云峰 · 2021年07月21日

【周易AIPU 仿真】 SDK测试仿真器

下载周易AIPU SDK已经好几天,今天终于可以有一个完整的晚上完成仿真器的测试任务,希望能够获得一个免费测试板的机会,继续R329应用发掘之旅。

首先是准备开发环境,这里不得不说一下,macbook pro搭载的是Apple M1芯片,用了才知道,各种不兼容,开发还得在只剩下80%有效显示面积的旧机器上完成,所以也建议在做周易AIPU SDK测试的同学不要在这里走弯路浪费时间了。

言归正传,贴心的文档很容易就安装完成docker,测试例程tflite,编译运行一切OK,开发环境工作正常!

下载周易AIPU SDK解压后的文档目录如下:
image.png
由文档、开发工具、仿真器以及各种驱动等几部分组成,遍历文档之后,尝试拷贝tf测试用例,到docker环境中测试仿真:

docker cp ~/Downloads/AI610-SDK-1003-r0p0-eac0/user-case-example/tf 91b:/tf/aipu/

docker cp ~/Downloads/AI610-SDK-1002-r0p0-eac0/simulator/bin 91b:/tf/aipu/tf

docker cp ~/Downloads/AI610-SDK-1002-r0p0-eac0/simulator/lib 91b:/tf/aipu/tf

进入docker shell:

docker exec -it 91b /bin/bash

配置仿真器驱动路径:

export LD_LIBRARY_PATH="/tf/aipu/tf/lib/":$LD_LIBRARY_PATH

拷贝tflite例程文件,并作相应的路径修改:

copy ~/demos/tflite/quant_predict.py ./

修改配置文件中相应的文件路径,编译仿真文件:

aipubuild config/resnet_50_run.cfg

编译仿真结果显示:

[I]     step1: get max/min statistic value DONE
[I]     step2: quantization each op DONE
[I]     step3: build quantization forward DONE
[I]     step4: show output scale of end node:
[I]         layer_id: 76, layer_top:resnet_v1_50/predictions/Reshape_0, output_scale:[7.539542]
[I] ==== auto-quantization DONE =
[I] Quantize model complete
[I] Building ...
[I] [common_options.h: 276] BuildTool version: 4.0.175. Build for target Z2_1104 at frequency 800MHz
[I] [common_options.h: 297] using default profile events to profile AIFF

[I] [IRChecker] Start to check IR: /tmp/AIPUBuilder_1626796034.0382383/resnet_50_int8.txt
[I] [IRChecker] model_name: resnet_50
[I] [IRChecker] IRChecker: All IR pass
[I] [graph.cpp : 846] loading graph weight: /tmp/AIPUBuilder_1626796034.0382383/resnet_50_int8.bin size: 0x186d5a4
[W] [aipu_hwa_conv_eltwise_pooling.cpp: 338] HWA/AIFF Convolution+Eltwise+Pooling minimum step size depass WrB region1 size 56k
[W] [datalayout_schedule.cpp: 900] resnet_v1_50/logits/Conv2D_out_crop(InternalCrop)'s tensor resnet_v1_50/logits/BiasAdd_0's layout=NHWC is incompatible with the setted valide layout NCHWC32. the tensor shape is [1,1,1,1000]
[W] [datalayout_schedule.cpp: 900] resnet_v1_50/logits/Conv2D_out_crop(InternalCrop)'s tensor resnet_v1_50/logits/BiasAdd_0's layout=NHWC is incompatible with the setted valide layout NCHWC16. the tensor shape is [1,1,1,1000]
[I] [datalayout_schedule.cpp: 990] layout_loss: 52
[I] [datalayout_schedule.cpp:1006] optimized layout loss for graph resnet_50: 0
[I] [builder.cpp:1059] Total memory for this graph: 0x1cca8d0 Bytes
[I] [builder.cpp:1060] Text   section:    0x000160c0 Bytes
[I] [builder.cpp:1061] RO     section:    0x00003500 Bytes
[I] [builder.cpp:1062] Desc   section:    0x00013200 Bytes
[I] [builder.cpp:1063] Data   section:    0x01855cd0 Bytes
[I] [builder.cpp:1064] BSS    section:    0x00408040 Bytes
[I] [builder.cpp:1065] Stack         :    0x00040400 Bytes
[I] [builder.cpp:1066] Workspace(BSS):    0x00000000 Bytes
[I] [main.cpp  : 467] # autogenrated by aipurun, do NOT modify!
LOG_FILE=log_default
FAST_FWD_INST=0
INPUT_INST_CNT=1
INPUT_DATA_CNT=2
CONFIG=Z2-1104
LOG_LEVEL=0
INPUT_INST_FILE0=/tmp/temp_5422dc93560ce6305c78ff923d9e9.text
INPUT_INST_BASE0=0x0
INPUT_INST_STARTPC0=0x0
INPUT_DATA_FILE0=/tmp/temp_5422dc93560ce6305c78ff923d9e9.ro
INPUT_DATA_BASE0=0x10000000
INPUT_DATA_FILE1=/tmp/temp_5422dc93560ce6305c78ff923d9e9.data
INPUT_DATA_BASE1=0x20000000
OUTPUT_DATA_CNT=2
OUTPUT_DATA_FILE0=output_resnet_50.bin
OUTPUT_DATA_BASE0=0x21c9c000
OUTPUT_DATA_SIZE0=0x3e8
OUTPUT_DATA_FILE1=profile_data.bin
OUTPUT_DATA_BASE1=0x21896100
OUTPUT_DATA_SIZE1=0xa00
RUN_DESCRIPTOR=BIN[0]

[I] [main.cpp  : 118] run simulator:
./bin/aipu_simulator_z2 /tmp/temp_5422dc93560ce6305c78ff923d9e9.cfg
[INFO]:SIMULATOR START!
[INFO]:========================================================================
[INFO]:                             STATIC CHECK
[INFO]:========================================================================
[INFO]:  INST START ADDR : 0x0(0)
[INFO]:  INST END ADDR   : 0x160bf(90303)
[INFO]:  INST SIZE       : 0x160c0(90304)
[INFO]:  PACKET CNT      : 0x160c(5644)
[INFO]:  INST CNT        : 0x5830(22576)
[INFO]:------------------------------------------------------------------------
[INFO]:========================================================================
[INFO]:                             STATIC CHECK END
[INFO]:========================================================================

[INFO]:AIPU START RUNNING: BIN[0]
[INFO]:AIFF START, COUNT NUMBER: 1 ...
[INFO]:AIFF START, COUNT NUMBER: 2 ...
[INFO]:AIFF START, COUNT NUMBER: 3 ...
[INFO]:AIFF START, COUNT NUMBER: 4 ...
[INFO]:AIFF START, COUNT NUMBER: 5 ...
[INFO]:AIFF START, COUNT NUMBER: 6 ...
[INFO]:AIFF START, COUNT NUMBER: 7 ...
[INFO]:AIFF START, COUNT NUMBER: 8 ...
[INFO]:AIFF START, COUNT NUMBER: 9 ...
[INFO]:AIFF START, COUNT NUMBER: 10 ...
[INFO]:AIFF START, COUNT NUMBER: 11 ...
[INFO]:AIFF START, COUNT NUMBER: 12 ...
[INFO]:AIFF START, COUNT NUMBER: 13 ...
[INFO]:AIFF START, COUNT NUMBER: 14 ...
[INFO]:AIFF START, COUNT NUMBER: 15 ...
[INFO]:AIFF START, COUNT NUMBER: 16 ...
[INFO]:AIFF START, COUNT NUMBER: 17 ...
[INFO]:AIFF START, COUNT NUMBER: 18 ...
[INFO]:AIFF START, COUNT NUMBER: 19 ...
[INFO]:AIFF START, COUNT NUMBER: 20 ...
[INFO]:AIFF START, COUNT NUMBER: 21 ...
[INFO]:AIFF START, COUNT NUMBER: 22 ...
[INFO]:AIFF START, COUNT NUMBER: 23 ...
[INFO]:AIFF START, COUNT NUMBER: 24 ...
[INFO]:AIFF START, COUNT NUMBER: 25 ...
[INFO]:AIFF START, COUNT NUMBER: 26 ...
[INFO]:AIFF START, COUNT NUMBER: 27 ...
[INFO]:AIFF START, COUNT NUMBER: 28 ...
[INFO]:AIFF START, COUNT NUMBER: 29 ...
[INFO]:AIFF START, COUNT NUMBER: 30 ...
[INFO]:AIFF START, COUNT NUMBER: 31 ...
[INFO]:AIFF START, COUNT NUMBER: 32 ...
[INFO]:AIFF START, COUNT NUMBER: 33 ...
[INFO]:AIFF START, COUNT NUMBER: 34 ...
[INFO]:AIFF START, COUNT NUMBER: 35 ...
[INFO]:AIFF START, COUNT NUMBER: 36 ...
[INFO]:AIFF START, COUNT NUMBER: 37 ...
[INFO]:AIFF START, COUNT NUMBER: 38 ...
[INFO]:AIFF START, COUNT NUMBER: 39 ...
[INFO]:AIFF START, COUNT NUMBER: 40 ...
[INFO]:AIFF START, COUNT NUMBER: 41 ...
[INFO]:AIFF START, COUNT NUMBER: 42 ...
[INFO]:AIFF START, COUNT NUMBER: 43 ...
[INFO]:AIFF START, COUNT NUMBER: 44 ...
[INFO]:AIFF START, COUNT NUMBER: 45 ...
[INFO]:AIFF START, COUNT NUMBER: 46 ...
[INFO]:AIFF START, COUNT NUMBER: 47 ...
[INFO]:AIFF START, COUNT NUMBER: 48 ...
[INFO]:AIFF START, COUNT NUMBER: 49 ...
[INFO]:AIFF START, COUNT NUMBER: 50 ...
[INFO]:AIFF START, COUNT NUMBER: 51 ...
[INFO]:AIFF START, COUNT NUMBER: 52 ...
[INFO]:AIFF START, COUNT NUMBER: 53 ...
[INFO]:AIFF START, COUNT NUMBER: 54 ...
[INFO]:AIFF START, COUNT NUMBER: 55 ...
[INFO]:AIFF START, COUNT NUMBER: 56 ...
[INFO]:AIFF START, COUNT NUMBER: 57 ...
[INFO]:AIFF START, COUNT NUMBER: 58 ...
[INFO]:AIFF START, COUNT NUMBER: 59 ...
[INFO]:AIFF START, COUNT NUMBER: 60 ...
[INFO]:AIFF START, COUNT NUMBER: 61 ...
[INFO]:AIFF START, COUNT NUMBER: 62 ...
[INFO]:AIFF START, COUNT NUMBER: 63 ...
[INFO]:TOTAL TIME: 31.016803s. 
[INFO]:SIMULATOR EXIT!
[I] [main.cpp  : 135] Simulator finished.
Total errors: 0,  warnings: 3

显示识别结果:

root@91b43f705813:/tf/aipu/tf# python quant_predict.py 
predict first 5 label:
    index  230, prob 108, name: Old English sheepdog, bobtail
    index  231, prob  96, name: Shetland sheepdog, Shetland sheep dog, Shetland
    index  232, prob  57, name: collie
    index  263, prob  53, name: Brabancon griffon
    index  258, prob  53, name: Great Pyrenees
true first 5 label:
    index  230, prob 109, name: Old English sheepdog, bobtail
    index  231, prob  96, name: Shetland sheepdog, Shetland sheep dog, Shetland
    index  232, prob  57, name: collie
    index  226, prob  54, name: malinois
    index  263, prob  53, name: Brabancon griffon
Detect picture save to result.jpeg

result.jpeg:

docker cp  91b:/tf/aipu/tf/result.jpeg ./
open result.jpeg 

image.png
perfect!真机实测,敬请期待!

测试文件下载链接: https://pan.baidu.com/s/1JHrP... 密码: 02he

推荐阅读
关注数
7443
内容数
92
人工智能边缘计算软硬件解决方案,提供高性能、低成本、低功耗、易使用的硬件选型方案.
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息