is_memmap_archive#
- tensordict.is_memmap_archive(path: str | Path) bool#
Whether
pathis a memory-mapped tensordict archive.An archive is a zip file with a top-level
meta.jsonentry, as written bypack_memmap()or bysave()with a".tdz"path. A directory, a missing path or another file givesFalse.- Parameters:
path (str or Path) – the path to check.
Examples
>>> import tempfile >>> from pathlib import Path >>> import torch >>> from tensordict import TensorDict, is_memmap_archive >>> td = TensorDict(a=torch.zeros(3)) >>> with tempfile.TemporaryDirectory() as path: ... _ = td.save(Path(path) / "td.tdz") ... _ = td.save(Path(path) / "td") ... print(is_memmap_archive(Path(path) / "td.tdz"), is_memmap_archive(Path(path) / "td")) True False