Project

General

Profile

How to build and test AI on SB52 » History » Version 1

Lion Wang, 08/06/2021 03:19 PM

1 1 Lion Wang
h1. How to build and test AI on SB52 
2
3
Please follow the below steps to complete AI simple test.
4
5
(1)Download the test APP package linux_sample_2019_10_25_UTC.rar from
6
7
https://onlinedcc.innocomm.com/seeddms/out/out.ViewFolder.php?folderid=1464&showtree=1
8
9
10
(2)Extract linux_sample_2019_10_25_UTC.rar you will have folder named linux_example
11
12
(3)After fully built SB50 Yocto linux, we'll export toolchain path as below:
13
14
   This is my compile environment for your reference:
15
16
<pre>
17
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
18
export SDKTARGETSYSROOT="//home/inncomm/root/sb50/build/tmp/work/aarch64-poky-linux/apunn/1.0-r0/recipe-sysroot"
19
export OECORE_NATIVE_SYSROOT="/home/inncomm/root/sb50/build/tmp/work/aarch64-poky-linux/apunn/1.0-r0/recipe-sysroot-native"
20
export CXX="aarch64-poky-linux-clang++ --sysroot=$SDKTARGETSYSROOT"
21
export CC="aarch64-poky-linux-clang --sysroot=$SDKTARGETSYSROOT"
22
</pre>
23
24
(4)make makefile under linux_example
25
<pre>
26
   (a) Modify linux_example/CMakeLists.txt
27
       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
28
29
   (b) If you meet lack of libcxx.so
30
       Please add extract and copy the attached lib_1.rar to linux_example/ 
31
       And add the below to linux_example/CMakeLists.txt
32
       LINK_LIBRARIES("${CMAKE_CURRENT_LIST_DIR}/lib_1/aarch64-poky-linux/libc++.so.1")
33
       LINK_LIBRARIES("${CMAKE_CURRENT_LIST_DIR}/lib_1/aarch64-poky-linux/libc++abi.so.1")
34
35
   (c)Move to /linux_example 
36
37
</pre>
38
39
  
40
<pre><code class="shell">
41
inncomm@inncomm-Dell-System-XPS-L502X:~/yocto/SB50/linux_sample$ mkdir build
42
inncomm@inncomm-Dell-System-XPS-L502X:~/yocto/SB50/linux_sample$ cd build
43
inncomm@inncomm-Dell-System-XPS-L502X:~/yocto/SB50/linux_sample/build$ cmake ../
44
-- The C compiler identification is Clang 8.0.1
45
-- The CXX compiler identification is Clang 8.0.1
46
-- 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
47
-- 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
48
-- Detecting C compiler ABI info
49
-- Detecting C compiler ABI info - done
50
-- Detecting C compile features
51
-- Detecting C compile features - done
52
-- 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++
53
-- 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
54
-- Detecting CXX compiler ABI info
55
-- Detecting CXX compiler ABI info - done
56
-- Detecting CXX compile features
57
-- Detecting CXX compile features - done
58
-- Configuring done
59
-- Generating done
60
-- Build files have been written to: /home/inncomm/yocto/SB50/linux_sample/build
61
</code></pre>
62
63
(5)Build AI Apps
64
<pre><code class="shell">
65
inncomm@inncomm-Dell-System-XPS-L502X:~/yocto/SB50/linux_sample/build$ make
66
Scanning dependencies of target AddTwoTensors
67
[ 16%] Building CXX object AddTwoTensors/CMakeFiles/AddTwoTensors.dir/AddTwoTensors.cpp.o
68
[ 33%] Linking CXX executable AddTwoTensors
69
[ 33%] Built target AddTwoTensors
70
Scanning dependencies of target MobileNet
71
[ 50%] Building CXX object MobileNet/CMakeFiles/MobileNet.dir/MobileNet.cpp.o
72
[ 66%] Linking CXX executable MobileNet
73
[ 66%] Built target MobileNet
74
Scanning dependencies of target SSD
75
[ 83%] Building CXX object MobileNetSSD/CMakeFiles/SSD.dir/SSD.cpp.o
76
[100%] Linking CXX executable SSD
77
[100%] Built target SSD
78
</code></pre>
79
80
(6)Push 3 APPs and related data into SB50
81
<pre>
82
   (a)adb push linux_example/build/AddTwoTensors/AddTwoTensors /tmp
83
84
   (b)adb push linux_example/build/MobileNet/MobileNet /tmp
85
      adb push linux_example/MobileNet/model/fp32_mobilenet_v1_224_model.tflite /tmp
86
      adb push linux_example/MobileNet/model/grace_hopper.bin /tmp
87
      adb push linux_example/MobileNet/model/labels.txt /tmp
88
89
   (c)adb push linux_example/build/MobileSSD/SSD /tmp
90
      adb push linux_example/MobileSSD/model/mobilenet_SSD.tflite /tmp
91
      adb push linux_example/MobileSSD/model/bicycle.bin /tmp
92
</pre>
93
94
(7)execute 3 AI APPs
95
96
<pre><code class="shell">
97
$adb shell
98
sh-3.2# cd tmp
99
------------------------------(1)-------------------------------------
100
sh-3.2# ./AddTwoTensors 
101
VpuStream(772)[getAlgo] fail to get algo, Illegal seek, errno = 29
102
[inst] create vpu algo[apu_lib_custom] fail
103
result[0][0] = 101.000000
104
result[0][1] = 202.000000
105
result[0][2] = 303.000000
106
result[0][3] = 404.000000
107
result[1][0] = 505.000000
108
result[1][1] = 606.000000
109
result[1][2] = 707.000000
110
result[1][3] = 808.000000
111
result[2][0] = 909.000000
112
result[2][1] = 1010.000000
113
result[2][2] = 1111.000000
114
result[2][3] = 1212.000000
115
result[3][0] = 1313.000000
116
result[3][1] = 1414.000000
117
result[3][2] = 1515.000000
118
result[3][3] = 1616.000000
119
------------------------------(2)----------------------------------------              
120
./MobileNet fp32_mobilenet_v1_224_model.tflite labels.txt grace_hopper.bin
121
Input tensor
122
type : 1
123
dimsSize : 4
124
1 224 224 3 
125
bufferSize : 150528
126
VpuStream(776)[getAlgo] fail to get algo, Illegal seek, errno = 29
127
[inst] create vpu algo[apu_lib_custom] fail
128
NN-VPUH:XtensaConcat E 11-21 14:29:32   776   776 concat.cpp:107] Operation SQUEEZE does not the same type
129
130
Output tensor
131
type : 1
132
dimsSize : 2
133
1 1001 
134
bufferSize : 1001
135
136
Top 5 results:
137
[Top1 0.932144] 653:military uniform
138
[Top2 0.012665] 907:Windsor tie
139
[Top3 0.007185] 668:mortarboard
140
[Top4 0.003620] 514:cornet, horn, trumpet, trump
141
[Top5 0.003313] 820:stage
142
-----------------------------(3)-----------------------------
143
sh-3.2# ./SSD mobilenet_ssd.tflite bicycle.bin 
144
145
Input tensor
146
type : 1
147
dimsSize : 4
148
1 300 300 3 
149
bufferSize : 270000
150
VpuStream(781)[getAlgo] fail to get algo, Illegal seek, errno = 29
151
[inst] create vpu algo[apu_lib_custom] fail
152
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
153
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
154
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
155
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
156
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
157
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
158
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
159
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
160
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
161
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
162
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
163
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
164
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
165
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
166
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
167
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
168
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:70]  Operation CONCATENATION unsupported input type
169
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation RESHAPE does not the same type
170
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:107] Operation SQUEEZE does not the same type
171
NN-VPUH:XtensaConcat E 11-21 14:30:27   781   781 concat.cpp:70]  Operation CONCATENATION unsupported input type
172
173
Output (box) tensor
174
type : 1
175
dimsSize : 3
176
1 1917 4 
177
bufferSize : 7668
178
179
Output (class) tensor
180
type : 1
181
dimsSize : 3
182
1 1917 91 
183
bufferSize : 174447
184
185
Top 10 Results:
186
[Top1 0.982844] car	(146, 68)	138x69
187
[Top2 0.947994] bicycle	(  4,129)	196x168
188
[Top3 0.929178] person	( 68, 40)	102x198
189
190
</code></pre>