Alta features a 5TOPs INT8 Verisilicon NPU for running tensor and convolution computation for AI based workloads. Tomeu has developed TensorFlow Lite delegate for Mesa to make use of the existing piping for Verisilicon’s Etnaviv IP. The long term goal is to create a NN API HAL frontend that is targeted by TensorFlow Lite and PyTorch Mobile with Gallium as the backend to create dmabufs and command streams for the physical hardware. If you are interested in this work, there is a community at #ml-mainline on OFTC.
Please update your board to the latest firmware. You can setup an NFS environment on Debian with LOON or use our Debian 12 image.
Enable the NPU with the wiring tool:
sudo apt install -y git
git clone https://github.com/libre-computer-project/libretech-wiring-tool.git
cd libretech-wiring-tool
make
sudo ./ldto enable npu
cd ..
Enable APT sources
sed "s/^deb\s/deb-src /" /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/src.list
sudo apt update
Install Mesa Build Dependencies
sudo eatmydata apt-get -y build-dep mesa
sudo eatmydata apt -y install meson glslang-tools glslang-dev python3-mako zlib1g-dev flatbuffers-compiler python3-pytest python3-exceptiongroup python3-pip python3-pil python3-pycparser
Get Meson > 1.1.0 from Debian
wget FILE_URL
#replace FILE_URL with direct link to the deb from the link above
sudo dpkg -i FILE
#replace FILE with filename
Build Teflon
git clone https://gitlab.freedesktop.org/tomeu/mesa.git -b 25.0.3-rendernode-check --single-branch --depth=1
cd mesa
meson setup build -Dgallium-drivers=etnaviv -Dvulkan-drivers= -Dteflon=true
meson compile -C build
Install TensorFlow Lite
pip3 install --break-system-packages tflite-runtime
Revert to numpy 1.x
pip3 install --break-system-packages "numpy<2.0"
Download MobileNetV1 Quantized
wget https://github.com/nnsuite/testcases/raw/refs/heads/master/DeepLearningModels/tensorflow-lite/Mobilenet_v1_1.0_224_quant/mobilenet_v1_1.0_224_quant.tflite
Create BMP image from URL
wget IMAGE_URL
#replace IMAGE_URL with direct link to any image URL
convert IMAGE_FILE IMAGE_FILE_BMP
#replace IMAGE_FILE with the image file name and replace #IMAGE_FILE_BMP with the output path for the converted bitmap image
Run MobileNetV1
python3 src/gallium/frontends/teflon/tests/classification.py -i IMAGE_FILE_BMP -m src/gallium/targets/teflon/tests/mobilenet_v1_1.0_224_quant.tflite -l src/gallium/frontends/teflon/tests/labels_mobilenet_quant_v1_224.txt -e build/src/gallium/targets/teflon/libteflon.so
#replace IMAGE_FILE_BMP with the bitmap image
Loading external delegate from build/src/gallium/targets/teflon/libteflon.so with args: {}
0.196078: fur coat
0.117647: briard
0.101961: trailer truck
0.086275: streetcar
0.043137: school bus
time: 6.829ms
Debugging Environment Variables for the Teflon Delegate
TEFLON_DEBUG=verbose
ETNA_MESA_DEBUG=ml_msg,npu_no_batching
To learn more about AI/neuro computing and how it is applied, here is a list of reading material.