Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 131 additions & 7 deletions docs/common/ai/_fastrpc_setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NPU 环境配置清单

```bash
sudo apt update
sudo apt install fastrpc fastrpc-dev libcdsprpc1 radxa-firmware-qcs6490
sudo apt install fastrpc libcdsprpc1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR removes the firmware packages (radxa-firmware-qcs6490 and radxa-firmware-qcs9075) from the installation commands. Are these packages no longer required for NPU functionality? If they're still needed, they should be kept in the installation instructions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer required, preinstalled !

```

</NewCodeBlock>
Expand All @@ -33,7 +33,7 @@ NPU 环境配置清单

```bash
sudo apt update
sudo apt install fastrpc fastrpc-dev libcdsprpc1 radxa-firmware-qcs9075
sudo apt install fastrpc libcdsprpc1
```

</NewCodeBlock>
Expand All @@ -43,20 +43,97 @@ NPU 环境配置清单

</Tabs>

对用户增加 fastrpc 设备权限
{/* 对用户增加 fastrpc 设备权限 */}

{/* <Tabs queryString="platform"> */}
{/* <TabItem value="QCS6490" default={props.tag === "qcs6490"} attributes={{className: props.tag === "qcs9075" && "tab_none"}}> */}

{/* <NewCodeBlock tip="Device" type="device"> */}

{/* ```bash */}
{/* sudo chmod 666 /dev/fastrpc-* */}
{/* sudo chmod 666 /dev/dma_heap/system */}
{/* ``` */}

{/* </NewCodeBlock> */}

{/* </TabItem> */}

{/* <TabItem value="QCS9075" default={props.tag === "qcs9075"} attributes={{className: props.tag === "qcs6490" && "tab_none"}}> */}

{/* <NewCodeBlock tip="Device" type="device"> */}

{/* ```bash */}
{/* sudo chmod 660 /dev/fastrpc-* */}
{/* sudo chmod 660 /dev/dma_heap/system */}
{/* ``` */}

{/* </NewCodeBlock> */}

{/* </TabItem> */}

{/* </Tabs> */}
Comment on lines +46 to +75
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section about setting device permissions has been commented out. Without these permissions, users may encounter access issues when trying to use the NPU. If these permissions are no longer needed, please explain why. Otherwise, consider keeping this section or providing alternative instructions for proper device access.


验证 fastrpc 状态

<Tabs queryString="platform">
<TabItem value="QCS6490" default={props.tag === "qcs6490"} attributes={{className: props.tag === "qcs9075" && "tab_none"}}>

<NewCodeBlock tip="Device" type="device">

```bash
sudo chmod 666 /dev/fastrpc-*
sudo chmod 666 /dev/dma_heap/system
sudo apt install fastrpc-test
fastrpc_test -a v68
```

</NewCodeBlock>

```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
```

</TabItem>

Expand All @@ -65,12 +142,59 @@ NPU 环境配置清单
<NewCodeBlock tip="Device" type="device">

```bash
sudo chmod 660 /dev/fastrpc-*
sudo chmod 660 /dev/dma_heap/system
sudo apt install fastrpc-test
fastrpc_test -a v75
```

</NewCodeBlock>

```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
```

</TabItem>

</Tabs>
66 changes: 66 additions & 0 deletions docs/common/ai/_qairt_tflite_delegate_demo.mdx
Original file line number Diff line number Diff line change
@@ -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
:::

## 下载示例

<NewCodeBlock tip="Device" type="device">

```bash
pip3 install modelscope
modelscope download --model radxa/Inception_v3_qairt_tflite_delegate --local ./Inception_v3_qairt_tflite_delegate
```

</NewCodeBlock>

## 运行示例

<NewCodeBlock tip="Device" type="device">

```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
```

</NewCodeBlock>

## 验证示例

可以使用 python 脚本进行结果验证

<NewCodeBlock tip="Device" type="device">

```bash
cd scripts
python3 show_inceptionv3_classifications.py --input_list ../input_list.txt -o ../outputs --labels_file ../data/imagenet_slim_labels.txt
```

</NewCodeBlock>

```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 推理输出的结果正确。

<div style={{ textAlign: "center" }}>
<img src="/img/dragon/q6a/qairt_resnet50.webp" style={{ width: "60%" }} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image filename referenced in line 60 is qairt_resnet50.webp but the document is about Inception_v3. Consider renaming the image file to match the model being demonstrated or ensure the image actually shows Inception_v3 results.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same images input

inceptionv3 input images
</div>

## 参考文档

- [**Tutorial - Preparing and Executing a Model with TFLite Delegate**](https://docs.qualcomm.com/doc/80-63442-10/topic/tutorial_preparing_and_executing.html)
9 changes: 9 additions & 0 deletions docs/dragon/q6a/app-dev/npu-dev/tflite-delegate-demo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
sidebar_position: 12
---

# TFLite Delegate 验证

import QAIRTTFLITEDELEGATEDEMO from '../../../../common/ai/\_qairt_tflite_delegate_demo.mdx';

<QAIRTTFLITEDELEGATEDEMO />
9 changes: 9 additions & 0 deletions docs/fogwise/airbox-q900/ai-dev/tflite-delegate-demo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
sidebar_position: 12
---

# TFLite Delegate 验证

import QAIRTTFLITEDELEGATEDEMO from '../../../common/ai/\_qairt_tflite_delegate_demo.mdx';

<QAIRTTFLITEDELEGATEDEMO />