onnx-ir provides an efficient in-memory representation for ONNX graphs, allowing for programmatic creation, manipulation, and optimization of ONNX models in Python. It is currently at version 0.2.0 and has a frequent release cadence, often seeing multiple patch releases per month, indicating active development.
pip install onnx-irVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a simple ONNX graph representing an 'Add' operation using `onnx-ir`'s core components: `Value`, `Type`, `Shape`, `Node`, and `Graph`.
Replace `ir.Input` with `ir.val`. Update node attribute definitions to use tuples for repeating attributes as specified in the updated API documentation.
After calling `Value.replace_all_uses_with` with `replace_graph_outputs=True`, ensure the replacement `Value` has its `.name` attribute set to the original output's name if graph signature preservation is desired.
Ensure your environment is prepared for the additional `sympy` dependency. No code changes are required unless you were explicitly trying to avoid `sympy`.