This repository provides a minimal example for deploying Apache TVM's Relax IR using the C++ API.
Note: This project supports Apache TVM FFI.
This project demonstrates how to build and deploy a Relax IR model using TVM's C++ API. It includes instructions for setting up dependencies, building TVM from source, and running the example binary.
Ensure the following tools and libraries are installed on your system:
- CMake
- Ninja (build system)
- Python (for virtual environment setup)
- LLVM (with
llvm-configavailable in yourPATH)
Follow these steps to build TVM from source:
-
Set up a Python virtual environment:
python3 -m venv .venv source .venv/bin/activate -
Install required Python packages:
pip install cmake ninja setuptools cython
-
Build TVM: Navigate to the
3rdpartydirectory and build TVM:cd 3rdparty ./build-tvm.sh --clean --llvm llvm-config
Once TVM is built, follow these steps to build the example project:
-
Configure the build using CMake:
cmake -B build -G Ninja
-
Build the project using Ninja:
ninja -C build
Before running the example, export the Relax library using the provided Python script:
python export_relax_library.pyAfter building the project, run the example binary:
./build/mainYou'll see the output below:
Found vm_load_executable()
Found vm_initialization()
vm initialized
Found main()
Input array initialized
output:
1
2
3
4
5
6
7
8
9