Skip to content

Work directly with textual MLIR.

Read, query, compare and edit MLIR in Rust, Python or the command line. Zirium keeps the original source and works without linking LLVM.
Rust · Python · CLI · Experimental

Zirium’s parser retains the original bytes, including comments, whitespace and malformed input. A separate semantic document resolves SSA values, types and symbols for queries, comparisons and transactional edits. Choose the representation that fits the work.

Install the published Python package:

Terminal window
python -m pip install zirium

Wheels cover conventional CPython 3.11–3.14 on Linux x86_64 and macOS arm64. Other platforms and free-threaded CPython are unsupported. The Python wheel does not include the CLI.

With Rust 1.88 or newer, install the published CLI:

Terminal window
cargo install zirium --locked

For a Rust application, add the library with cargo add zirium and consult the Rust API reference. The getting-started guide covers library usage and building from a checkout.

GitHub Releases provides standalone CLI archives for Linux x86_64 (static musl) and macOS arm64. These do not require Rust, Python or LLVM. Follow the download and checksum instructions for your platform.

This example reads generic MLIR from stdin and needs no dialect registry:

Terminal window
printf '%s\n' '"example.make"() : () -> i32' | zirium 'names | tally | json'

For a file using registered custom syntax, choose a preset and use strict lowering to reject incomplete semantic information:

Terminal window
zirium --preset stablehlo --strict 'names | tally | json' model.mlir

The query language reference lists predicates and pipeline stages. The preset reference records which custom forms each registry supports.

Zirium is experimental and its API may change without a migration path. Its textual syntax target is MLIR 22.1, with selected custom dialect forms. Presets support structural inspection; they do not provide complete dialect verification, type inference or execution. Bytecode and ODS/TableGen loading are unsupported.

Original output reproduces the input bytes. Formatting, canonical output and source-preserving edits each have a different contract. Read the capability reference and structural editing guide before choosing an output path.