An MLIR-based compiler and runtime that lowers ML models to a unified IR for deployment from datacenters to mobile and edge devices.
onnx/onnx-mlir
A compiler that lowers ONNX neural network graphs through MLIR into code with minimal runtime dependencies.
- Stars
- 1,066
- Forks
- 457
- Open issues
- 357
- Last commit
- yesterday
What is it?
ONNX-MLIR takes a valid ONNX model graph and compiles it into code that implements the graph, aiming for minimal runtime support. It implements the ONNX standard and is built on the LLVM/MLIR compiler infrastructure.
The project provides an ONNX dialect that other MLIR-based projects can integrate, compiler interfaces that lower ONNX graphs to MLIR files, LLVM bytecode, or C and Java libraries, and an onnx-mlir command-line driver. It also includes Python, C, C++, and Java runtime interfaces for loading and running compiled models.
Support for individual ONNX operations is tracked per target, including a generic CPU backend and IBM's Telum integrated AI accelerator. Builds run natively on Linux, macOS, and Windows, and Docker images are offered as the recommended setup.
Key features
- 01Converts ONNX graphs into MLIR, LLVM IR, object files, shared libraries, or JAR files.
- 02Provides an ONNX dialect that other MLIR projects can reuse.
- 03Offers Python, C, C++, and Java runtime interfaces.
- 04Supports optimization levels O0 through O3 and can read flags from an environment variable.
- 05Publishes per-operation support tables for CPU and IBM Telum NNPA targets.
Use cases
- Deploying ONNX models as compiled libraries with minimal runtime dependencies.
- Targeting IBM Telum servers with ONNX models via the NNPA backend.
- Building compiler tooling that integrates the ONNX dialect into an MLIR pipeline.
Quick start
- 1
Set up with prebuilt Docker containers (see docs/Docker.md)
- 2
Build ONNX-MLIR directly on Linux or macOS (see docs/BuildOnLinuxOSX.md)
- 3
Lower an ONNX model to the ONNX dialect with the built driver
./onnx-mlir --EmitONNXIR add.onnx
Things to know
- Building from source requires a specific LLVM/MLIR commit and several prerequisites such as clang, protobuf and cmake.
- There is no simple package-manager install; setup can be tricky on some systems, so Docker is recommended.
- Operation support is limited to the operations listed in the project's supported-ops documents.
In collections
Topics
FAQ
- What is onnx-mlir?
- A compiler that lowers ONNX neural network graphs through MLIR into code with minimal runtime dependencies. ONNX-MLIR takes a valid ONNX model graph and compiles it into code that implements the graph, aiming for minimal runtime support. It implements the ONNX standard and is built on the LLVM/MLIR compiler infrastructure.
- Is onnx-mlir free to use? What license does it have?
- onnx-mlir is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is onnx-mlir still maintained?
- Actively maintained. The last commit to onnx-mlir was on Nov 6, 2026.
- What can I use onnx-mlir for?
- Deploying ONNX models as compiled libraries with minimal runtime dependencies. Targeting IBM Telum servers with ONNX models via the NNPA backend. Building compiler tooling that integrates the ONNX dialect into an MLIR pipeline.
- How do I install onnx-mlir?
- Set up with prebuilt Docker containers (see docs/Docker.md) Build ONNX-MLIR directly on Linux or macOS (see docs/BuildOnLinuxOSX.md) Lower an ONNX model to the ONNX dialect with the built driver: ./onnx-mlir --EmitONNXIR add.onnx
- Where can I get onnx-mlir?
- The source code and installation instructions are on GitHub: https://github.com/onnx/onnx-mlir
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A language and compiler for writing highly efficient custom deep-learning GPU kernels in Python-like code, with higher productivity than CUDA.
A cross-platform accelerator for running ML models exported to ONNX format, with training support for PyTorch scripts.
An engine-agnostic deep learning framework for Java that lets developers build, train, and run models with a native Java API.
Ultralytics YOLOv5, a PyTorch-based computer vision toolkit for object detection, instance segmentation and image classification with training and export.
A high-performance neural network inference framework in C++ for running deep learning models on mobile, embedded, and desktop devices.