Skip to content

unienv_data.storages.pytorch

PytorchTensorStorage

PytorchTensorStorage(single_instance_space: Union[BoxSpace[PyTorchArrayType, PyTorchDeviceType, PyTorchDtypeType, PyTorchRNGType], BinarySpace[PyTorchArrayType, PyTorchDeviceType, PyTorchDtypeType, PyTorchRNGType]], data: Union[Tensor, MemoryMappedTensor], mutable: bool = True)

Bases: SpaceStorage[PyTorchArrayType, PyTorchArrayType, PyTorchDeviceType, PyTorchDtypeType, PyTorchRNGType]

backend class-attribute instance-attribute

backend = PyTorchComputeBackend

single_file_ext class-attribute instance-attribute

single_file_ext: str = '.memmap'

data instance-attribute

data = data

device property

device: Optional[PyTorchDeviceType]

cache_filename property

cache_filename: Optional[Union[str, PathLike]]

is_mutable property

is_mutable: bool

is_multiprocessing_safe property

is_multiprocessing_safe: bool

capacity property

capacity: int

is_memmap property

is_memmap: bool

single_instance_space instance-attribute

single_instance_space = single_instance_space

create classmethod

create(single_instance_space: BoxSpace[PyTorchArrayType, PyTorchDeviceType, PyTorchDtypeType, PyTorchRNGType], *, capacity: Optional[int], is_memmap: bool = True, cache_path: Optional[str] = None, multiprocessing: bool = False, memmap_existok: bool = True) -> PytorchTensorStorage

load_from classmethod

load_from(path: Union[str, PathLike], single_instance_space: Union[BoxSpace[PyTorchArrayType, PyTorchDeviceType, PyTorchDtypeType, PyTorchRNGType], BinarySpace[PyTorchArrayType, PyTorchDeviceType, PyTorchDtypeType, PyTorchRNGType]], *, is_memmap: bool = True, capacity: Optional[int] = None, read_only: bool = True, multiprocessing: bool = False, **kwargs) -> PytorchTensorStorage

get

get(index: Union[int, slice, Tensor]) -> torch.Tensor

set

set(index: Union[int, slice, Tensor], value: Tensor) -> None

clear

clear() -> None

dumps

dumps(path: Union[str, PathLike]) -> None

close

close()

extend_length

extend_length(length: int) -> None

This is used by capacity = None storages to extend the length of the storage If this is called on a storage with a fixed capacity, we will simply ignore the call.

shrink_length

shrink_length(length: int) -> None

This is used by capacity = None storages to shrink the length of the storage If this is called on a storage with a fixed capacity, we will simply ignore the call.