Forums - QCM2290 issue running TensorFlow Lite using Hexagon DSP

2 posts / 0 new
Last post
QCM2290 issue running TensorFlow Lite using Hexagon DSP
vadim.gerassimov
Join Date: 8 Aug 23
Posts: 2
Posted: Wed, 2023-08-09 00:31

Hello,

 

I'm trying to run an Android app with sample TensorFlow Lite models using Hexagon DSP to evaluate the DSP performance.

 

I have created a gradle 7.5 based project with following tensorflow lite dependencies:

 

implementation 'org.tensorflow:tensorflow-lite:2.13.0'
implementation 'org.tensorflow:tensorflow-lite-hexagon:2.13.0'

 

In jniLibs I have added hexagon_nn_skel_v1.20.0.1 libraries for both architectures (arm64-v8a and armeabi-v7a):

  • libhexagon_nn_skel.so
  • libhexagon_nn_skel_v65.so
  • libhexagon_nn_skel_v66.so

 

 

In the source set I've registered jni libraries:

 

sourceSets {
    main {
        jniLibs.srcDirs = ['src/main/jniLibs']
    }
}

After trying to run the test using HexagonDelegate

 

System.loadLibrary("tensorflowlite_hexagon_jni");
opt.addDelegate(HexagonDelegate(cntx))

 

I receive an error saying

 

java.lang.UnsupportedOperationException: This Device doesn't support Hexagon DSP execution.
                                                                                                    at org.tensorflow.lite.HexagonDelegate.<init>(HexagonDelegate.java:39)
                                                                                                    at com.example.tfex.ImageClassifier.<init>(ImageCs.kt:55)

 

The prior logcat output is following:

2021-09-01 07:09:06.097  7693-7693  om.example.tfe          com.example.tfex                     W  Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2021-09-01 07:09:06.099  7693-7693  om.example.tfe          com.example.tfex                     W  Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2021-09-01 07:09:06.210  7693-7693  BoltImage               com.example.tfex                     I  This is dir: /data/app/~~A9ndLbj_btrXp5IWNgTVQQ==/com.example.tfex-kvd6vsApdtnm8Zyi-hZWoA==/lib/arm64
2021-09-01 07:09:06.249  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/rpcmem_android.c:159: rpcmem_init_internal: opened ION device fd 57, configured heap IDs: system (0x2000000), contig (0x400000), secure (0x200), secure flags (0x80080000)
2021-09-01 07:09:06.250  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:2944: fastrpc_apps_user_init done
2021-09-01 07:09:06.257  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/rpcmem_android.c:159: rpcmem_init_internal: opened ION device fd 60, configured heap IDs: system (0x2000000), contig (0x400000), secure (0x200), secure flags (0x80080000)
2021-09-01 07:09:06.258  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:2944: fastrpc_apps_user_init done
2021-09-01 07:09:06.253  7693-7693  om.example.tfex         com.example.tfex                     W  type=1400 audit(0.0:2909): avc: denied { read } for name="adsprpc-smd-secure" dev="tmpfs" ino=19469 scontext=u:r:untrusted_app:s0:c180,c256,c512,c768 tcontext=u:object_r:vendor_xdsp_device:s0 tclass=chr_file permissive=0 app=com.example.tfex
2021-09-01 07:09:06.260  7693-7693  com.example.tfex        com.example.tfex                     E  vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:2526: Error 0xd: open_shell failed for domain 3 search paths used are /dsp/, /vendor/dsp/, /vendor/dsp/xdsp/ (errno Permission denied)
2021-09-01 07:09:06.261  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/fastrpc_config.c:175: Reading configuration file: com.example.tfex.debugconfig
2021-09-01 07:09:06.253  7693-7693  om.example.tfex         com.example.tfex                     W  type=1400 audit(0.0:2910): avc: denied { search } for name="/" dev="mmcblk0p26" ino=2 scontext=u:r:untrusted_app:s0:c180,c256,c512,c768 tcontext=u:object_r:adsprpcd_file:s0 tclass=dir permissive=0 app=com.example.tfex
2021-09-01 07:09:06.267  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/fastrpc_config.c:64: fastrpc_read_config_file_from_path: Couldn't find file: /data/app/~~A9ndLbj_btrXp5IWNgTVQQ==/com.example.tfex-kvd6vsApdtnm8Zyi-hZWoA==/lib/arm64/com.example.tfex.debugconfig
2021-09-01 07:09:06.267  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/fastrpc_config.c:132: Error 45: failed for /data/app/~~A9ndLbj_btrXp5IWNgTVQQ==/com.example.tfex-kvd6vsApdtnm8Zyi-hZWoA==/lib/arm64/com.example.tfex.debugconfig with errno(No such file or directory)
2021-09-01 07:09:06.268  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/fastrpc_config.c:64: fastrpc_read_config_file_from_path: Couldn't find file: /system/vendor/lib/rfsa/adsp/com.example.tfex.debugconfig
2021-09-01 07:09:06.268  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/fastrpc_config.c:132: Error 45: failed for /system/vendor/lib/rfsa/adsp/com.example.tfex.debugconfig with errno(No such file or directory)
2021-09-01 07:09:06.268  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/fastrpc_config.c:64: fastrpc_read_config_file_from_path: Couldn't find file: /vendor/lib/rfsa/adsp/com.example.tfex.debugconfig
2021-09-01 07:09:06.268  7693-7693  com.example.tfex        com.example.tfex                     I  vendor/qcom/proprietary/adsprpc/src/fastrpc_config.c:132: Error 45: failed for /vendor/lib/rfsa/adsp/com.example.tfex.debugconfig with errno(No such file or directory)
2021-09-01 07:09:06.269  7693-7693  com.example.tfex        com.example.tfex                     E  vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:2740: Error 0xffffffff: apps_dev_init failed for domain 3, errno Transport endpoint is not connected
2021-09-01 07:09:06.253  7693-7693  om.example.tfex         com.example.tfex                     W  type=1400 audit(0.0:2911): avc: denied { search } for name="/" dev="mmcblk0p26" ino=2 scontext=u:r:untrusted_app:s0:c180,c256,c512,c768 tcontext=u:object_r:adsprpcd_file:s0 tclass=dir permissive=0 app=com.example.tfex
2021-09-01 07:09:06.257  7693-7693  om.example.tfex         com.example.tfex                     W  type=1400 audit(0.0:2912): avc: denied { search } for name="/" dev="mmcblk0p26" ino=2 scontext=u:r:untrusted_app:s0:c180,c256,c512,c768 tcontext=u:object_r:adsprpcd_file:s0 tclass=dir permissive=0 app=com.example.tfex
2021-09-01 07:09:06.257  7693-7693  om.example.tfex         com.example.tfex                     W  type=1400 audit(0.0:2913): avc: denied { getattr } for path="/vendor/dsp" dev="mmcblk0p26" ino=2 scontext=u:r:untrusted_app:s0:c180,c256,c512,c768 tcontext=u:object_r:adsprpcd_file:s0 tclass=dir permissive=0 app=com.example.tfex
2021-09-01 07:09:06.269  7693-7693  com.example.tfex        com.example.tfex                     E  vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:2838: Error 0xffffffff: open_dev (-1) failed for domain 3 (errno Transport endpoint is not connected)
2021-09-01 07:09:06.269  7693-7693  com.example.tfex        com.example.tfex                     E  vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:1754: Error 0xffffffff: remote_handle_control_domain failed for request ID 1 on domain 3 (errno Transport endpoint is not connected)
2021-09-01 07:09:06.270  7693-7693  com.example.tfex        com.example.tfex                     E  vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:1765: Error 0xffffffff: remote_handle_control failed for request ID 1 (errno Success)
2021-09-01 07:09:06.271  7693-7693  tflite                  com.example.tfex                     W  Failed to fetch Hexagon NN version. This might be because you're using incompatible versions of libhexagon_interface and libhexagon_nn_skel. You must use compatible versions. Refer to Tensorflow Lite Hexagon Delegate Guide.
2021-09-01 07:09:06.271  7693-7693  tflite                  com.example.tfex                     I  Hexagon Delegate is not supported.

 

TThe main message "Failed to fetch Hexagon NN version. This might be because you're using incompatible versions of libhexagon_interface and libhexagon_nn_skel. You must use compatible versions. Refer to Tensorflow Lite Hexagon Delegate Guide." says that there are some incompatibilites. I removed jni libraries, cleaned and rebuilt, but without jni libraries the message is the same. Thus, I don't know if jni libraries nare not visible or still some versions incompativbility.

I manually uploaded libhexagon_nn_skel* files to /data/local/tmp like here https://github.com/tensorflow/tensorflow/issues/55364 - without the error message remained the same.

I tried recommendations from this post https://developer.qualcomm.com/comment/19316#comment-19316 except setenforce 0 as my dev-board is not rooted and not sure it's a good idea to root it. Cleaned and built again - no success, the error message was exactly the same.

Any ideas to try? Or maybe you have a sample android based app to run TensforFlow lite using Hexagon DSP (either via HexagonDelegate or via some other SDK)?

Thanks in advance.

Vadim Gerassimov

 

 

  • Up0
  • Down0
vadim.gerassimov
Join Date: 8 Aug 23
Posts: 2
Posted: Wed, 2023-08-09 23:48

I explicitely checked the content of the /data/app/~~A9ndLbj_btrXp5IWNgTVQQ==/com.example.tfex-kvd6vsApdtnm8Zyi-hZWoA==/lib/arm64 (output of this.applicationInfo.nativeLibraryDir)

and libraries are present here:

 

-rwxr-xr-x 1 system system   85096 1981-01-01 01:01 libhexagon_interface.so
-rwxr-xr-x 1 system system 1148720 1981-01-01 01:01 libhexagon_nn_skel.so
-rwxr-xr-x 1 system system 1165168 1981-01-01 01:01 libhexagon_nn_skel_v65.so
-rwxr-xr-x 1 system system 1161072 1981-01-01 01:01 libhexagon_nn_skel_v66.so
-rwxr-xr-x 1 system system  534672 1981-01-01 01:01 libtensorflowlite_hexagon_jni.so
-rwxr-xr-x 1 system system 3779304 1981-01-01 01:01 libtensorflowlite_jni.so
 
Listing this:
 
1|bengal:/ $ ls -l /system/vendor/lib/rfsa/adsp/
total 4
-????????? ? ?    ?        ?                ? libadsp_jpege_skel.so
-????????? ? ?    ?        ?                ? libapps_mem_heap.so
-????????? ? ?    ?        ?                ? libbitml_nsp_skel.so
-????????? ? ?    ?        ?                ? libcamera_nn_skel.so
-????????? ? ?    ?        ?                ? libdspCV_skel.so
-????????? ? ?    ?        ?                ? libdsp_streamer_binning.so
-????????? ? ?    ?        ?                ? libfastcvadsp.so
-????????? ? ?    ?        ?                ? libfastcvdsp_skel.so
-????????? ? ?    ?        ?                ? libhexagon_nn_skel.so
-????????? ? ?    ?        ?                ? libmctfengine_skel.so
-????????? ? ?    ?        ?                ? libscveObjectSegmentation_skel.so
-????????? ? ?    ?        ?                ? libscveT2T_skel.so
-????????? ? ?    ?        ?                ? libsns_device_mode_skel.so
-????????? ? ?    ?        ?                ? libsns_low_lat_stream_skel.so
 

 

I see libhexagon_nn_skel.so. Can it be that the system loads libhexagon_nn_skel.so from that location whereas libhexagon_interface.so is taken from the app native library path what causes different versions?

I've tried the same setup with QCM6125 dev-board and everything works there. Running out of ideas why it doesn't work on  the CM2290 dev-board.

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.