TensorPlay
API symbolsserialization
Copy
View MarkdownDownload .md

tensorplay.serialization.save

tensorplay.serialization.save(obj: Any, f: str | PathLike[str], *, metadata: Mapping[str, Any] | None = None, alignment: int = 4096, checksum: str = 'crc32', pickle_protocol: int = 2) None[source]

Save obj to disk.

Formats are selected by extension:

  • .mega (default): native MEGA artifact. Supports nested tensor containers plus JSON-primitive leaves, shared-storage deduplication, an alignment, per-region checksum ("crc32", "sha256", or "none") and free-form metadata (strings, numbers, bools, lists).

  • .safetensors: flat name->tensor mapping.

  • .pt / .pth: torch-compatible archive; any picklable object graph.

A file-like object (io.BytesIO etc.) receives the torch pickle format, matching torch.save conventions.

Ask DeepWiki