Skip to main content

ztensor_compat/
lib.rs

1//! Foreign tensor formats, projected into the zTensor object model.
2//!
3//! Every format here builds a [`Catalog`](ztensor::Catalog) of names, shapes,
4//! types and byte locations, then hands back an ordinary
5//! [`Source`](ztensor::Source). There is no per-format type in the public API,
6//! because after projection there is nothing per-format left to say:
7//!
8//! ```no_run
9//! let src = ztensor_compat::open("model.safetensors")?;
10//! let t = src.tensor("layer.weight")?;
11//! let bytes = t.map()?;          // zero-copy where the file allows it
12//! # Ok::<(), ztensor::Error>(())
13//! ```
14//!
15//! Projections are read-only and honest. A part's payload says which of the
16//! three shapes it has: a raw addressable range, something stored under an
17//! encoding, or bytes only the format's own reader can produce. It also
18//! [`Caps`](ztensor::Caps) is a direct reading of that. Nothing is silently
19//! reinterpreted or dequantized, and nothing degrades quietly to a copy.
20//!
21//! A projected file reports its *actual* offsets; the `.zt` guarantees (the
22//! 4096 floor, page exclusivity, digests) hold only for `.zt` files. To
23//! upgrade a foreign checkpoint, convert it: `Writer::ingest` copies any
24//! source into a canonical `.zt` file.
25
26mod detect;
27mod project;
28mod safe;
29
30#[cfg(feature = "safetensors")]
31mod safetensors;
32
33#[cfg(feature = "gguf")]
34mod gguf;
35
36#[cfg(feature = "npz")]
37mod npz;
38
39#[cfg(feature = "pickle")]
40mod pt;
41
42#[cfg(feature = "hdf5")]
43mod hdf5;
44
45#[cfg(feature = "onnx")]
46mod onnx;
47
48pub use detect::{detect, index, index_all, open, open_all, options, Open, FORMATS};