Skip to content

Commit 663a438

Browse files
authored
[Doc] Update demo doc for NNAdapter devices (#9685)
1 parent f969de8 commit 663a438

13 files changed

+578
-516
lines changed

docs/demo_guides/android_nnapi.md

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,31 @@ Paddle Lite 已支持 Android NNAPI 的预测部署。
7272

7373
### 运行图像分类示例程序
7474

75-
- 下载 Paddle Lite 通用示例程序[ PaddleLite-generic-demo.tar.gz ](https://paddlelite-demo.bj.bcebos.com/devices/generic/PaddleLite-generic-demo.tar.gz),解压后目录主体结构如下:
75+
- 下载 Paddle Lite 通用示例程序[ PaddleLite-generic-demo.tar.gz ](http://paddlelite-demo.bj.bcebos.com/devices/generic/PaddleLite-generic-demo_v2_12_0.tar.gz),解压后目录主体结构如下:
7676

7777
```shell
7878
- PaddleLite-generic-demo
7979
- image_classification_demo
8080
- assets
81-
- images
82-
- tabby_cat.jpg # 测试图片
83-
- tabby_cat.raw # 经过 convert_to_raw_image.py 处理后的 RGB Raw 图像
84-
- labels
81+
- configs
82+
- imagenet_224.txt # config 文件
8583
- synset_words.txt # 1000 分类 label 文件
84+
- datasets
85+
- test # dataset
86+
- inputs
87+
- tabby_cat.jpg # 输入图片
88+
- outputs
89+
- tabby_cat.jpg # 输出图片
90+
- list.txt # 图片清单
8691
- shell
8792
- CMakeLists.txt # 示例程序 CMake 脚本
8893
- build.android.arm64-v8a # arm64-v8a 编译工作目录
89-
- image_classification_demo # 已编译好的,适用于 amd64-v8a 的示例程序
94+
- demo # 已编译好的,适用于 amd64-v8a 的示例程序
9095
- build.android.armeabi-v7a # armeabi-v7a 编译工作目录
91-
- image_classification_demo # 已编译好的,适用于 arm64 的示例程序
96+
- demo # 已编译好的,适用于 arm64 的示例程序
9297
...
9398
...
94-
- image_classification_demo.cc # 示例程序源码
99+
- demo.cc # 示例程序源码
95100
- build.sh # 示例程序编译脚本
96101
- run_with_adb.sh # 示例程序 adb 运行脚本
97102
— run_with_ssh.sh # 示例程序 ssh 运行脚本
@@ -107,7 +112,6 @@ Paddle Lite 已支持 Android NNAPI 的预测部署。
107112
- libandroid_nnapi.so # NNAdapter device HAL 库
108113
- libpaddle_full_api_shared.so # 预编译 Paddle Lite full api 库
109114
- libpaddle_light_api_shared.so # 预编译 Paddle Lite light api 库
110-
- libc++_shared.so
111115
...
112116
- OpenCV # OpenCV 预编译库
113117
```
@@ -125,43 +129,33 @@ Paddle Lite 已支持 Android NNAPI 的预测部署。
125129
6)下述命令行示例中涉及的设备序列号等均为示例环境,请用户根据自身实际设备环境修改。
126130
在 ARM CPU 上运行 mobilenetv1 全量化模型
127131
$ cd PaddleLite-generic-demo/image_classification_demo/shell
128-
$ ./run_with_adb.sh mobilenet_v1_int8_224_per_layer android armeabi-v7a cpu d3869b25
129-
...
130-
iter 0 cost: 102.673004 ms
131-
iter 1 cost: 102.539001 ms
132-
iter 2 cost: 102.505005 ms
133-
iter 3 cost: 102.626007 ms
134-
iter 4 cost: 102.735992 ms
135-
warmup: 1 repeat: 5, average: 102.615802 ms, max: 102.735992 ms, min: 102.505005 ms
136-
results: 3
137-
Top0 Egyptian cat - 0.512545
138-
Top1 tabby, tabby cat - 0.402567
139-
Top2 tiger cat - 0.067904
140-
Preprocess time: 2.070000 ms
141-
Prediction time: 102.615802 ms
142-
Postprocess time: 0.280000 ms
132+
$ ./run_with_adb.sh mobilenet_v1_int8_224_per_layer imagenet_224.txt test android armeabi-v7a cpu d3869b25
133+
134+
Top1 Egyptian cat - 0.502124
135+
Top2 tabby, tabby cat - 0.413927
136+
Top3 tiger cat - 0.071703
137+
Top4 lynx, catamount - 0.008436
138+
Top5 cougar, puma, catamount, mountain lion, painter, panther, Felis concolor - 0.000563
139+
Preprocess time: 4.948000 ms, avg 4.948000 ms, max 4.948000 ms, min 4.948000 ms
140+
Prediction time: 34.962000 ms, avg 34.962000 ms, max 34.962000 ms, min 34.962000 ms
141+
Postprocess time: 4.715000 ms, avg 4.715000 ms, max 4.715000 ms, min 4.715000 ms
143142

144143
基于 Android NNAPI 上运行 mobilenetv1 全量化模型
145144
$ cd PaddleLite-generic-demo/image_classification_demo/shell
146-
$ ./run_with_adb.sh mobilenet_v1_int8_224_per_layer android armeabi-v7a android_nnapi d3869b25
147-
...
148-
iter 0 cost: 10.193001 ms
149-
iter 1 cost: 10.142000 ms
150-
iter 2 cost: 11.538000 ms
151-
iter 3 cost: 9.292000 ms
152-
iter 4 cost: 10.304001 ms
153-
warmup: 1 repeat: 5, average: 10.293800 ms, max: 14.538000 ms, min: 9.292000 ms
154-
results: 3
155-
Top0 Egyptian cat - 0.672723
156-
Top1 tabby, tabby cat - 0.672723
157-
Top2 tiger cat - 0.128695
158-
Preprocess time: 2.098000 ms
159-
Prediction time: 10.293800 ms
160-
Postprocess time: 0.260000 ms
145+
$ ./run_with_adb.sh mobilenet_v1_int8_224_per_layer imagenet_224.txt test android armeabi-v7a android_nnapi d3869b25
146+
147+
Top1 Egyptian cat - 0.497230
148+
Top2 tabby, tabby cat - 0.403634
149+
Top3 tiger cat - 0.076047
150+
Top4 lynx, catamount - 0.005850
151+
Top5 great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias - 0.000000
152+
Preprocess time: 5.271000 ms, avg 5.271000 ms, max 5.271000 ms, min 5.271000 ms
153+
Prediction time: 6.877000 ms, avg 6.877000 ms, max 6.877000 ms, min 6.877000 ms
154+
Postprocess time: 5.083000 ms, avg 5.083000 ms, max 5.083000 ms, min 5.083000 ms
161155
```
162156

163-
- 如果需要更改测试图片,可将图片拷贝到 `PaddleLite-generic-demo/image_classification_demo/assets/images` 目录下,然后调用 `convert_to_raw_image.py` 生成相应的 RGB Raw 图像,最后修改 `run_with_adb.sh` 的 IMAGE_NAME 变量即可
164-
- 重新编译示例程序:
157+
- 如果需要更改测试图片,可将图片拷贝到 `PaddleLite-generic-demo/image_classification_demo/assets/datasets/test/inputs` 目录下,同时将图片文件名添加到 `PaddleLite-generic-demo/image_classification_demo/assets/datasets/test/list.txt`
158+
- 重新编译示例程序:
165159
```shell
166160
注意:
167161
1)请根据 `buid.sh` 配置正确的参数值。

docs/demo_guides/cambricon_mlu.md

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,22 @@ $ cnmon
128128

129129
### 运行图像分类示例程序
130130

131-
- 下载示例程序[ PaddleLite-generic-demo.tar.gz ](https://paddlelite-demo.bj.bcebos.com/devices/generic/PaddleLite-generic-demo.tar.gz),解压后清单如下:
131+
- 下载示例程序[ PaddleLite-generic-demo.tar.gz ](http://paddlelite-demo.bj.bcebos.com/devices/generic/PaddleLite-generic-demo_v2_12_0.tar.gz),解压后清单如下:
132132

133133
```shell
134134
- PaddleLite-generic-demo
135135
- image_classification_demo
136136
- assets
137-
- images
138-
- tabby_cat.jpg # 测试图片
139-
- tabby_cat.raw # 经过 convert_to_raw_image.py 处理后的 RGB Raw 图像
140-
- labels
137+
- configs
138+
- imagenet_224.txt # config 文件
141139
- synset_words.txt # 1000 分类 label 文件
140+
- datasets
141+
- test # dataset
142+
- inputs
143+
- tabby_cat.jpg # 输入图片
144+
- outputs
145+
- tabby_cat.jpg # 输出图片
146+
- list.txt # 图片清单
142147
- models
143148
- resnet50_fp32_224 # Paddle non-combined 格式的 resnet50 float32 模型
144149
- __model__ # Paddle fluid 模型组网文件,可拖入 https://lutzroeder.github.io/netron/ 进行可视化显示网络结构
@@ -148,10 +153,10 @@ $ cnmon
148153
- shell
149154
- CMakeLists.txt # 示例程序 CMake 脚本
150155
- build.linux.amd64 # 已编译好的,适用于 amd64
151-
- image_classification_demo # 已编译好的,适用于 amd64 的示例程序
156+
- demo # 已编译好的,适用于 amd64 的示例程序
152157
...
153158
...
154-
- image_classification_demo.cc # 示例程序源码
159+
- demo.cc # 示例程序源码
155160
- build.sh # 示例程序编译脚本
156161
- run.sh # 示例程序本地运行脚本
157162
- run_with_ssh.sh # 示例程序 ssh 运行脚本
@@ -165,12 +170,13 @@ $ cnmon
165170
- amd64
166171
- include # Paddle Lite 头文件
167172
- lib # Paddle Lite 库文件
173+
- cpu
174+
- libiomp5.so # Intel OpenMP 库
175+
- libmklml_intel.so # Intel MKL 库
176+
- libmklml_gnu.so # GNU MKL 库
168177
- cambricon_mlu # 寒武纪MLU neuware 库、NNAdapter 运行时库、device HAL 库
169178
- libnnadapter.so # NNAdapter 运行时库
170179
- libcambricon_mlu.so # NNAdapter device HAL 库
171-
- libiomp5.so # Intel OpenMP 库
172-
- libmklml_intel.so # Intel MKL 库
173-
- libmklml_gnu.so # GNU MKL 库
174180
- libpaddle_full_api_shared.so # 预编译 Paddle Lite full api 库
175181
- libpaddle_light_api_shared.so # 预编译 Paddle Lite light api 库
176182
- arm64
@@ -179,11 +185,9 @@ $ cnmon
179185
- armhf
180186
...
181187
- OpenCV # OpenCV 预编译库
182-
- ssd_detection_demo # 基于 ssd 的目标检测示例程序
188+
- object_detection_demo # 目标检测示例程序
183189
```
184190

185-
186-
187191
- 进入 `PaddleLite-generic-demo/image_classification_demo/shell/`
188192

189193
- 执行以下命令比较 resnet50_fp32_224 模型的性能和结果;
@@ -193,35 +197,37 @@ $ cnmon
193197

194198
For amd64
195199
(intel x86 cpu only)
196-
$ ./run.sh resnet50_fp32_224 linux amd64
197-
warmup: 1 repeat: 1, average: 44.949001 ms, max: 44.949001 ms, min: 44.949001 ms
198-
results: 3
199-
Top0 tabby, tabby cat - 0.529132
200-
Top1 Egyptian cat - 0.419680
201-
Top2 tiger cat - 0.045172
202-
Preprocess time: 1.017000 ms
203-
Prediction time: 44.949001 ms
204-
Postprocess time: 0.171000 ms
200+
$ ./run.sh resnet50_fp32_224 imagenet_224.txt test linux amd64
201+
202+
Top1 tabby, tabby cat - 0.705223
203+
Top2 tiger cat - 0.134570
204+
Top3 Egyptian cat - 0.121521
205+
Top4 lynx, catamount - 0.028652
206+
Top5 ping-pong ball - 0.001043
207+
Preprocess time: 3.711000 ms, avg 3.711000 ms, max 3.711000 ms, min 3.711000 ms
208+
Prediction time: 174.218000 ms, avg 174.218000 ms, max 174.218000 ms, min 174.218000 ms
209+
Postprocess time: 4.920000 ms, avg 4.920000 ms, max 4.920000 ms, min 4.920000 ms
210+
205211
(intel x86 cpu + cambricon mlu)
206-
$ ./run.sh resnet50_fp32_224 linux amd64 cambricon_mlu
207-
warmup: 1 repeat: 1, average: 2.079000 ms, max: 2.079000 ms, min: 2.079000 ms
208-
results: 3
209-
Top0 tabby, tabby cat - 0.529785
210-
Top1 Egyptian cat - 0.418945
211-
Top2 tiger cat - 0.045227
212-
Preprocess time: 1.132000 ms
213-
Prediction time: 2.079000 ms
214-
Postprocess time: 0.251000 ms
212+
$ ./run.sh resnet50_fp32_224 imagenet_224.txt test linux amd64 cambricon_mlu
213+
214+
Top1 tabby, tabby cat - 0.705225
215+
Top2 tiger cat - 0.134570
216+
Top3 Egyptian cat - 0.121520
217+
Top4 lynx, catamount - 0.028652
218+
Top5 ping-pong ball - 0.001043
219+
Preprocess time: 4.269000 ms, avg 4.269000 ms, max 4.269000 ms, min 4.269000 ms
220+
Prediction time: 6.133000 ms, avg 6.133000 ms, max 6.133000 ms, min 6.133000 ms
221+
Postprocess time: 5.005000 ms, avg 5.005000 ms, max 5.005000 ms, min 5.005000 ms
215222

216223
- 如果需要更改测试模型,可以将 `run.sh` 里的 MODEL_NAME 改成比如 mobilenet_v1_fp32_224,或执行命令:
217224

218225
```shell
219226
(intel x86 cpu + cambricon mlu)
220-
$ ./run.sh mobilenet_v1_fp32_224 linux amd64 cambricon_mlu
227+
$ ./run.sh mobilenet_v1_fp32_224 imagenet_224.txt test linux amd64 cambricon_mlu
221228
```
222229

223-
- 如果需要更改测试图片,请将图片拷贝到 **`PaddleLite-generic-demo/image_classification_demo/assets/images`** 目录下,修改并执行 **`convert_to_raw_image.py`** 生成相应的 RGB Raw 图像,最后修改 `run.sh` 的 IMAGE_NAME 即可;
224-
230+
- 如果需要更改测试图片,可将图片拷贝到 `PaddleLite-generic-demo/image_classification_demo/assets/datasets/test/inputs` 目录下,同时将图片文件名添加到 `PaddleLite-generic-demo/image_classification_demo/assets/datasets/test/list.txt` 中;
225231
- 如果需要重新编译示例程序,直接运行
226232

227233
```shell

docs/demo_guides/eeasytech_npu.md

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,22 @@ Paddle Lite 已支持 亿智 NPU (eeasytech NPU) 的预测部署。
6464

6565
### 运行图像分类示例程序
6666

67-
- 下载 Paddle Lite 通用示例程序[ PaddleLite-generic-demo.tar.gz ](https://paddlelite-demo.bj.bcebos.com/devices/generic/PaddleLite-generic-demo.tar.gz),解压后目录主体结构如下:
67+
- 下载 Paddle Lite 通用示例程序[ PaddleLite-generic-demo.tar.gz ](http://paddlelite-demo.bj.bcebos.com/devices/generic/PaddleLite-generic-demo_v2_12_0.tar.gz),解压后目录主体结构如下:
6868

6969
```shell
7070
- PaddleLite-generic-demo
7171
- image_classification_demo
7272
- assets
73-
- images
74-
- tabby_cat.jpg # 测试图片
75-
- tabby_cat.raw # 经过 convert_to_raw_image.py 处理后的 RGB Raw 图像
76-
- labels
73+
- configs
74+
- imagenet_224.txt # config 文件
7775
- synset_words.txt # 1000 分类 label 文件
76+
- datasets
77+
- test # dataset
78+
- inputs
79+
- tabby_cat.jpg # 输入图片
80+
- outputs
81+
- tabby_cat.jpg # 输出图片
82+
- list.txt # 图片清单
7883
- models
7984
- mobilenet_v1_int8_per_layer_log2
8085
- __model__ # Paddle fluid 模型组网文件,可使用 netron 查看网络结构
@@ -85,11 +90,11 @@ Paddle Lite 已支持 亿智 NPU (eeasytech NPU) 的预测部署。
8590
- shell
8691
- CMakeLists.txt # 示例程序 CMake 脚本
8792
- build.linux.arm64 # arm64 编译工作目录
88-
- image_classification_demo # 已编译好的,适用于 arm64 的示例程序
93+
- demo # 已编译好的,适用于 arm64 的示例程序
8994
- build.linux.armhf # armhf编译工作目录
90-
- image_classification_demo # 已编译好的,适用于 armhf 的示例程序
95+
- demo # 已编译好的,适用于 armhf 的示例程序
9196
...
92-
- image_classification_demo.cc # 示例程序源码
97+
- demo.cc # 示例程序源码
9398
- build.sh # 示例程序编译脚本
9499
- run.sh # 示例程序本地运行脚本
95100
- run_with_ssh.sh # 示例程序ssh运行脚本
@@ -113,7 +118,7 @@ Paddle Lite 已支持 亿智 NPU (eeasytech NPU) 的预测部署。
113118
...
114119
- android
115120
- OpenCV # OpenCV 预编译库
116-
- ssd_detection_demo # 基于 ssd 的目标检测示例程序
121+
- object_detection_demo # 目标检测示例程序
117122
```
118123

119124
- 按照以下命令分别运行转换后的 ARM CPU 模型和 亿智 NPU 模型,比较它们的性能和结果;
@@ -131,36 +136,36 @@ Paddle Lite 已支持 亿智 NPU (eeasytech NPU) 的预测部署。
131136
$ cd PaddleLite-generic-demo/image_classification_demo/shell
132137

133138
For SH506 CPU
134-
$ ./run_with_adb.sh mobilenet_v1_int8_per_layer_log2 linux armhf cpu adb设备号
139+
$ ./run_with_adb.sh mobilenet_v1_int8_per_layer_log2 imagenet_224.txt test linux armhf cpu adb设备号
135140
(RK1808 EVB)
136-
warmup: 1 repeat: 5, average: 517.333008 ms, max: 519.331000 ms, min: 516.848999 ms
137-
results: 3
138-
Top0 tabby, tabby cat - 0.638649
139-
Top1 Egyptian cat - 0.289704
140-
Top2 tiger cat - 0.051178
141-
Preprocess time: 6.928000 ms
142-
Prediction time: 517.333008 ms
143-
Postprocess time: 0.538000 ms
141+
Top1 tabby, tabby cat - 0.751034
142+
Top2 Egyptian cat - 0.183955
143+
Top3 tiger cat - 0.045455
144+
Top4 lynx, catamount - 0.003305
145+
Top5 ping-pong ball - 0.002057
146+
Preprocess time: 59.751000 ms, avg 59.751000 ms, max 59.751000 ms, min 59.751000 ms
147+
Prediction time: 679.279000 ms, avg 679.279000 ms, max 679.279000 ms, min 679.279000 ms
148+
Postprocess time: 58.927000 ms, avg 58.927000 ms, max 58.927000 ms, min 58.927000 ms
144149

145150
------------------------------
146151

147152
在 EEASYTECH NPU 上运行 mobilenet_v1_int8_per_layer_log2 全量化模型
148153
$ cd PaddleLite-generic-demo/image_classification_demo/shell
149154

150155
For SH506 NPU
151-
$ ./run_with_adb.sh mobilenet_v1_int8_per_layer_log2 linux armhf eeasytech_npu adb设备号
152-
(SH596)
153-
warmup: 1 repeat: 5, average: 52.715000 ms, max: 54.652100 ms, min: 51.233000 ms
154-
results: 3
155-
Top0 tabby, tabby cat - 0.708991
156-
Top1 Egyptian cat - 0.125688
157-
Top2 tiger cat - 0.051297
158-
Preprocess time: 6.935000 ms
159-
Prediction time: 50.715000 ms
160-
Postprocess time: 0.897000 ms
156+
$ ./run_with_adb.sh mobilenet_v1_int8_per_layer_log2 imagenet_224.txt test linux armhf eeasytech_npu adb设备号
157+
158+
Top1 tabby, tabby cat - 0.725007
159+
Top2 Egyptian cat - 0.183262
160+
Top3 tiger cat - 0.054423
161+
Top4 ping-pong ball - 0.003798
162+
Top5 lynx, catamount - 0.003338
163+
Preprocess time: 61.407000 ms, avg 61.407000 ms, max 61.407000 ms, min 61.407000 ms
164+
Prediction time: 48.100000 ms, avg 48.100000 ms, max 48.100000 ms, min 48.100000 ms
165+
Postprocess time: 59.201000 ms, avg 59.201000 ms, max 59.201000 ms, min 59.201000 ms
161166
```
162167

163-
- 如果需要更改测试图片,可将图片拷贝到 `PaddleLite-generic-demo/image_classification_demo/assets/images` 目录下,然后调用 `convert_to_raw_image.py` 生成相应的 RGB Raw 图像,最后修改 `run_with_adb.sh``run_with_ssh.sh` 的 IMAGE_NAME 变量即可
168+
- 如果需要更改测试图片,可将图片拷贝到 `PaddleLite-generic-demo/image_classification_demo/assets/datasets/test/inputs` 目录下,同时将图片文件名添加到 `PaddleLite-generic-demo/image_classification_demo/assets/datasets/test/list.txt`
164169
- 重新编译示例程序:
165170
```shell
166171
注意:

0 commit comments

Comments
 (0)