Data Formats and Plotting¶
The jacobi::io module provides pure-Rust helpers for common scientific data formats and lightweight SVG charts.
Supported Formats¶
| Module | Functions | Format |
|---|---|---|
io::npy |
load_npy, save_npy, load_idx_gz |
NumPy .npy arrays and gzipped MNIST IDX files |
io::image |
load_png, save_png |
8-bit PNG images as NHWC float tensors |
io::audio |
load_wav, load_wav_i16, save_wav |
16-bit PCM WAV waveforms (f32 or raw i16) |
io::table |
load_csv, save_csv |
Numeric CSV tables |
io::text |
SentencePiece, Tokenizer, load_bytes, decode_bytes |
Raw SentencePiece .model, HF tokenizers, and byte corpora |
io::safetensors |
save, save_with_metadata, read_metadata, load_map, load_sharded, load_into, load_from_map |
Single and sharded safetensors checkpoints with native BF16/F16/I16 |
io::dlpack |
to_dlpack, from_dlpack, from_dlpack_ptr, DlPackCapsule |
Zero-copy DLPack C-ABI tensor exchange with PyTorch, NumPy, and JAX |
io::onnx |
export_onnx, trace_export_onnx |
Standalone ONNX (IR v9, Opset 18) models |
io::export |
export_mlir, trace_export_mlir, export_mlir_with_weights |
Standalone and external-weight StableHLO MLIR modules |
io::serve |
serve_mlir, serve_mlir_with_weights, MlirRunner |
Built-in HTTP JSON inference server |
SVG Plotting (io::plot)¶
Generate clean, dependency-free SVG charts directly from tensors.
use jacobi::io::plot::Figure;
use jacobi::prelude::*;
let x = Tensor::linspace(0.0, 6.28, 64);
let y = x.sin();
Figure::new()
.title("sin(x)")
.xlabel("x")
.ylabel("y")
.plot(&x, &y, Some("sin"))?
.save_svg("sin.svg")?;
Figure supports line plots (.plot), scatter plots (.scatter), and 2D heatmaps or images (.imshow), returning raw SVG via .render_svg() or writing directly with .save_svg(path).
SentencePiece .model Tokenizers (SentencePiece)¶
Load raw SentencePiece .model protobuf files directly in pure Rust (with Unigram Viterbi, BPE, Char, and <0xXX> byte fallback) and recover exact UTF-8 byte offsets for alignment and timestamping.