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