onnx-ir
Efficient in-memory representation for ONNX
What it is and what it does
onnx-ir is an in-memory intermediate representation layer for ONNX models that decouples graph manipulation from protobuf serialization. It provides a Pythonic API for constructing, analyzing, and transforming ONNX computation graphs while supporting the full ONNX specification. The package is designed to handle large models efficiently through memory-mapped external tensors and unified interfaces for different tensor types (numpy arrays, PyTorch tensors, ONNX TensorProto), with no hard limits on tensor size and zero-copy semantics where possible.
The IR is built on core entities—Model, Graph, Node, Value—that map intuitively to ONNX protobuf concepts but remain independent of the serialization format once loaded. It supports robust mutation with concurrent iterators on the graph, making it suitable for workflows that need to inspect and modify model structure programmatically. The package targets developers building ONNX tooling, model optimization pipelines, or graph-level analysis tools.
Use it for:
- Build ONNX models programmatically by constructing graphs through the IR API rather than working directly with protobuf.
- Analyze and traverse ONNX model topology to extract information about layers, connections, and data flow.
- Transform and optimize ONNX graphs by mutating nodes and values while iterating over the graph structure.
- Load and repair invalid ONNX models that cannot be loaded via standard protobuf deserialization.
- Integrate ONNX model manipulation into larger ML tooling pipelines without protobuf as a runtime dependency.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
onnx-ir provides an in-memory intermediate representation for ONNX models that supports the full ONNX specification, enabling graph construction, analysis, and transformation without requiring protobuf after initial conversion.
Yes. onnx-ir is actively maintained (released 2026-08-11), has no known vulnerabilities, carries a permissive Apache-2.0 license, and low install friction. It is worth installing if you need to programmatically construct, analyze, or transform ONNX graphs. The IR abstraction is most valuable for tooling and optimization workflows; for simple model inference, standard ONNX Runtime is more direct.
Install
onnx-ir on PyPI
pip
pip install onnx-iruv
uv add onnx-irpoetry
poetry add onnx-irInstalling onnx-ir
Before you install
Installation is straightforward with low friction; the package has active maintenance (last commit 2026-08-10, released 2026-08-11) and requires only five runtime dependencies including numpy, onnx, typing_extensions, ml_dtypes, and sympy.
License in practice
Licensed under Apache-2.0 (permissive), so you can use, modify, and distribute onnx-ir freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install onnx-ir
import onnx_ir
from onnx_ir import Model
# Load and manipulate an ONNX model via the IR
model = Model.load('model.onnx')
Requires Python >=3.9; onnx package must be installed as a runtime dependency.
Verify before relying
- Whether the IR can load and fix invalid ONNX models as claimed in the description.
- Performance characteristics and memory footprint compared to direct protobuf manipulation.
- Whether mmap'ed external tensors and zero-copy semantics are production-ready.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — numpy, onnx, typing_extensions, ml_dtypes, sympy |
| Maintenance | actively maintained — 3 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,113,169/month — #2,748 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: onnx_ir-1.0.0-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
onnx-graphsurgeonONNX GraphSurgeon lets you programmatically…
permissive · top 15,000 on PyPI
onnxoptimizerApplies graph-level optimizations to ONNX…
permissive · top 15,000 on PyPI
onnxscriptWrite ONNX functions and models in Python…
permissive · top 5,000 on PyPI
onnxsimSimplifies ONNX neural network models by…
permissive · top 15,000 on PyPI
onnx-weeklyonnx-weekly provides a Python package for…
permissive · top 15,000 on PyPI
onnxONNX provides an open-source format and runtime…
permissive · top 5,000 on PyPI
onnx-toolParse, analyze, optimize, and profile ONNX…
permissive · top 15,000 on PyPI
pyvexPyVEX provides Python bindings to libVEX,…
copyleft · top 15,000 on PyPI
xdslxDSL is a Python framework for building…
permissive · top 15,000 on PyPI
vineyardVineyard is an in-memory immutable data manager…
permissive · top 15,000 on PyPI