This is a very basic microTVM example for Raspberry Pi Pico.
- TVM v0.17
- Ubuntu 24.04
- Python 3.12
Install CMake and cross compiler.
sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi
Clone the repository.
git clone https://github.com/mshr-h/pico-microtvm-standalone
cd pico-microtvm-standalone
Create python virtual env and install python dependencies.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Build and install TVM from source.
cd 3rdparty
./build-tvm.sh
cd ..
Build model with TVM.
python build_module.py -m add.onnx
Extract tar and generate hexdumps.
tar xvf model_c.tar
xxd -i graph_c.json > graph_c.json.c
xxd -i params_c.bin > params_c.bin.c
graph_c.json.c
- Hexdump for computational graph
params_c.bin.c
- Hexdump for the parameter of the graph
lib0.c
- Operator registry
lib1.c
- Compiled operators
Copy the TVM runtime files from 3rdparty/tvm
./copy-tvm-crt.sh
Fix some errors before building the code.
patch -p1 < diff.patch
Configure and build it.
If PICO_SDK_PATH
environment variable isn't set, cmake will automatically download pico-sdk to the build/_dep
directory.
cmake -S . -B build -G Ninja
cmake --build build
Connect the Pico to the Host PC with pressing the BOOTSEL button.
Copy the binary to Raspberry Pi Pico.
cp microtvm.uf2 /path/to/pico_storage
Connect to the Pico with UART. The default baud rate is 115200.
You can see the inference result.