Skip to main content

Module io

Module io 

Source
Expand description

HDF5 .nir read/write.

.nir is the official NIR interchange format: an HDF5 container whose layout is fixed by upstream neuromorphs/NIR. Files written here load in Python nir.read, and files written by Python nir.write load in read. See wire for the layout itself.

§Feature gate

The implementation lives behind the hdf5 feature, which links the native libhdf5 library. It is off by default so that the graph model stays dependency-free for consumers that only build or inspect graphs:

nir-rs = { version = "0.4", features = ["hdf5"] }

System dependency: libhdf5-dev (Debian/Ubuntu), hdf5 (Homebrew), or add hdf5-metno as a direct dependency with features = ["static", "zlib"] for a hermetic build from vendored source.

Every item in this module exists in both builds — only the bodies are gated. Without the feature, read, write() and read_version return NirError::Unimplemented rather than failing to compile, so downstream code can be written once and feature-gated at the call site if it wants to.

§Version string

Upstream writes the version of the Python nir package into /version and never validates it on read. This crate follows suit:

§Non-goals

Byte-identical output versus h5py (group ordering, chunk layout and filter parameters may differ), and the separate NIRGraphData observables layout that upstream read_data / write_data handle.

Modules§

wire
Vocabulary of the NIR HDF5 wire format.

Structs§

ReadOptions
Allocation policy for decoding an untrusted .nir file with read_with.
WriteOptions
Tuning knobs for write_with.

Constants§

DEFAULT_NIR_VERSION
Version string written to /version when a graph carries none.

Functions§

read
Read a NIR graph from a .nir (HDF5) path.
read_version
Read only the /version string from a .nir file.
read_version_with
Read only /version with an explicit decoded-allocation budget.
read_with
Read a NIR graph with an explicit decoded-allocation budget.
write
Write a NIR graph to a .nir (HDF5) path atomically.
write_with
Write a NIR graph to a .nir (HDF5) path with explicit options.