Skip to content

unienv_data.batches.backend_compat

Classes:

Name Description
ToBackendOrDeviceBatch

Functions:

Name Description
data_to

Attributes:

Name Type Description
WrapperBatchT
WrapperBArrayT
WrapperBDeviceT
WrapperBDtypeT
WrapperBRngT

WrapperBatchT module-attribute

WrapperBatchT = TypeVar('WrapperBatchT')

WrapperBArrayT module-attribute

WrapperBArrayT = TypeVar('WrapperBArrayT')

WrapperBDeviceT module-attribute

WrapperBDeviceT = TypeVar('WrapperBDeviceT')

WrapperBDtypeT module-attribute

WrapperBDtypeT = TypeVar('WrapperBDtypeT')

WrapperBRngT module-attribute

WrapperBRngT = TypeVar('WrapperBRngT')

ToBackendOrDeviceBatch

ToBackendOrDeviceBatch(
    batch: BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType],
    backend: Optional[
        ComputeBackend[WrapperBArrayT, WrapperBDeviceT, WrapperBDtypeT, WrapperBRngT]
    ] = None,
    device: Optional[WrapperBDeviceT] = None,
)

Bases: Generic[WrapperBatchT, WrapperBArrayT, WrapperBDeviceT, WrapperBDtypeT, WrapperBRngT, BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType], BatchBase[WrapperBatchT, WrapperBArrayT, WrapperBDeviceT, WrapperBDtypeT, WrapperBRngT]

Methods:

Name Description
get_flattened_at
get_flattened_at_with_metadata
set_flattened_at
extend_flattened
get_at
get_at_with_metadata
set_at
extend
remove_at
close

Release this view. The wrapped batch is not owned by the view and stays open;

append_flattened

Append one flattened sample to the batch.

append

Append one structured sample to the batch.

extend_from

Copy data from another batch in bounded-size chunks.

get_slice

Create a lazy view over a subset of indices.

get_column

Create a lazy view over a nested field inside each sample.

Attributes:

Name Type Description
batch
target_backend
target_device
is_mutable bool
backend ComputeBackend[WrapperBArrayT, WrapperBDeviceT, WrapperBDtypeT, WrapperBRngT]
device Optional[WrapperBDeviceT]
single_space
single_metadata_space

batch instance-attribute

batch = batch

target_backend instance-attribute

target_backend = backend

target_device instance-attribute

target_device = device

is_mutable property

is_mutable: bool

backend property

device property

device: Optional[WrapperBDeviceT]

single_space instance-attribute

single_space = single_space

single_metadata_space instance-attribute

single_metadata_space = single_metadata_space

get_flattened_at

get_flattened_at(idx)

get_flattened_at_with_metadata

get_flattened_at_with_metadata(idx)

set_flattened_at

set_flattened_at(idx, value)

extend_flattened

extend_flattened(value)

get_at

get_at(idx)

get_at_with_metadata

get_at_with_metadata(idx)

set_at

set_at(idx, value)

extend

extend(value)

remove_at

remove_at(idx)

close

close()

Release this view. The wrapped batch is not owned by the view and stays open; close it through whoever created it (BatchBase.__del__ calls close(), so closing the source here would tear it down whenever a view is garbage-collected).

append_flattened

append_flattened(value: BArrayType) -> None

Append one flattened sample to the batch.

append

append(value: BatchT) -> None

Append one structured sample to the batch.

extend_from

extend_from(
    other: BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType],
    chunk_size: int = 8,
    tqdm: bool = False,
) -> None

Copy data from another batch in bounded-size chunks.

get_slice

get_slice(
    idx: Union[IndexableType, BArrayType],
) -> BatchBase[BatchT, BArrayType, BDeviceType, BDtypeType, BRNGType]

Create a lazy view over a subset of indices.

get_column

get_column(
    nested_keys: Sequence[str],
) -> BatchBase[Any, BArrayType, BDeviceType, BDtypeType, BRNGType]

Create a lazy view over a nested field inside each sample.

data_to

data_to(
    data: Any,
    source_backend: Optional[
        ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType]
    ] = None,
    target_backend: Optional[
        ComputeBackend[WrapperBArrayT, WrapperBDeviceT, WrapperBDtypeT, WrapperBRngT]
    ] = None,
    target_device: Optional[WrapperBDeviceT] = None,
)