Rust bindings for TVM's TIRx, generated using the tvm-ffi stubgen tool
(tvm-ffi-stubgen --target rust). The generated bindings cover tirx and
its shared ir and prim types. The crate also includes hand-written
semantic helpers and Rust implementations of TIRx passes.
With Rust installed and a Python environment active:
python -m pip install -r requirements.txt
cargo testTVM and tvm-ffi are consumed as packages. Python dependencies are pinned in
requirements.txt, and the Rust tvm-ffi dependency is
pinned in Cargo.toml. Keep python and tvm-ffi-config from
the active environment on PATH.
With the same Python environment active:
TVM_STUBGEN_LIB=$(python -c "import tvm, os; print(os.path.join(os.path.dirname(tvm.__file__), 'lib', 'libtvm_compiler.so'))")
tvm-ffi-stubgen --target rust --dlls "$TVM_STUBGEN_LIB" src
cargo fmtGenerated code lives in marked blocks in src/ir.rs, src/prim.rs, and src/tirx.rs. Hand-written helpers and passes live outside those blocks.
Build the shared library and run python/demo.py to load
it through tvm_ffi and use the exported passes:
cargo build
python python/demo.pySee BINDING_CONTRACT.md for binding requirements and STUBGEN_FEEDBACK.md for generator details and remaining gaps.