{"id":3188,"library":"onnx-ir","title":"ONNX Intermediate Representation (IR)","description":"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.","status":"active","version":"0.2.0","language":"python","source_language":"en","source_url":"https://github.com/onnx/ir-py","tags":["onnx","ir","intermediate representation","ml","deep learning","graph optimization"],"install":[{"cmd":"pip install onnx-ir","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for ONNX model manipulation.","package":"onnx","optional":false},{"reason":"Used for tensor data handling.","package":"numpy","optional":false},{"reason":"Added in v0.2.0 for symbolic shape inferencing infrastructure.","package":"sympy","optional":false}],"imports":[{"wrong":"from onnx_ir import Graph","symbol":"Graph","correct":"from onnx_ir import Graph"}],"quickstart":{"code":"import onnx_ir as ir\nimport numpy as np\n\n# Create input values with specific types and shapes\ninput_a = ir.Value(\"input_a\", ir.Type(ir.Shape([2, 2]), ir.TensorElementDataType.FLOAT))\ninput_b = ir.Value(\"input_b\", ir.Type(ir.Shape([2, 2]), ir.TensorElementDataType.FLOAT))\n\n# Define the output value for the Add node\noutput_c = ir.Value(\"output_c\") \n\n# Create an 'Add' node with inputs and outputs\nadd_node = ir.Node(\"Add\", inputs=[input_a, input_b], outputs=[output_c])\n\n# Assemble a graph from inputs, outputs, and nodes\ngraph = ir.Graph(\n    [input_a, input_b], # Graph inputs\n    [output_c],         # Graph outputs\n    [add_node],         # Nodes in the graph\n    \"simple_add_graph\"  # Name of the graph\n)\n\nprint(f\"Created graph: {graph.name}\")\nprint(f\"Graph has {len(graph.nodes)} node(s).\")\nprint(f\"Input 'input_a' shape: {input_a.type.shape.dims}\")","lang":"python","description":"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`."},"warnings":[{"fix":"Replace `ir.Input` with `ir.val`. Update node attribute definitions to use tuples for repeating attributes as specified in the updated API documentation.","message":"In `v0.1.9`, the `ir.Input` class was deprecated in favor of `ir.val`. Additionally, attribute signatures for nodes were simplified, requiring tuples for repeating attributes. Code using the old `ir.Input` or the previous attribute signature format will break.","severity":"breaking","affected_versions":">=0.1.9"},{"fix":"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.","message":"When using the `Value.replace_all_uses_with` method (introduced in `v0.1.12`) with the `replace_graph_outputs` option, users are responsible for manually assigning the original output name to the replacement value if they wish to preserve the graph's signature. Failing to do so can lead to a modified graph signature.","severity":"gotcha","affected_versions":">=0.1.12"},{"fix":"Ensure your environment is prepared for the additional `sympy` dependency. No code changes are required unless you were explicitly trying to avoid `sympy`.","message":"The `v0.2.0` release introduced `sympy` as a new dependency for symbolic shape inferencing. This will increase the total install size and might slightly extend the installation time for new environments.","severity":"gotcha","affected_versions":">=0.2.0"}],"env_vars":null,"search_vec":"'0.2.0':35 'activ':50 'allow':18 'cadenc':41 'creation':21 'current':32 'deep':57 'develop':51 'effici':10 'frequent':39 'graph':17,59 'in-memori':11 'indic':49 'intermedi':2,54 'ir':4,7,53 'learn':58 'manipul':22 'memori':13 'ml':56 'model':27 'month':48 'multipl':44 'often':42 'onnx':1,6,16,26,52 'onnx-ir':5 'optim':24,60 'patch':45 'per':47 'programmat':20 'provid':8 'python':29 'releas':40,46 'represent':3,14,55 'see':43 'version':34","created_at":"2026-04-11T09:24:47.918748+00:00","updated_at":"2026-04-16T17:32:33.676698+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmp_ipkl_xx/venv/lib/python3.12/site-packages/onnx_ir/__init__.py\", line 161, in <module>\n    from onnx_ir._safetensors import save_safetensors\n  File \"/tmp/tmp_ipkl_xx/venv/lib/python3.12/site-packages/onnx_ir/_s"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.0.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://onnx.ai/ir-py","github":"https://github.com/onnx/ir-py","docs":null,"changelog":null,"pypi":"https://pypi.org/project/onnx-ir/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-08-28","next_check":"2026-07-10","install_tag":null}}