tree: 58d28133cfcb783b473188bb4a14be750479a5d0
  1. tvm-ffi/
  2. tvm-ffi-macros/
  3. tvm-ffi-sys/
  4. Cargo.toml
  5. README.md
rust/README.md

Rust Packages

(Experimental) Rust support for the tvm-ffi ABI. Currently, the rust support is in an experimental stage. This workspace contains three crates:

  • tvm-ffi: Safe, ergonomic Rust bindings over the ABI.
  • tvm-ffi-sys: Low-level exposure of raw C ABIs.
  • tvm-ffi-macros: Procedural macros used by tvm-ffi (derive/object helpers and exported function helpers).

The overall project focuses on low-level, direct access to the ABI when possible for maximum efficiency while maintaining interoperability.

Installation

The Rust support depends on libtvm_ffi. Please install the tvm-ffi pip package by running:

pip install -v ..

Confirm that tvm-ffi-config is available with:

tvm-ffi-config --libdir

Then build the workspace with:

cargo build

The build will:

  • Query tvm-ffi-config --libdir to add the appropriate link search path.
  • Link against tvm_ffi.
  • Update the appropriate dynamic loader path environment variable for cargo run and cargo test.

For running downstream applications, you need to set the LD_LIBRARY_PATH so libtvm_ffi is available in the path.

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:`tvm-ffi-config --libdir`

Running Examples

You can run an optional library-loading example similar to the quick_start examples in examples/quick_start.

cargo run --example load_library --features example

Check out the load_library.rs for details.