Efficient in-memory representation for ONNX
Project Links
Meta
Author: ONNX Contributors
Requires Python: >=3.9
Classifiers
Development Status
- 4 - Beta
An in-memory IR that supports the full ONNX spec, designed for graph construction, analysis and transformation.
Getting Started
Installation
Via pip:
pip install onnx-ir
Or from source:
pip install git+https://github.com/onnx/ir-py.git
Features ✨
- Full ONNX spec support: all valid models representable by ONNX protobuf, and a subset of invalid models (so you can load and fix them).
- Low memory footprint: mmap'ed external tensors; unified interface for ONNX TensorProto, Numpy arrays and PyTorch Tensors etc. No tensor size limitation. Zero copies.
- Straightforward access patterns: Access value information and traverse the graph topology at ease.
- Robust mutation: Create as many iterators as you like on the graph while mutating it.
- Speed: Performant graph manipulation, serialization/deserialization to Protobuf.
- Pythonic and familiar APIs: Classes define Pythonic apis and still map to ONNX protobuf concepts in an intuitive way.
- No protobuf dependency: The IR does not require protobuf once the model is converted to the IR representation, decoupling from the serialization format.
Concept Diagram
Code Organization 🗺️
_protocols.py
: Interfaces defined for all entities in the IR._core.py
: Implementation of the core entities in the IR, includingModel
,Graph
,Node
,Value
, and others._enums.py
: Definition of the type enums that correspond to theDataType
andAttributeType
inonnx.proto
._name_authority.py
: The authority for giving names to entities in the graph, used internally._linked_list.py
: The data structure as the node container in the graph that supports robust iteration and mutation. Internal._metadata.py
: Metadata store for all entities in the IR.
Oct 15, 2025
0.1.11
Sep 30, 2025
0.1.10
Sep 12, 2025
0.1.9
Sep 05, 2025
0.1.8
Aug 22, 2025
0.1.7
Aug 11, 2025
0.1.6
Aug 08, 2025
0.1.5
Jul 04, 2025
0.1.4
Jun 26, 2025
0.1.3
Jun 18, 2025
0.1.2
Jun 03, 2025
0.1.1
May 29, 2025
0.1.0
Jan 30, 2025
0.0.1