Skip to content

Latest commit

 

History

51 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TVM Rust extension

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.

Build and test

With Rust installed and a Python environment active:

python -m pip install -r requirements.txt
cargo test

TVM 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.

Regenerate bindings

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 fmt

Generated 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.

Python demo

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.py

See BINDING_CONTRACT.md for binding requirements and STUBGEN_FEEDBACK.md for generator details and remaining gaps.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages