瑞芯微和全志板端NPU运行AI模型
微信视频号:sph0RgSyDYV47z6
快手号:4874645212
抖音号:dy0so323fq2w
小红书号:95619019828
B站1:UID:3546863642871878
B站2:UID: 3546955410049087
在瑞芯微和全志最新的SOC上面,都集成了NPU,可以在板端运行相关AI模型,下面记录在对应的芯片平台上运行AI模型的操作:
1、瑞芯微
在Rockchip的RK3562/6/8、RK3576、RK3588等芯片上面,都集成了NPU,下面以RK3562为例说明:
在RK3562 Buildroot Linux系统板端,使用NPU运行转换后的RKNN模型,可以使用RK自带的rknn_common_test命令来运行,有如下例子:
rknn_common_test /usr/share/model/RK3562/mobilenet_v1.rknn /usr/share/model/dog_224x224.jpg
在板端执行上面的命令,有如下打印信息输出:
添加图片注释,不超过 140 字(可选)
只需要有相应的RKNN模型和该模型要用到的输入文件即可进行测试验证。
rknn_common_test命令的帮助信息如下:
Usage:rknn_common_test model_path input_path [loop_count]
其中,model_path指要使用的AI模型的路径; input_path指对应AI模型要使用到的数据源路径; loop_count指要执行多少遍,为可选项。
2、全志
在Allwinner的T536、MR536等SOC上面也集成了NPU,下面以MR536为例进行说明:
在MR536 OpenWRT Linux系统环境下,包含了AI例程和工具,在板端通过vpm_run命令运行转换后的NB格式模型,如下:
vpm_run -s /etc/npu/sample_viplite/MobileNet_V2/sample.txt
在板端执行上述命令,会有如下打印信息输出:
添加图片注释,不超过 140 字(可选)
相应的vpm_run命令的帮助信息如下:
相应的vpm_run命令的帮助信息如下:vpm_run -s sample.txt -l loop_run_count -d device_index-s sample.txt: to include one ore more network binary graph (NBG) data file resource. See sample.txt for details.-l loop_run_count: the number of loop run network.-d device_index: specify this NBG runs device.-t time_out: specify milliseconds time out of network.-b bypass_level: set value 1 to bypass saving output txt/binary file and showing top5.-c core_index: specify this start core index of device.--layer_profile_dump: set value 1 to enable NPD function.--preload: set value 1 to enable preload coeff into vipsram.--op_segment: set which operations will be run. example: --op_segment 10,20 means run 10 ~ 20--layer_dump: layer dump. eg: --layer_dump -1 dump all layer, --layer_dump 19, --layer_dump 18,20-h : helpexample: ./vpm_run -s sample.txt -l 10 -d 1 specify the NBG runs 10 times on device 1. 相应的sample.txt文件内容如下:
相应的vpm_run命令的帮助信息如下:vpm_run -s sample.txt -l loop_run_count -d device_index-s sample.txt: to include one ore more network binary graph (NBG) data file resource. See sample.txt for details.-l loop_run_count: the number of loop run network.-d device_index: specify this NBG runs device.-t time_out: specify milliseconds time out of network.-b bypass_level: set value 1 to bypass saving output txt/binary file and showing top5.-c core_index: specify this start core index of device.--layer_profile_dump: set value 1 to enable NPD function.--preload: set value 1 to enable preload coeff into vipsram.--op_segment: set which operations will be run. example: --op_segment 10,20 means run 10 ~ 20--layer_dump: layer dump. eg: --layer_dump -1 dump all layer, --layer_dump 19, --layer_dump 18,20-h : helpexample: ./vpm_run -s sample.txt -l 10 -d 1 specify the NBG runs 10 times on device 1. 相应的sample.txt文件内容如下:
相应的sample.txt文件内容如下:
vpm_run is a framework for testing VIPLite driver.
#You may put comment by starting with a '#'.#####################################################A separator makes the list clear.[network]/etc/npu/sample_viplite/MobileNet_V2/network_binary.nb[input]/etc/npu/sample_viplite/MobileNet_V2/244x244.dat
可以很直观看出,只需要配置好要使用的AI模型(即network),以及AI模型用到的数据(即input),即可使用vpm_run命令运行任何支持的NBG模型。
上述提及的RKNN和NBG模型,可通过相关芯片厂商提供的工具,将ONNX模型转换过来。
微信视频号:sph0RgSyDYV47z6
快手号:4874645212
抖音号:dy0so323fq2w
小红书号:95619019828
B站1:UID:3546863642871878
B站2:UID: 3546955410049087
参考文献链接
人工智能芯片与自动驾驶

浙公网安备 33010602011771号