Skip to main content

nuvec_io/
lib.rs

1//! Reading and writing arrays: safetensors (MLX's checkpoint format) and NumPy's `.npy`,
2//! any tree of arrays by path ([`save`], [`load_into`]),
3//! the IDX format (MNIST) and a minimal [`json`] parser for model files. Files whose
4//! tensors are aligned (files nuvec writes are) are memory-mapped without a copy; others,
5//! such as mlx-community checkpoints with unpadded headers, are read once at load, in
6//! parallel, without being mapped.
7//!
8//! **Stability:** no promise when this crate is depended on directly; depend on `nuvec`,
9//! whose re-exports are semver-tracked.
10//!
11//! **Status:** pre-alpha.
12
13#![forbid(unsafe_code)]
14
15mod idx;
16pub mod json;
17mod npy;
18mod safetensors;
19mod tree;
20
21pub use idx::{parse_idx, read_idx};
22pub use npy::{load_npy, save_npy};
23pub use safetensors::{
24    Footprint, SafeTensors, SaveHandle, TensorInfo, align_safetensors, load_safetensors,
25    load_safetensors_cached, load_safetensors_filtered, safetensors_footprint,
26    safetensors_footprint_filtered, safetensors_tensors, save_safetensors, save_safetensors_async,
27};
28pub use tree::{load_into, save};
29
30/// The version of this crate.
31pub const VERSION: &str = env!("CARGO_PKG_VERSION");