nnlib
nnlib copied to clipboard
Fork of https://source.codeaurora.org/quic/hexagon_nn/nnlib
Here's how we are able to build Hexagon NN for MACE.
Note that in order to run code on target, you have to follow the SDK instructions for installing a testsig. Try the "calculator" or other examples in the SDK to make sure you can execute on the DSP.
-
Download and install the Hexagon SDK 3.4.3 (other versions may also work)
-
Source the Hexagon SDK setup_sdk_env.sh script.
-
Build the Hexagon NN dynamic library
Note: For Hexagon SDK 3.4.0 and 3.4.1, please use toolv82 instead of toolv83 in all build instructions below.
For SD820: make tree VERBOSE=1 V=hexagon_Release_dynamic_toolv83_v60 For SD660: make tree VERBOSE=1 V=hexagon_Release_dynamic_toolv83_v60 For SD835: make tree VERBOSE=1 V=hexagon_Release_dynamic_toolv83_v60 For SD845: (best performance): make tree VERBOSE=1 V=hexagon_Release_dynamic_toolv83_v65 V65=1 For SD845: (Don't use V65 code): make tree VERBOSE=1 V=hexagon_Release_dynamic_toolv83_v65 For SD670: (best performance): make tree VERBOSE=1 V=hexagon_Release_dynamic_toolv83_v65 V65=1 For SD670: (Don't use V65 code): make tree VERBOSE=1 V=hexagon_Release_dynamic_toolv83_v65 For SD855: make tree VERBOSE=1 V=hexagon_Release_dynamic_toolv83_v66 V66=1 For SD855: (Don't use V66 code): make tree VERBOSE=1 V=hexagon_Release_dynamic_toolv83_v66
- Build the Hexagon NN controller(for MACE)
For armeabi-v7a: make tree VERBOSE=1 V=android_Release CDSP_FLAG=1 For arm64-v8a: make tree VERBOSE=1 V=android_Release_aarch64 CDSP_FLAG=1
-
adb root ; adb remount
-
cp interface/ops.def /path_to_mace/third_party/nnlib/ops.h cp android_Release/ship/libhexagon_controller.so /path_to_mace/third_party/nnlib/armeabi-v7a/ or cp android_Release_aarch64/ship/libhexagon_controller.so /path_to_mace/third_party/nnlib/arm64-v8a/
-
adb push hexagon_Release_dynamic_toolv83_v6x/ship/libhexagon_nn_skel.so /system/vendor/lib/rfsa/adsp/ (Replace with the actual V= path that gets created from the appropriate option from above)
-
To test it could run successfully, after (3), adb shell mkdir -p /data/local/tmp/hexagon_nn adb push android_Release/ship/controller_test /data/local/tmp/hexagon_nn/ adb shell "LD_LIBRARY_PATH=/data/local/tmp/hexagon_nn /data/local/tmp/hexagon_nn/controller_test"