onnx-ir

Efficient in-memory representation for ONNX

20 个版本 Python >=3.9
安装
pip install onnx-ir
poetry add onnx-ir
pipenv install onnx-ir
conda install onnx-ir
描述

ONNX IR

PyPI - Version Ruff codecov PyPI Downloads

An in-memory IR that supports the full ONNX spec, designed for graph construction, analysis and transformation.

Getting Started

onnx-ir documentation

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

Concept Diagram

Code Organization 🗺️

  • _protocols.py: Interfaces defined for all entities in the IR.
  • _core.py: Implementation of the core entities in the IR, including Model, Graph, Node, Value, and others.
  • _enums.py: Definition of the type enums that correspond to the DataType and AttributeType in onnx.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.
版本列表
0.2.1 2026-04-20
0.2.0 2026-02-24
0.1.16 2026-02-09
0.1.15 2026-01-21
0.1.14 2026-01-07
0.1.13 2025-12-17
0.1.12 2025-10-28
0.1.11 2025-10-15
0.1.10 2025-09-30
0.1.9 2025-09-12
0.1.8 2025-09-05
0.1.7 2025-08-22
0.1.6 2025-08-11
0.1.5 2025-08-08
0.1.4 2025-07-04
0.1.3 2025-06-26
0.1.2 2025-06-18
0.1.1 2025-06-03
0.1.0 2025-05-29
0.0.1 2025-01-30