Installation¶
Requirements¶
Python 3.9+
pip23+
Install from PyPI¶
pip install onnx-ir
Install from source¶
git clone https://github.com/onnx/ir-py.git
cd ir-py
pip install -e .
Verify installation¶
python -c "import onnx_ir as ir; print(ir.__version__)"
Optional integrations¶
Install optional packages only for the workflows that need them:
Package |
Purpose |
|---|---|
|
IR-native symbolic shape inference with SymPy expressions and shape-data propagation |
|
Save model weights with |
|
Syntax-highlighted |
|
PyTorch tensor adapter and dtype conversion utilities |
pip install onnx-shape-inference "safetensors>=0.7.0" rich
ONNX IR does not require these packages for its core model, graph, and tensor APIs. See Model I/O, Tensor Representation, and Debugging transformations for integration-specific usage.
Recommended setup for production workflows¶
Use a dedicated virtual environment per project.
Pin exact versions in your lockfile (
requirements.txt,uv.lock, or similar).Run with a tested ONNX version from your environment matrix.
For external tensor loading from untrusted artifacts, always set
base_dir.
See Security for details.