--- id: onnx-ir version: "1.0.0" license: Apache-2.0 license_treatment: permissive maintenance: active --- # onnx-ir — Efficient in-memory representation for ONNX License: permissive · Maintenance: active · Downloads: 3.1M/mo ## 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 above — 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 pip install onnx-ir uv add onnx-ir poetry add onnx-ir ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 3.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags onnx graph manipulation, onnx model ir representation, graph construction onnx, onnx model transformation, onnx graph analysis, in-memory onnx representation, onnx model editing, onnx-tooling, graph-ir, model-optimization [View on SkillFed](https://skillfed.io/packages/onnx-ir) · [View on PyPI](https://pypi.org/project/onnx-ir/)