iree-tools CLI Reference
Commands
compile
Compile a StableHLO MLIR file to IREE VMFB for both host and rv32 targets.
uv run python main.py compile <input.mlir>
Produces:
-
out/<stem>_host.vmfb— host-native bytecode (x86_64/arm64) -
out/<stem>_rv32.vmfb— RISC-V 32-bit bytecode (not runnable on NPU without IREE runtime)
verify
Compile for host and run iree-run-module to produce reference output.
uv run python main.py verify <input.mlir>
If the MLIR function has arguments, IREE fills them with default values (zeros). The output serves as a correctness reference for comparing against simulator results.
generate-c
Transpile StableHLO MLIR to C source code compatible with coralnpu_v2_binary.
uv run python main.py generate-c <input.mlir> [-o output.cc]
| Argument | Required | Description |
|---|---|---|
|
Yes |
Path to StableHLO MLIR file |
|
No |
Output C file path (default: |
build-elf
Generate C source, write BUILD.bazel, and invoke Bazel to produce a bare-metal ELF.
uv run python main.py build-elf <input.mlir>
This command:
-
Parses the MLIR and generates C source
-
Writes
.ccandBUILD.bazelto../coralnpu/examples/generated/<stem>/ -
Runs
bazel buildin thecoralnpuworkspace
Output ELF path: ../coralnpu/bazel-bin/examples/generated/<stem>/coralnpu_v2_<stem>.elf
simulate
Run an ELF binary on the MPACT behavioral simulator.
uv run python main.py simulate <input.elf> [--output-sizes sym=N ...]
| Argument | Required | Description |
|---|---|---|
|
Yes |
Path to ELF binary |
|
No |
Output symbol sizes as |
Example:
uv run python main.py simulate program.elf --output-sizes output_0=64 output_1=32
run-all
Execute the full end-to-end pipeline: compile → verify → generate C → build ELF → simulate → compare.
uv run python main.py run-all <input.mlir>
Steps executed:
-
Compile MLIR for host →
out/<stem>_host.vmfb -
Run on host via
iree-run-module→ reference output -
Transpile MLIR → C source
-
Write generated files to
coralnpu/examples/generated/<stem>/ -
Build ELF via Bazel
-
Run ELF on MPACT simulator
-
Print host vs. simulator outputs for comparison
IREE Compiler Flags
Used internally by the compile and verify commands:
Host Compilation
| Flag | Value |
|---|---|
|
|
|
|
|
|
|
|
RV32 Compilation
| Flag | Value |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
The +f CPU feature is required. Without it, the compiler emits soft-float code that needs mulsf3/addsf3 builtins not available in the bare-metal link environment.
|
Python Module Reference
mlir_parser.py
| Function | Purpose |
|---|---|
|
Parse complete StableHLO MLIR text into IR dataclasses |
|
Parse |
|
Extract float values from nested bracket notation |
|
Parse a |
|
Parse a |
|
Parse |
|
Parse |
|
Parse |
ir.py
| Class | Fields |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
codegen.py
| Function | Purpose |
|---|---|
|
Generate complete C source from IR module |
|
Emit 1×1 optimized or general 7-loop convolution |
|
Emit element-wise |