Rate this Page
★ ★ ★ ★ ★

TensorDictBase.load_memmap#

TensorDictBase.load_memmap_(prefix: str | Path, robust_key: bool | None = True, *, allow_pickle: bool | None = None, mode: str | None = None)#

Loads the content of a memory-mapped tensordict within the tensordict where load_memmap_ is called.

The tensordict and its nested containers are reused, but the leaves are rebound to the loaded tensors, so their storage is not reused. Keys that are missing from the saved data are removed. To write the data into the existing storage, use td.update_(TensorDict.load_memmap(prefix, device=td.device)) instead.

Parameters:
  • prefix (str or Path) – the directory, or the ".tdz" archive file, to read.

  • robust_key (bool, optional) – the key encoding used when the data was saved. See memmap(). Defaults to True.

Keyword Arguments:
  • allow_pickle (bool, optional) – whether pickled non-tensor fields may be loaded. Pickle can execute arbitrary code, so pass True only for data from a trusted source and False for untrusted data. As in load_memmap(), omitting this option loads pickle with a FutureWarning in 0.14 and 0.15, and the default changes to False in 0.16.

  • mode (str, optional) – the mode of the memory maps. See load_memmap().

See load_memmap() for more info.

Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.