Module safetensors::tensor

source ·
Expand description

Module Containing the most important structures

Structs

The stuct representing the header of safetensor files which allow indexing into the raw byte-buffer array and how to interpret it.
A structure owning some metadata to lookup tensors on a shared data byte-buffer (not owned).
A single tensor information. Endianness is assumed to be little endian Ordering is assumed to be ‘C’.
A view of a Tensor within the file. Contains references to data within the full byte-buffer And is thus a readable view of a single tensor

Enums

The various available dtypes
Possible errors that could occur while reading A Safetensor file.

Functions

Serialize to an owned byte buffer the dictionnary of tensors.
Serialize to a regular file the dictionnary of tensors. Writing directly to file reduces the need to allocate the whole amount to memory.