This directory contains the Hexagon backend implementation for MNN. It supports accelerating model inference on Qualcomm Hexagon DSPs.
- Hexagon SDK: Ensure you have downloaded and installed the Qualcomm Hexagon SDK.
- Environment Variable: Set the
HEXAGON_SDK_ROOTenvironment variable pointing to the root of your Hexagon SDK installation.
Before compiling MNN, you need to build the custom Hexagon Tensor Processor (HTP) operator library located in htp-ops-lib/.
cd source/backend/hexagon/htp-ops-lib
# Pass the target DSP architecture version (e.g., v73, v75, v79)
# Ensure your Hexagon SDK environment is properly set up before running this script
bash build.sh v79This script will generate two essential libraries in the htp-ops-lib/outputs/ directory:
libMNN_htpops.so: The Android AArch64 stub library that runs on the CPU.libMNN_htpops_skel.so: The Hexagon DSP skeleton library that runs on the Hexagon NPU/DSP.
When configuring the MNN build, you need to enable the Hexagon backend by passing the -DMNN_HEXAGON=ON flag to CMake. Don't need Hexagon SDK.
cd /path/to/MNN
mkdir build && cd build
cmake .. \
-DMNN_HEXAGON=ON \
# ... other MNN compilation flags (e.g., cross-compiling for Android)
make -j8Note: If you have already exported HEXAGON_SDK_ROOT in your environment, you can omit the -DHEXAGON_SDK_ROOT CMake argument.
To run the compiled MNN with the Hexagon backend on an Android device:
- Push your compiled MNN executable and libraries to the device.
- Push the generated
libMNN_htpops.soandlibMNN_htpops_skel.solibraries to the device. - Configure your
LD_LIBRARY_PATHso the system can findlibMNN_htpops.so. - Configure the
ADSP_LIBRARY_PATHenvironment variable to include the directory containinglibMNN_htpops_skel.soso the DSP can load the skeleton library.
# Example on device:
export ADSP_LIBRARY_PATH="/data/local/tmp/hexagon_libs;/vendor/lib/rfsa/adsp;/system/lib/rfsa/adsp"
export LD_LIBRARY_PATH="/data/local/tmp/hexagon_libs:$LD_LIBRARY_PATH"