Project

General

Profile

Actions

How to build and test AI on SB52

Please follow the below steps to complete AI simple test.

(1)Download the test APP package linux_sample_2019_10_25_UTC.rar from

https://onlinedcc.innocomm.com/seeddms/out/out.ViewFolder.php?folderid=1464&showtree=1

(2)Extract linux_sample_2019_10_25_UTC.rar you will have folder named linux_example

(3)After fully built SB50 Yocto linux, we'll export toolchain path as below:

This is my compile environment for your reference:
export PATH=/home/inncomm/root/sb50/build/tmp/work/aarch64-poky-linux/apunn/1.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/:$PATH
export SDKTARGETSYSROOT="//home/inncomm/root/sb50/build/tmp/work/aarch64-poky-linux/apunn/1.0-r0/recipe-sysroot" 
export OECORE_NATIVE_SYSROOT="/home/inncomm/root/sb50/build/tmp/work/aarch64-poky-linux/apunn/1.0-r0/recipe-sysroot-native" 
export CXX="aarch64-poky-linux-clang++ --sysroot=$SDKTARGETSYSROOT" 
export CC="aarch64-poky-linux-clang --sysroot=$SDKTARGETSYSROOT" 

(4)make makefile under linux_example

   (a) Modify linux_example/CMakeLists.txt
       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

   (b) If you meet lack of libcxx.so
       Please add extract and copy the attached lib_1.rar to linux_example/ 
       And add the below to linux_example/CMakeLists.txt
       LINK_LIBRARIES("${CMAKE_CURRENT_LIST_DIR}/lib_1/aarch64-poky-linux/libc++.so.1")
       LINK_LIBRARIES("${CMAKE_CURRENT_LIST_DIR}/lib_1/aarch64-poky-linux/libc++abi.so.1")

   (c)Move to /linux_example 

inncomm@inncomm-Dell-System-XPS-L502X:~/yocto/SB50/linux_sample$ mkdir build
inncomm@inncomm-Dell-System-XPS-L502X:~/yocto/SB50/linux_sample$ cd build
inncomm@inncomm-Dell-System-XPS-L502X:~/yocto/SB50/linux_sample/build$ cmake ../
-- The C compiler identification is Clang 8.0.1
-- The CXX compiler identification is Clang 8.0.1
-- Check for working C compiler: /home/inncomm/root/sb50/build/tmp/work/aarch64-poky-linux/ann/v1-1/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-clang
-- Check for working C compiler: /home/inncomm/root/sb50/build/tmp/work/aarch64-poky-linux/ann/v1-1/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/inncomm/root/sb50/build/tmp/work/aarch64-poky-linux/ann/v1-1/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-clang++
-- Check for working CXX compiler: /home/inncomm/root/sb50/build/tmp/work/aarch64-poky-linux/ann/v1-1/recipe-sysroot-native/usr/bin/aarch64-poky-linux/aarch64-poky-linux-clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/inncomm/yocto/SB50/linux_sample/build

(5)Build AI Apps

inncomm@inncomm-Dell-System-XPS-L502X:~/yocto/SB50/linux_sample/build$ make
Scanning dependencies of target AddTwoTensors
[ 16%] Building CXX object AddTwoTensors/CMakeFiles/AddTwoTensors.dir/AddTwoTensors.cpp.o
[ 33%] Linking CXX executable AddTwoTensors
[ 33%] Built target AddTwoTensors
Scanning dependencies of target MobileNet
[ 50%] Building CXX object MobileNet/CMakeFiles/MobileNet.dir/MobileNet.cpp.o
[ 66%] Linking CXX executable MobileNet
[ 66%] Built target MobileNet
Scanning dependencies of target SSD
[ 83%] Building CXX object MobileNetSSD/CMakeFiles/SSD.dir/SSD.cpp.o
[100%] Linking CXX executable SSD
[100%] Built target SSD

(6)Push 3 APPs and related data into SB50

   (a)adb push linux_example/build/AddTwoTensors/AddTwoTensors /tmp

   (b)adb push linux_example/build/MobileNet/MobileNet /tmp
      adb push linux_example/MobileNet/model/fp32_mobilenet_v1_224_model.tflite /tmp
      adb push linux_example/MobileNet/model/grace_hopper.bin /tmp
      adb push linux_example/MobileNet/model/labels.txt /tmp

   (c)adb push linux_example/build/MobileSSD/SSD /tmp
      adb push linux_example/MobileSSD/model/mobilenet_SSD.tflite /tmp
      adb push linux_example/MobileSSD/model/bicycle.bin /tmp

(7)execute 3 AI APPs

$adb shell
sh-3.2# cd tmp
------------------------------(1)-------------------------------------
sh-3.2# ./AddTwoTensors 
VpuStream(772)[getAlgo] fail to get algo, Illegal seek, errno = 29
[inst] create vpu algo[apu_lib_custom] fail
result[0][0] = 101.000000
result[0][1] = 202.000000
result[0][2] = 303.000000
result[0][3] = 404.000000
result[1][0] = 505.000000
result[1][1] = 606.000000
result[1][2] = 707.000000
result[1][3] = 808.000000
result[2][0] = 909.000000
result[2][1] = 1010.000000
result[2][2] = 1111.000000
result[2][3] = 1212.000000
result[3][0] = 1313.000000
result[3][1] = 1414.000000
result[3][2] = 1515.000000
result[3][3] = 1616.000000
------------------------------(2)----------------------------------------              
./MobileNet fp32_mobilenet_v1_224_model.tflite labels.txt grace_hopper.bin
Input tensor
type : 1
dimsSize : 4
1 224 224 3 
bufferSize : 150528
VpuStream(776)[getAlgo] fail to get algo, Illegal seek, errno = 29
[inst] create vpu algo[apu_lib_custom] fail
NN-VPUH:XtensaConcat E 11-21 14:29:32   776   776 concat.cpp:107] Operation SQUEEZE does not the same type

Output tensor
type : 1
dimsSize : 2
1 1001 
bufferSize : 1001

Top 5 results:
[Top1 0.932144] 653:military uniform
[Top2 0.012665] 907:Windsor tie
[Top3 0.007185] 668:mortarboard
[Top4 0.003620] 514:cornet, horn, trumpet, trump
[Top5 0.003313] 820:stage
-----------------------------(3)-----------------------------
sh-3.2# ./SSD mobilenet_ssd.tflite bicycle.bin 

Input tensor
type : 1
dimsSize : 4
1 300 300 3 
bufferSize : 270000
VpuStream(781)[getAlgo] fail to get algo, Illegal seek, errno = 29
[inst] create vpu algo[apu_lib_custom] fail
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:70]  Operation CONCATENATION unsupported input type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:70]  Operation CONCATENATION unsupported input type

Output (box) tensor
type : 1
dimsSize : 3
1 1917 4 
bufferSize : 7668

Output (class) tensor
type : 1
dimsSize : 3
1 1917 91 
bufferSize : 174447

Top 10 Results:
[Top1 0.982844] car    (146, 68)    138x69
[Top2 0.947994] bicycle    (  4,129)    196x168
[Top3 0.929178] person    ( 68, 40)    102x198

Updated by Lion Wang over 2 years ago · 1 revisions