NNEF¶
- class tract.nnef.Nnef[source]¶
Represent a NNEF context in tract.
NNEF is a neural model interchange format, similar to ONNX but focusing on the needs of an inference engine instead of a training framework.
tractcan natively load NNEF models. It can also save models in tract internal format astract-oplmodels.tract-oplis a set of proprietary extensions to NNEF allowing serialization of most of the models tract can handle. These extensions can be activated by thewith_*()methods.- load(path: str | Path) Model[source]¶
Load an NNEF model from the file or folder at
path.model = ( tract.nnef() .load("mobilenet_v2_1.0.onnx.nnef.tgz") .into_runnable() )
- with_tract_core() Nnef[source]¶
Enable tract-opl extensions to NNEF to covers tract-core operator set
- with_pulse() Nnef[source]¶
Enable tract-opl extensions to NNEF for tract pulse operators (for audio streaming)
- with_extended_identifier_syntax() Nnef[source]¶
Enable tract-opl extensions to NNEF for extended identifiers (will support PyTorch 2 path-like ids)
- write_model_to_dir(model: Model, path: str | Path) None[source]¶
Save
modelas a NNEF directory model inpath.tract tries to stick to strict NNEF even if extensions have been enabled.