From 9e8e604de3e09290929f714b49543b8edf7e1d84 Mon Sep 17 00:00:00 2001 From: ZIFENG278 Date: Thu, 12 Feb 2026 11:57:19 +0800 Subject: [PATCH] docs: add qnn tflite delegate demo zh docs Signed-off-by: ZIFENG278 --- docs/common/ai/_fastrpc_setup.mdx | 138 +++++++++++++++++- .../common/ai/_qairt_tflite_delegate_demo.mdx | 66 +++++++++ .../app-dev/npu-dev/tflite-delegate-demo.md | 9 ++ .../ai-dev/tflite-delegate-demo.md | 9 ++ 4 files changed, 215 insertions(+), 7 deletions(-) create mode 100644 docs/common/ai/_qairt_tflite_delegate_demo.mdx create mode 100644 docs/dragon/q6a/app-dev/npu-dev/tflite-delegate-demo.md create mode 100644 docs/fogwise/airbox-q900/ai-dev/tflite-delegate-demo.md diff --git a/docs/common/ai/_fastrpc_setup.mdx b/docs/common/ai/_fastrpc_setup.mdx index ad254ad57..e7c576ff2 100644 --- a/docs/common/ai/_fastrpc_setup.mdx +++ b/docs/common/ai/_fastrpc_setup.mdx @@ -19,7 +19,7 @@ NPU 环境配置清单 ```bash sudo apt update - sudo apt install fastrpc fastrpc-dev libcdsprpc1 radxa-firmware-qcs6490 + sudo apt install fastrpc libcdsprpc1 ``` @@ -33,7 +33,7 @@ NPU 环境配置清单 ```bash sudo apt update - sudo apt install fastrpc fastrpc-dev libcdsprpc1 radxa-firmware-qcs9075 + sudo apt install fastrpc libcdsprpc1 ``` @@ -43,7 +43,38 @@ NPU 环境配置清单 -对用户增加 fastrpc 设备权限 +{/* 对用户增加 fastrpc 设备权限 */} + +{/* */} +{/* */} + +{/* */} + +{/* ```bash */} +{/* sudo chmod 666 /dev/fastrpc-* */} +{/* sudo chmod 666 /dev/dma_heap/system */} +{/* ``` */} + +{/* */} + +{/* */} + +{/* */} + +{/* */} + +{/* ```bash */} +{/* sudo chmod 660 /dev/fastrpc-* */} +{/* sudo chmod 660 /dev/dma_heap/system */} +{/* ``` */} + +{/* */} + +{/* */} + +{/* */} + +验证 fastrpc 状态 @@ -51,12 +82,58 @@ NPU 环境配置清单 ```bash - sudo chmod 666 /dev/fastrpc-* - sudo chmod 666 /dev/dma_heap/system + sudo apt install fastrpc-test + fastrpc_test -a v68 ``` + ```bash + rock@radxa-dragon-q6a:~$ fastrpc_test -a v68 + + Demonstrating FARF run-time logging + + hap_example function PASSED + Please look at the mini-dm logs or the adb logcat logs for DSP output + + Demonstrating HAP_mem.h APIs + + hap_example function PASSED + Please look at the mini-dm logs or the adb logcat logs for DSP output + + Demonstrating HAP_perf.h APIs + + hap_example function PASSED + Please look at the mini-dm logs or the adb logcat logs for DSP output + [PASS] libhap_example.so + + Test PASSED + Please look at the mini-dm logs or the adb logcat logs for DSP output + [PASS] libmultithreading.so + + + Allocate 4000 bytes from ION heap + Creating sequence of numbers from 0 to 999 + Compute sum on domain 3 + + Call calculator_sum on the DSP + Sum = 499500 + + Call calculator_max on the DSP + Max value = 999 + [PASS] libcalculator.so + + + ======================================== + Test Summary: + Total tests run: 3 + Passed: 3 + Failed: 0 + Skipped: 0 + ======================================== + + RESULT: All applicable tests PASSED + ``` @@ -65,12 +142,59 @@ NPU 环境配置清单 ```bash - sudo chmod 660 /dev/fastrpc-* - sudo chmod 660 /dev/dma_heap/system + sudo apt install fastrpc-test + fastrpc_test -a v75 ``` + ```bash + rock@radxa-airbox-q900:~$ fastrpc_test -a v75 + + Allocate 4000 bytes from ION heap + Creating sequence of numbers from 0 to 999 + Compute sum on domain 3 + + Call calculator_sum on the DSP + Sum = 499500 + + Call calculator_max on the DSP + Max value = 999 + [PASS] libcalculator.so + + Test PASSED + Please look at the mini-dm logs or the adb logcat logs for DSP output + [PASS] libmultithreading.so + + + Demonstrating FARF run-time logging + + hap_example function PASSED + Please look at the mini-dm logs or the adb logcat logs for DSP output + + Demonstrating HAP_mem.h APIs + + hap_example function PASSED + Please look at the mini-dm logs or the adb logcat logs for DSP output + + Demonstrating HAP_perf.h APIs + + hap_example function PASSED + Please look at the mini-dm logs or the adb logcat logs for DSP output + [PASS] libhap_example.so + + + ======================================== + Test Summary: + Total tests run: 3 + Passed: 3 + Failed: 0 + Skipped: 0 + ======================================== + + RESULT: All applicable tests PASSED + ``` + diff --git a/docs/common/ai/_qairt_tflite_delegate_demo.mdx b/docs/common/ai/_qairt_tflite_delegate_demo.mdx new file mode 100644 index 000000000..2518da4dd --- /dev/null +++ b/docs/common/ai/_qairt_tflite_delegate_demo.mdx @@ -0,0 +1,66 @@ +本文档提供一个开箱即用的 [Inception_v3](https://aihub.qualcomm.com/models/inception_v3) 目标识别模型的 TFLite Delegate 推理示例, +此示例是在瑞莎 Dragon Ubuntu 系统下通过 [TFLite Delegate](https://ai.google.dev/edge/litert/performance/delegates) 使用 Qualcomm® Hexagon™ Processor (NPU) 进行硬件加速推理。 + +:::tip +此文档可用于验证 TFLite delegate, fastrpc 与 NPU 的状态与可用性。 + +进行 TFLite Delegate 验证 前请参考 [**板端启用 NPU**](./fastrpc-setup) 使能 NPU +::: + +## 下载示例 + + + +```bash +pip3 install modelscope +modelscope download --model radxa/Inception_v3_qairt_tflite_delegate --local ./Inception_v3_qairt_tflite_delegate +``` + + + +## 运行示例 + + + +```bash +cd Inception_v3_qairt_tflite_delegate +chmod +x qtld-net-run +export LD_LIBRARY_PATH=$(pwd)/libs:$LD_LIBRARY_PATH +export ADSP_LIBRARY_PATH=$(pwd)/libs +./qtld-net-run --model inception_v3_quant.tflite --input input_list.txt --output outputs --backend htp +``` + + + +## 验证示例 + +可以使用 python 脚本进行结果验证 + + + +```bash +cd scripts +python3 show_inceptionv3_classifications.py --input_list ../input_list.txt -o ../outputs --labels_file ../data/imagenet_slim_labels.txt +``` + + + +```bash +(.venv) rock@radxa-dragon-q6a:~/Inception_v3_qairt_tflite_delegate/scripts$ python3 show_inceptionv3_classifications.py --input_list ../input_list.txt -o ../outputs --labels_file ../data/imagenet_slim_labels.txt +Classification results +data/cropped/ILSVRC2012_val_00003441.raw 0.875000 403 acoustic guitar +data/cropped/ILSVRC2012_val_00008465.raw 0.992188 928 trifle +data/cropped/ILSVRC2012_val_00010218.raw 0.515625 282 tabby +data/cropped/ILSVRC2012_val_00044076.raw 0.941406 377 proboscis monkey +``` + +通过结果打印与测试图片类容对比,可以确认 inception_v3 通过 TFLite delegate 使用 Qualcomm® NPU 推理输出的结果正确。 + +
+ + inceptionv3 input images +
+ +## 参考文档 + +- [**Tutorial - Preparing and Executing a Model with TFLite Delegate**](https://docs.qualcomm.com/doc/80-63442-10/topic/tutorial_preparing_and_executing.html) diff --git a/docs/dragon/q6a/app-dev/npu-dev/tflite-delegate-demo.md b/docs/dragon/q6a/app-dev/npu-dev/tflite-delegate-demo.md new file mode 100644 index 000000000..6c5188925 --- /dev/null +++ b/docs/dragon/q6a/app-dev/npu-dev/tflite-delegate-demo.md @@ -0,0 +1,9 @@ +--- +sidebar_position: 12 +--- + +# TFLite Delegate 验证 + +import QAIRTTFLITEDELEGATEDEMO from '../../../../common/ai/\_qairt_tflite_delegate_demo.mdx'; + + diff --git a/docs/fogwise/airbox-q900/ai-dev/tflite-delegate-demo.md b/docs/fogwise/airbox-q900/ai-dev/tflite-delegate-demo.md new file mode 100644 index 000000000..f80c9f7fc --- /dev/null +++ b/docs/fogwise/airbox-q900/ai-dev/tflite-delegate-demo.md @@ -0,0 +1,9 @@ +--- +sidebar_position: 12 +--- + +# TFLite Delegate 验证 + +import QAIRTTFLITEDELEGATEDEMO from '../../../common/ai/\_qairt_tflite_delegate_demo.mdx'; + +