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:
readstores/versioninNirGraph::version, and leaves itNonewhen the dataset is absent. It is never an error.read_versionis the strict accessor and does error when absent.write()emitsNirGraph::versionwhen set, elseDEFAULT_NIR_VERSION.
§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§
- Read
Options - Allocation policy for decoding an untrusted
.nirfile withread_with. - Write
Options - Tuning knobs for
write_with.
Constants§
- DEFAULT_
NIR_ VERSION - Version string written to
/versionwhen a graph carries none.
Functions§
- read
- Read a NIR graph from a
.nir(HDF5) path. - read_
version - Read only the
/versionstring from a.nirfile. - read_
version_ with - Read only
/versionwith 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.