@@ -38,6 +38,11 @@ classification/imagenet_inception_v2_classification_5.tflite -i \
38
38
classification/dog.jpg -l classification/labels.txt -c 1 -b 0 -s 255 -t 1
39
39
# label: Blenheim spaniel with probability 11.0233 有bug
40
40
41
+ qemu-riscv64 classification/tflite_classification_arm -m \
42
+ classification/imagenet_inception_v3_classification_5.tflite -i \
43
+ classification/dog.jpg -l classification/labels.txt -c 1 -b 0 -s 255 -t 1
44
+ # label: Blenheim spaniel with probability 22.116
45
+
41
46
qemu-riscv64 classification/tflite_classification -m \
42
47
classification/imagenet_resnet_v1_50_classification_5.tflite -i \
43
48
classification/dog.jpg -l classification/labels.txt -c 1 -b 0 -s 255 -t 1
@@ -131,21 +136,27 @@ void DisplayFrames(char *display_win, int input_source, Mat &show_image,
131
136
void display_usage () {
132
137
std:
133
138
cout << " tflite_classification\n "
134
- << " --tflite_model, -m: model_name.tflite\n "
135
- << " --input_src, -r: [0|1|2] input source: image 0, video 1, camera 2\n "
139
+ << " --frame_cnt, -c: the number of frames to be used\n "
136
140
<< " --input_path, -i: path of the input image/video or video port for "
137
141
" camera, e.g., 1 for /dev/video1\n "
138
142
<< " --labels, -l: labels for the model\n "
139
- << " --frame_cnt, -c: the number of frames to be used\n "
143
+ << " --tflite_model, -m: model_name.tflite\n "
144
+ << " --profiling, -p: [0|1], profiling or not\n "
145
+ << " --input_src, -r: [0|1|2] input source: image 0, video 1, camera 2\n "
140
146
<< " --input_mean, -b: input mean\n "
141
147
<< " --input_std, -s: input standard deviation\n "
142
- << " --profiling, -p: [0|1], profiling or not\n "
143
148
<< " --threads, -t: number of threads\n "
149
+ << " --feature_copy, -f: feature copy to tcm\n "
150
+ << " --weight_copy, -w: weight copy to tcm\n "
151
+ << " --profile, -d: profile all layer\n "
152
+ << " --conv_profile, -P: profile convlution\n "
153
+ << " --freq, -F: cpu freq MHz\n "
154
+ << " --affinity, -a: process affinity\n "
155
+ << " --only_conv, -C: only run convlution\n "
156
+ << " --only_misc, -M: only run other op except convlution\n "
144
157
<< " \n " ;
145
158
}
146
159
147
- #ifdef MEM_PROFILE
148
-
149
160
#ifdef __cplusplus
150
161
extern " C" {
151
162
#endif
@@ -154,12 +165,23 @@ extern size_t packed_feature_in_byte;
154
165
155
166
extern size_t packed_weight_access_in_byte;
156
167
extern size_t packed_feature_access_in_byte;
168
+
169
+ extern bool PROFILE;
170
+ extern bool CONV_PROFILE;
171
+
172
+ extern long FREQ;
173
+
174
+ extern bool FEA_CPY2TCM;
175
+ extern bool FILTER_CPY2TCM;
176
+
177
+ extern bool ONLY_CONV;
178
+ extern bool ONLY_MISC;
179
+
180
+ extern long ELAPSEDTIME;
157
181
#ifdef __cplusplus
158
182
}
159
183
#endif
160
184
161
- #endif
162
-
163
185
// (input - mean) / std
164
186
/*
165
187
* Main function
@@ -180,30 +202,35 @@ int main(int argc, char **argv) {
180
202
while (1 ) {
181
203
static struct option long_options[] = {
182
204
{" frame_cnt" , required_argument, nullptr , ' c' },
183
- {" input_src" , required_argument, nullptr , ' r' },
184
205
{" input_path" , required_argument, nullptr , ' i' },
185
206
{" labels" , required_argument, nullptr , ' l' },
186
207
{" tflite_model" , required_argument, nullptr , ' m' },
187
208
{" profiling" , required_argument, nullptr , ' p' },
188
- {" threads " , required_argument, nullptr , ' t ' },
209
+ {" input_src " , required_argument, nullptr , ' r ' },
189
210
{" input_mean" , required_argument, nullptr , ' b' },
190
211
{" input_std" , required_argument, nullptr , ' s' },
212
+ {" threads" , required_argument, nullptr , ' t' },
213
+ {" feature_copy" , required_argument, nullptr , ' f' },
214
+ {" weight_copy" , required_argument, nullptr , ' w' },
215
+ {" profile" , required_argument, nullptr , ' d' },
216
+ {" conv_profile" , required_argument, nullptr , ' P' },
217
+ {" freq" , required_argument, nullptr , ' F' },
218
+ {" affinity" , required_argument, nullptr , ' a' },
219
+ {" only_conv" , required_argument, nullptr , ' C' },
220
+ {" only_misc" , required_argument, nullptr , ' M' },
191
221
{nullptr , 0 , nullptr , 0 }};
192
222
193
223
/* getopt_long stores the option index here. */
194
224
int option_index = 0 ;
195
225
196
- c = getopt_long (argc, argv, " b: c:i:l:m:p:r:s:t:h " , long_options ,
197
- &option_index);
226
+ c = getopt_long (argc, argv, " c:i:l:m:p:r:b: s:t:f:w:d:P:F:a:C:M:h " ,
227
+ long_options, &option_index);
198
228
199
229
/* Detect the end of the options. */
200
230
if (c == -1 )
201
231
break ;
202
232
203
233
switch (c) {
204
- case ' b' :
205
- input_mean = strtod (optarg , nullptr );
206
- break ;
207
234
case ' c' :
208
235
frame_cnt = strtol (optarg , nullptr , 10 );
209
236
break ;
@@ -222,12 +249,57 @@ int main(int argc, char **argv) {
222
249
case ' r' :
223
250
input_source = (eInputType)strtol (optarg , nullptr , 10 );
224
251
break ;
252
+ case ' b' :
253
+ input_mean = strtod (optarg , nullptr );
254
+ break ;
225
255
case ' s' :
226
256
input_std = strtod (optarg , nullptr );
227
257
break ;
228
258
case ' t' :
229
259
num_threads = strtol (optarg , nullptr , 10 );
230
260
break ;
261
+ case ' f' :
262
+ FEA_CPY2TCM = strtol (optarg , nullptr , 10 );
263
+ break ;
264
+ case ' w' :
265
+ FILTER_CPY2TCM = strtol (optarg , nullptr , 10 );
266
+ break ;
267
+ case ' d' :
268
+ PROFILE = strtol (optarg , nullptr , 10 );
269
+ break ;
270
+ case ' P' :
271
+ CONV_PROFILE = strtol (optarg , nullptr , 10 );
272
+ break ;
273
+ case ' F' :
274
+ FREQ = strtol (optarg , nullptr , 10 );
275
+ break ;
276
+ case ' a' : {
277
+ char *core_id_str = strtok (optarg , " ," );
278
+ cpu_set_t mask;
279
+ CPU_ZERO (&mask);
280
+ while (core_id_str) {
281
+ long core_id = strtol (core_id_str, nullptr , 10 );
282
+ if (core_id > -1 ) {
283
+ CPU_SET (core_id, &mask);
284
+ fprintf (stderr, " set affinity to %d!\n " , core_id);
285
+ } else {
286
+ fprintf (stderr, " noaffinity set!\n " );
287
+ }
288
+ core_id_str = strtok (NULL , " ," );
289
+ }
290
+ int result = sched_setaffinity (0 , sizeof (mask), &mask);
291
+ if (result == 0 ) {
292
+ fprintf (stderr, " set process affinity suc!\n " );
293
+ } else {
294
+ fprintf (stderr, " set process affinity err %d!\n " , result);
295
+ }
296
+ } break ;
297
+ case ' C' :
298
+ ONLY_CONV = strtol (optarg , nullptr , 10 );
299
+ break ;
300
+ case ' M' :
301
+ ONLY_MISC = strtol (optarg , nullptr , 10 );
302
+ break ;
231
303
case ' h' :
232
304
display_usage ();
233
305
exit (-1 );
@@ -350,9 +422,10 @@ int main(int argc, char **argv) {
350
422
351
423
if (profiling) {
352
424
std::cout << " Inference time for frame " << frame_index << " : "
353
- << inference_time_ms << " ms" << std::endl;
425
+ << inference_time_ms << " ms"
426
+ << " XNNPACKrun: " << ELAPSEDTIME << " ms" << std::endl;
354
427
}
355
-
428
+ ELAPSEDTIME = 0 ;
356
429
// Report the inference output
357
430
std::string last_label = " None" ;
358
431
int argmax = -1 ;
0 commit comments