test: Add CLTuner verification code
[platform/core/multimedia/inference-engine-interface.git] / test / src / inference_engine_profiler.cpp
1 /**
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <string.h>
18 #include <tuple>
19 #include <map>
20 #include <fcntl.h>
21 #include <unistd.h>
22 #include <queue>
23 #include <algorithm>
24
25 #include "gtest/gtest.h"
26
27 #include "inference_engine_error.h"
28 #include "inference_engine_common_impl.h"
29 #include "inference_engine_test_common.h"
30
31 #define INFERENCE_ITERATION             10
32
33 typedef std::tuple<std::string, int, int, int, int, std::vector<std::string>,
34                                    int, int, int, std::vector<std::string>,
35                                    std::vector<std::string>, std::vector<std::string>,
36                                    std::vector<int> >
37                 ParamType_Infer;
38
39
40 typedef std::tuple<std::string, int, bool, bool, inference_engine_cltuner_mode_e,
41                                    int, int, int, std::vector<std::string>,
42                                    int, int, int, std::vector<std::string>,
43                                    std::vector<std::string>, std::vector<std::string>,
44                                    std::vector<int> >
45                 ParamType_CLTuner;
46
47 class InferenceEngineTfliteCLTunerTest : public testing::TestWithParam<ParamType_CLTuner>
48 {};
49 class InferenceEngineTfliteTest : public testing::TestWithParam<ParamType_Infer>
50 {};
51 class InferenceEngineCaffeTest : public testing::TestWithParam<ParamType_Infer>
52 {};
53 class InferenceEngineDldtTest : public testing::TestWithParam<ParamType_Infer>
54 {};
55
56 TEST_P(InferenceEngineTfliteTest, Inference)
57 {
58         std::string backend_name;
59         int target_devices;
60         int test_type;
61         int iteration;
62         int tensor_type;
63         std::vector<std::string> image_paths;
64         size_t height;
65         size_t width;
66         size_t ch;
67         std::vector<std::string> input_layers;
68         std::vector<std::string> output_layers;
69         std::vector<std::string> model_paths;
70         std::vector<int> answers;
71
72         std::tie(backend_name, target_devices, test_type, iteration, tensor_type,
73                          image_paths, height, width, ch, input_layers, output_layers,
74                          model_paths, answers) = GetParam();
75
76         if (iteration < 1) {
77                 iteration = 1;
78         }
79
80         MachineCapacity *Cap = GetMachineCapacity();
81         if (Cap == NULL) {
82                 std::cout << "Failed to get machine capacity" << std::endl;
83                 return;
84         }
85
86         // If current machine doesn't support inference engine then skip this test.
87         if (Cap->available == false) {
88                 return;
89         }
90
91         // If current machine doesn't support OpenCL then skip the inference on GPU.
92         if (target_devices == INFERENCE_TARGET_GPU && Cap->has_gpu == false) {
93                 return;
94         }
95
96         std::string test_name;
97         switch (test_type) {
98         case TEST_IMAGE_CLASSIFICATION:
99                 test_name.append("Image classification");
100                 break;
101         case TEST_OBJECT_DETECTION:
102                 test_name.append("Object detection");
103                 break;
104         case TEST_FACE_DETECTION:
105                 test_name.append("Face detection");
106                 break;
107         case TEST_FACIAL_LANDMARK_DETECTION:
108                 test_name.append("Facial landmark detection");
109                 break;
110         case TEST_POSE_ESTIMATION:
111                 test_name.append("Pose estimation");
112                 break;
113         case TEST_AIC_HAND_GESTURE_1:
114                 test_name.append("AIC Hand Gesture detection 1");
115                 break;
116         case TEST_AIC_HAND_GESTURE_2:
117                 test_name.append("AIC Hand Gesture detection 2");
118                 break;
119         }
120
121         std::cout << test_name << " inference test : backend = " << backend_name
122                           << ", target device = " << Target_Formats[target_devices]
123                           << std::endl;
124
125         int backend_type = -1;
126
127         // If backend name is "one" then change it to "mlapi"
128         // and set backend_type to INFERENCE_BACKEND_ONE.
129         if (backend_name.compare("one") == 0) {
130                 backend_name = "mlapi";
131                 backend_type = INFERENCE_BACKEND_ONE;
132         }
133
134         inference_engine_config config = { .backend_name = backend_name,
135                                                                            .backend_type = backend_type,
136                                                                            .target_devices = target_devices };
137
138         auto engine = std::make_unique<InferenceEngineCommon>();
139         if (engine == nullptr) {
140                 ASSERT_TRUE(engine);
141                 return;
142         }
143
144         int ret = engine->EnableProfiler(true);
145         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
146                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
147                 return;
148         }
149
150         if (backend_type == INFERENCE_BACKEND_ONE)
151                 backend_name = "one";
152
153         ret = engine->DumpProfileToFile("profile_data_" + backend_name +
154                                                                         "_" + Target_Formats[target_devices] +
155                                                                         "_tflite_model.txt");
156         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
157                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
158                 return;
159         }
160
161         ret = engine->LoadConfigFile();
162         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
163
164         ret = engine->BindBackend(&config);
165         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
166                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
167                 return;
168         }
169
170         inference_engine_capacity capacity;
171         ret = engine->GetBackendCapacity(&capacity);
172         EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
173
174         ret = engine->SetTargetDevices(target_devices);
175         EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
176
177         std::vector<std::string> models;
178         int model_type = GetModelInfo(model_paths, models);
179         if (model_type == -1) {
180                 ASSERT_NE(model_type, -1);
181                 return;
182         }
183
184         inference_engine_layer_property input_property;
185         std::vector<std::string>::iterator iter;
186
187         for (iter = input_layers.begin(); iter != input_layers.end(); iter++) {
188                 inference_engine_tensor_info tensor_info = {
189                         { 1, ch, height, width },
190                         (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW,
191                         (inference_tensor_data_type_e) tensor_type,
192                         (size_t)(1 * ch * height * width)
193                 };
194
195                 input_property.layer_names.push_back(*iter);
196                 input_property.tensor_infos.push_back(tensor_info);
197         }
198
199         ret = engine->SetInputLayerProperty(input_property);
200         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
201                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
202                 return;
203         }
204
205         inference_engine_layer_property output_property;
206
207         for (iter = output_layers.begin(); iter != output_layers.end(); iter++) {
208                 output_property.layer_names.push_back(*iter);
209         }
210
211         ret = engine->SetOutputLayerProperty(output_property);
212         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
213                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
214                 return;
215         }
216
217         ret = engine->Load(models, (inference_model_format_e) model_type);
218         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
219                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
220                 return;
221         }
222
223         std::vector<inference_engine_tensor_buffer> inputs, outputs;
224         ret = PrepareTensorBuffers(engine.get(), inputs, outputs);
225         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
226                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
227                 return;
228         }
229
230         // Copy input image tensor data from a given file to input tensor buffer.
231         for (int i = 0; i < (int) image_paths.size(); ++i) {
232                 CopyFileToMemory(image_paths[i].c_str(), inputs[i], inputs[i].size);
233         }
234
235         for (int repeat = 0; repeat < iteration; ++repeat) {
236                 ret = engine->Run(inputs, outputs);
237                 EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
238         }
239
240         tensor_t result;
241         FillOutputResult(engine.get(), outputs, result);
242
243         switch (test_type) {
244         case TEST_IMAGE_CLASSIFICATION:
245                 ret = VerifyImageClassificationResults(result, answers[0]);
246                 EXPECT_EQ(ret, 1);
247                 break;
248         case TEST_OBJECT_DETECTION:
249                 // 1072 : fixed height size of dumped image, 1608 : fixed width size of dumped image.
250                 ret = VerifyObjectDetectionResults(result, answers, 1072, 1608);
251                 EXPECT_EQ(ret, 1);
252                 break;
253         case TEST_FACE_DETECTION:
254                 // 1152 : fixed height size of dumped image, 1536 : fixed width size of dumped image.
255                 ret = VerifyObjectDetectionResults(result, answers, 1152, 1536);
256                 EXPECT_EQ(ret, 1);
257                 break;
258         case TEST_FACIAL_LANDMARK_DETECTION:
259                 // TODO.
260                 break;
261         case TEST_POSE_ESTIMATION:
262                 // 563 : fixed height size of dumped image, 750 : fixed width size of dumped image.
263                 ret = VerifyPoseEstimationResults(result, answers, 563, 750);
264                 EXPECT_EQ(ret, 1);
265                 break;
266         case TEST_AIC_HAND_GESTURE_1:
267                 ret = VerifyAICHandGesture1Results(outputs);
268                 EXPECT_EQ(ret, 1);
269                 break;
270         case TEST_AIC_HAND_GESTURE_2:
271                 ret = VerifyAICHandGesture2Results(outputs, answers);
272                 EXPECT_EQ(ret, 1);
273                 break;
274         }
275
276         CleanupTensorBuffers(inputs, outputs);
277
278         engine->UnbindBackend();
279         models.clear();
280 }
281
282 TEST_P(InferenceEngineTfliteCLTunerTest, Inference)
283 {
284         std::string backend_name;
285         int target_devices;
286         bool active;
287         bool update;
288         inference_engine_cltuner_mode_e tuning_mode;
289         int test_type;
290         int iteration;
291         int tensor_type;
292         std::vector<std::string> image_paths;
293         size_t height;
294         size_t width;
295         size_t ch;
296         std::vector<std::string> input_layers;
297         std::vector<std::string> output_layers;
298         std::vector<std::string> model_paths;
299         std::vector<int> answers;
300
301         std::tie(backend_name, target_devices, active, update, tuning_mode, test_type,
302                          iteration, tensor_type, image_paths, height, width, ch, input_layers,
303                          output_layers, model_paths, answers) = GetParam();
304
305         if (iteration < 1) {
306                 iteration = 1;
307         }
308
309         MachineCapacity *Cap = GetMachineCapacity();
310         if (Cap == NULL) {
311                 std::cout << "Failed to get machine capacity" << std::endl;
312                 return;
313         }
314
315         // If current machine doesn't support inference engine then skip this test.
316         if (Cap->available == false) {
317                 return;
318         }
319
320         // If current machine doesn't support OpenCL then skip the inference on GPU.
321         if (target_devices == INFERENCE_TARGET_GPU && Cap->has_gpu == false) {
322                 return;
323         }
324
325         std::string test_name;
326         switch (test_type) {
327         case TEST_IMAGE_CLASSIFICATION:
328                 test_name.append("Image classification");
329                 break;
330         case TEST_OBJECT_DETECTION:
331                 test_name.append("Object detection");
332                 break;
333         case TEST_FACE_DETECTION:
334                 test_name.append("Face detection");
335                 break;
336         case TEST_FACIAL_LANDMARK_DETECTION:
337                 test_name.append("Facial landmark detection");
338                 break;
339         case TEST_POSE_ESTIMATION:
340                 test_name.append("Pose estimation");
341                 break;
342         case TEST_AIC_HAND_GESTURE_1:
343                 test_name.append("AIC Hand Gesture detection 1");
344                 break;
345         case TEST_AIC_HAND_GESTURE_2:
346                 test_name.append("AIC Hand Gesture detection 2");
347                 break;
348         }
349
350         std::cout << test_name << " inference test : backend = " << backend_name
351                           << ", target device = " << Target_Formats[target_devices]
352                           << ", CLTuning mode = " << tuning_mode << std::endl;
353
354         int backend_type = -1;
355
356         // If backend name is "one" then change it to "mlapi"
357         // and set backend_type to INFERENCE_BACKEND_ONE.
358         if (backend_name.compare("one") == 0) {
359                 backend_name = "mlapi";
360                 backend_type = INFERENCE_BACKEND_ONE;
361         }
362
363         inference_engine_config config = { .backend_name = backend_name,
364                                                                            .backend_type = backend_type,
365                                                                            .target_devices = target_devices };
366
367         auto engine = std::make_unique<InferenceEngineCommon>();
368         ASSERT_TRUE(engine);
369
370         int ret = engine->EnableProfiler(true);
371         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
372
373         if (backend_type == INFERENCE_BACKEND_ONE)
374                 backend_name = "one";
375
376         ret = engine->DumpProfileToFile("profile_data_" + backend_name +
377                                                                         "_" + Target_Formats[target_devices] +
378                                                                         "_tflite_model.txt");
379         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
380
381         ret = engine->LoadConfigFile();
382         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
383
384         ret = engine->BindBackend(&config);
385         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
386
387         inference_engine_capacity capacity;
388         ret = engine->GetBackendCapacity(&capacity);
389         EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
390
391         if (capacity.cltuner_supported) {
392                 inference_engine_cltuner cltuner;
393                         cltuner.active = active;
394                         cltuner.update = update;
395                         cltuner.tuning_mode = tuning_mode;
396
397                 ret = engine->SetCLTuner(&cltuner);
398                 EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
399         }
400
401         ret = engine->SetTargetDevices(target_devices);
402         EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
403
404         std::vector<std::string> models;
405         int model_type = GetModelInfo(model_paths, models);
406         ASSERT_NE(model_type, -1);
407
408         std::vector<std::string>::iterator iter;
409
410         inference_engine_tensor_info tensor_info = {
411                 { 1, ch, height, width },
412                 INFERENCE_TENSOR_SHAPE_NCHW,
413                 static_cast<inference_tensor_data_type_e>(tensor_type),
414                 static_cast<size_t>(1 * ch * height * width)
415         };
416
417         inference_engine_layer_property input_property;
418
419         for (auto &input : input_layers) {
420                 input_property.layer_names.push_back(input);
421                 input_property.tensor_infos.push_back(tensor_info);
422         }
423
424         ret = engine->SetInputLayerProperty(input_property);
425         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
426
427         inference_engine_layer_property output_property = { output_layers, {} };
428
429         ret = engine->SetOutputLayerProperty(output_property);
430         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
431
432         ret = engine->Load(models, (inference_model_format_e) model_type);
433         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
434
435         std::vector<inference_engine_tensor_buffer> inputs, outputs;
436         ret = PrepareTensorBuffers(engine.get(), inputs, outputs);
437         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
438
439         // Copy input image tensor data from a given file to input tensor buffer.
440         for (int i = 0; i < (int) image_paths.size(); ++i) {
441                 CopyFileToMemory(image_paths[i].c_str(), inputs[i], inputs[i].size);
442         }
443
444         for (int repeat = 0; repeat < iteration; ++repeat) {
445                 ret = engine->Run(inputs, outputs);
446                 EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
447         }
448
449         tensor_t result;
450         FillOutputResult(engine.get(), outputs, result);
451
452         switch (test_type) {
453         case TEST_IMAGE_CLASSIFICATION:
454                 ret = VerifyImageClassificationResults(result, answers[0]);
455                 EXPECT_EQ(ret, 1);
456                 break;
457         case TEST_OBJECT_DETECTION:
458                 // 1072 : fixed height size of dumped image, 1608 : fixed width size of dumped image.
459                 ret = VerifyObjectDetectionResults(result, answers, 1072, 1608);
460                 EXPECT_EQ(ret, 1);
461                 break;
462         case TEST_FACE_DETECTION:
463                 // 1152 : fixed height size of dumped image, 1536 : fixed width size of dumped image.
464                 ret = VerifyObjectDetectionResults(result, answers, 1152, 1536);
465                 EXPECT_EQ(ret, 1);
466                 break;
467         case TEST_FACIAL_LANDMARK_DETECTION:
468                 // TODO.
469                 break;
470         case TEST_POSE_ESTIMATION:
471                 // 563 : fixed height size of dumped image, 750 : fixed width size of dumped image.
472                 ret = VerifyPoseEstimationResults(result, answers, 563, 750);
473                 EXPECT_EQ(ret, 1);
474                 break;
475         case TEST_AIC_HAND_GESTURE_1:
476                 ret = VerifyAICHandGesture1Results(outputs);
477                 EXPECT_EQ(ret, 1);
478                 break;
479         case TEST_AIC_HAND_GESTURE_2:
480                 ret = VerifyAICHandGesture2Results(outputs, answers);
481                 EXPECT_EQ(ret, 1);
482                 break;
483         }
484
485         CleanupTensorBuffers(inputs, outputs);
486
487         engine->UnbindBackend();
488         models.clear();
489 }
490
491
492 TEST_P(InferenceEngineCaffeTest, Inference)
493 {
494         std::string backend_name;
495         int target_devices;
496         int test_type;
497         int iteration;
498         int tensor_type;
499         std::vector<std::string> image_paths;
500         size_t height;
501         size_t width;
502         size_t ch;
503         std::vector<std::string> input_layers;
504         std::vector<std::string> output_layers;
505         std::vector<std::string> model_paths;
506         std::vector<int> answers;
507
508         std::tie(backend_name, target_devices, test_type, iteration, tensor_type,
509                          image_paths, height, width, ch, input_layers, output_layers,
510                          model_paths, answers) = GetParam();
511
512         if (iteration < 1) {
513                 iteration = 1;
514         }
515
516         MachineCapacity *Cap = GetMachineCapacity();
517         if (Cap == NULL) {
518                 std::cout << "Failed to get machine capacity" << std::endl;
519                 return;
520         }
521
522         // If current machine doesn't support inference engine then skip this test.
523         if (Cap->available == false) {
524                 return;
525         }
526
527         // If current machine doesn't support OpenCL then skip the inference on GPU.
528         if (target_devices == INFERENCE_TARGET_GPU && Cap->has_gpu == false) {
529                 return;
530         }
531
532         std::string test_name;
533         switch (test_type) {
534         case TEST_IMAGE_CLASSIFICATION:
535                 test_name.append("Image classification");
536                 break;
537         case TEST_OBJECT_DETECTION:
538                 test_name.append("Object detection");
539                 break;
540         case TEST_FACE_DETECTION:
541                 test_name.append("Face detection");
542                 break;
543         case TEST_FACIAL_LANDMARK_DETECTION:
544                 test_name.append("Facial landmark detection");
545                 break;
546         case TEST_POSE_ESTIMATION:
547                 test_name.append("Pose estimation");
548                 break;
549         }
550
551         std::cout << test_name << " inference test : backend = " << backend_name
552                           << ", target device = " << Target_Formats[target_devices]
553                           << std::endl;
554         inference_engine_config config = { .backend_name = backend_name,
555                                                                            .backend_type = -1,
556                                                                            .target_devices = target_devices };
557
558         auto engine = std::make_unique<InferenceEngineCommon>();
559         if (engine == nullptr) {
560                 ASSERT_TRUE(engine);
561                 return;
562         }
563
564         int ret = engine->EnableProfiler(true);
565         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
566                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
567                 return;
568         }
569
570         ret = engine->DumpProfileToFile("profile_data_" + backend_name +
571                                                                         "_caffe_model.txt");
572         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
573                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
574                 return;
575         }
576
577         ret = engine->LoadConfigFile();
578         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
579
580         ret = engine->BindBackend(&config);
581         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
582                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
583                 return;
584         }
585
586         inference_engine_capacity capacity;
587         ret = engine->GetBackendCapacity(&capacity);
588         EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
589
590         ret = engine->SetTargetDevices(target_devices);
591         EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
592
593         std::vector<std::string> models;
594         int model_type = GetModelInfo(model_paths, models);
595         if (model_type == -1) {
596                 ASSERT_NE(model_type, -1);
597                 return;
598         }
599
600         inference_engine_layer_property input_property;
601         std::vector<std::string>::iterator iter;
602
603         for (iter = input_layers.begin(); iter != input_layers.end(); iter++) {
604                 inference_engine_tensor_info tensor_info = {
605                         { 1, ch, height, width },
606                         (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW,
607                         (inference_tensor_data_type_e) tensor_type,
608                         (size_t)(1 * ch * height * width)
609                 };
610
611                 input_property.layer_names.push_back(*iter);
612                 input_property.tensor_infos.push_back(tensor_info);
613         }
614
615         ret = engine->SetInputLayerProperty(input_property);
616         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
617                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
618                 return;
619         }
620
621         inference_engine_layer_property output_property;
622
623         for (iter = output_layers.begin(); iter != output_layers.end(); iter++) {
624                 output_property.layer_names.push_back(*iter);
625         }
626
627         ret = engine->SetOutputLayerProperty(output_property);
628         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
629                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
630                 return;
631         }
632
633         ret = engine->Load(models, (inference_model_format_e) model_type);
634         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
635                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
636                 return;
637         }
638
639         std::vector<inference_engine_tensor_buffer> inputs, outputs;
640         ret = PrepareTensorBuffers(engine.get(), inputs, outputs);
641         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
642                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
643                 return;
644         }
645
646         // Copy input image tensor data from a given file to input tensor buffer.
647         for (int i = 0; i < (int) image_paths.size(); ++i) {
648                 CopyFileToMemory(image_paths[i].c_str(), inputs[i], inputs[i].size);
649         }
650
651         for (int repeat = 0; repeat < iteration; ++repeat) {
652                 ret = engine->Run(inputs, outputs);
653                 EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
654         }
655
656         tensor_t result;
657         FillOutputResult(engine.get(), outputs, result);
658
659         switch (test_type) {
660         case TEST_IMAGE_CLASSIFICATION:
661                 ret = VerifyImageClassificationResults(result, answers[0]);
662                 EXPECT_EQ(ret, 1);
663                 break;
664         case TEST_OBJECT_DETECTION:
665                 // 1024 : fixed height size of dumped image, 636 : fixed width size of dumped image.
666                 ret = VerifyObjectDetectionResults(result, answers, 636, 1024);
667                 EXPECT_EQ(ret, 1);
668                 break;
669         case TEST_FACE_DETECTION:
670                 // 1152 : fixed height size of dumped image, 1536 : fixed width size of dumped image.
671                 ret = VerifyObjectDetectionResults(result, answers, 1152, 1536);
672                 EXPECT_EQ(ret, 1);
673                 break;
674         case TEST_FACIAL_LANDMARK_DETECTION:
675                 // 128 : fixed height size of dumped image, 128 : fixed width size of dumped image.
676                 ret = VerifyFacialLandmarkDetectionResults(result, answers, 128, 128);
677                 EXPECT_EQ(ret, 1);
678                 break;
679         case TEST_POSE_ESTIMATION:
680                 // 563 : fixed height size of dumped image, 750 : fixed width size of dumped image.
681                 ret = VerifyPoseEstimationResults(result, answers, 563, 750);
682                 EXPECT_EQ(ret, 1);
683                 break;
684         }
685
686         CleanupTensorBuffers(inputs, outputs);
687
688         engine->UnbindBackend();
689         models.clear();
690 }
691
692 TEST_P(InferenceEngineDldtTest, Inference)
693 {
694         std::string backend_name;
695         int target_devices;
696         int test_type;
697         int iteration;
698         int tensor_type;
699         std::vector<std::string> image_paths;
700         size_t height;
701         size_t width;
702         size_t ch;
703         std::vector<std::string> input_layers;
704         std::vector<std::string> output_layers;
705         std::vector<std::string> model_paths;
706         std::vector<int> answers;
707
708         std::tie(backend_name, target_devices, test_type, iteration, tensor_type,
709                          image_paths, height, width, ch, input_layers, output_layers,
710                          model_paths, answers) = GetParam();
711
712         if (iteration < 1) {
713                 iteration = 1;
714         }
715
716         MachineCapacity *Cap = GetMachineCapacity();
717         if (Cap == NULL) {
718                 std::cout << "Failed to get machine capacity" << std::endl;
719                 return;
720         }
721
722         // If current machine doesn't support inference engine then skip this test.
723         if (Cap->available == false) {
724                 return;
725         }
726
727         // If current machine doesn't support OpenCL then skip the inference on GPU.
728         if (target_devices == INFERENCE_TARGET_GPU && Cap->has_gpu == false) {
729                 return;
730         }
731
732         std::string test_name;
733         switch (test_type) {
734         case TEST_IMAGE_CLASSIFICATION:
735                 test_name.append("Image classification");
736                 break;
737         case TEST_OBJECT_DETECTION:
738                 test_name.append("Object detection");
739                 break;
740         case TEST_FACE_DETECTION:
741                 test_name.append("Face detection");
742                 break;
743         case TEST_FACIAL_LANDMARK_DETECTION:
744                 test_name.append("Facial landmark detection");
745                 break;
746         case TEST_POSE_ESTIMATION:
747                 test_name.append("Pose estimation");
748                 break;
749         }
750
751         std::cout << test_name << " inference test : backend = " << backend_name
752                           << ", target device = " << Target_Formats[target_devices]
753                           << std::endl;
754         inference_engine_config config = { .backend_name = backend_name,
755                                                                            .backend_type = -1,
756                                                                            .target_devices = target_devices };
757
758         auto engine = std::make_unique<InferenceEngineCommon>();
759         if (engine == nullptr) {
760                 ASSERT_TRUE(engine);
761                 return;
762         }
763
764         int ret = engine->EnableProfiler(true);
765         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
766                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
767                 return;
768         }
769
770         ret = engine->DumpProfileToFile("profile_data_" + backend_name +
771                                                                         "_dldt_model.txt");
772         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
773                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
774                 return;
775         }
776
777         ret = engine->LoadConfigFile();
778         ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
779
780         ret = engine->BindBackend(&config);
781         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
782                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
783                 return;
784         }
785
786         inference_engine_capacity capacity;
787         ret = engine->GetBackendCapacity(&capacity);
788         EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
789
790         ret = engine->SetTargetDevices(target_devices);
791         EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
792
793         std::vector<std::string> models;
794         int model_type = GetModelInfo(model_paths, models);
795         if (model_type == -1) {
796                 ASSERT_NE(model_type, -1);
797                 return;
798         }
799
800         inference_engine_layer_property input_property;
801         std::vector<std::string>::iterator iter;
802
803         for (iter = input_layers.begin(); iter != input_layers.end(); iter++) {
804                 inference_engine_tensor_info tensor_info = {
805                         { 1, ch, height, width },
806                         (inference_tensor_shape_type_e) INFERENCE_TENSOR_SHAPE_NCHW,
807                         (inference_tensor_data_type_e) tensor_type,
808                         (size_t)(1 * ch * height * width)
809                 };
810
811                 input_property.layer_names.push_back(*iter);
812                 input_property.tensor_infos.push_back(tensor_info);
813         }
814
815         ret = engine->SetInputLayerProperty(input_property);
816         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
817                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
818                 return;
819         }
820
821         inference_engine_layer_property output_property;
822
823         for (iter = output_layers.begin(); iter != output_layers.end(); iter++) {
824                 output_property.layer_names.push_back(*iter);
825         }
826
827         ret = engine->SetOutputLayerProperty(output_property);
828         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
829                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
830                 return;
831         }
832
833         ret = engine->Load(models, (inference_model_format_e) model_type);
834         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
835                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
836                 return;
837         }
838
839         std::vector<inference_engine_tensor_buffer> inputs, outputs;
840         ret = PrepareTensorBuffers(engine.get(), inputs, outputs);
841         if (ret != INFERENCE_ENGINE_ERROR_NONE) {
842                 ASSERT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
843                 return;
844         }
845
846         // Copy input image tensor data from a given file to input tensor buffer.
847         for (int i = 0; i < (int) image_paths.size(); ++i) {
848                 CopyFileToMemory(image_paths[i].c_str(), inputs[i], inputs[i].size);
849         }
850
851         for (int repeat = 0; repeat < iteration; ++repeat) {
852                 ret = engine->Run(inputs, outputs);
853                 EXPECT_EQ(ret, INFERENCE_ENGINE_ERROR_NONE);
854         }
855
856         tensor_t result;
857         FillOutputResult(engine.get(), outputs, result);
858
859         switch (test_type) {
860         case TEST_IMAGE_CLASSIFICATION:
861                 ret = VerifyImageClassificationResults(result, answers[0]);
862                 EXPECT_EQ(ret, 1);
863                 break;
864         case TEST_OBJECT_DETECTION:
865                 // 1024 : fixed height size of dumped image, 636 : fixed width size of dumped image.
866                 ret = VerifyObjectDetectionResults(result, answers, 636, 1024);
867                 EXPECT_EQ(ret, 1);
868                 break;
869         case TEST_FACE_DETECTION:
870                 // 1152 : fixed height size of dumped image, 1536 : fixed width size of dumped image.
871                 ret = VerifyObjectDetectionResults(result, answers, 1152, 1536);
872                 EXPECT_EQ(ret, 1);
873                 break;
874         case TEST_FACIAL_LANDMARK_DETECTION:
875                 // 128 : fixed height size of dumped image, 128 : fixed width size of dumped image.
876                 ret = VerifyFacialLandmarkDetectionResults(result, answers, 128, 128);
877                 EXPECT_EQ(ret, 1);
878                 break;
879         case TEST_POSE_ESTIMATION:
880                 // 563 : fixed height size of dumped image, 750 : fixed width size of dumped image.
881                 ret = VerifyPoseEstimationResults(result, answers, 563, 750);
882                 EXPECT_EQ(ret, 1);
883                 break;
884         }
885
886         CleanupTensorBuffers(inputs, outputs);
887
888         engine->UnbindBackend();
889         models.clear();
890 }
891
892 INSTANTIATE_TEST_CASE_P(
893                 Opensource, InferenceEngineTfliteTest,
894                 testing::Values(
895                                 // parameter order : backend name, target device, input image path/s, height, width, channel count, input layer names, output layer names, model path/s, inference result
896                                 // mobilenet based image classification test
897                                 // ARMNN.
898                                 ParamType_Infer(
899                                                 "armnn", INFERENCE_TARGET_CPU,
900                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
901                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
902                                                 { "/opt/usr/images/image_classification.bin" }, 224,
903                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
904                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
905                                                 { 3 }),
906                                 // quantized mobilenet based image classification test
907                                 ParamType_Infer(
908                                                 "armnn", INFERENCE_TARGET_CPU,
909                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
910                                                 INFERENCE_TENSOR_DATA_TYPE_UINT8,
911                                                 { "/opt/usr/images/image_classification_q.bin" }, 224,
912                                                 224, 3, { "input" },
913                                                 { "MobilenetV1/Predictions/Reshape_1" },
914                                                 { "/usr/share/capi-media-vision/models/IC_Q/tflite/ic_tflite_q_model.tflite" },
915                                                 { 955 }),
916                                 // object detection test
917                                 ParamType_Infer(
918                                                 "armnn", INFERENCE_TARGET_CPU, TEST_OBJECT_DETECTION,
919                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
920                                                 { "/opt/usr/images/object_detection.bin" }, 300, 300, 3,
921                                                 { "normalized_input_image_tensor" },
922                                                 { "TFLite_Detection_PostProcess",
923                                                   "TFLite_Detection_PostProcess:1",
924                                                   "TFLite_Detection_PostProcess:2",
925                                                   "TFLite_Detection_PostProcess:3" },
926                                                 { "/usr/share/capi-media-vision/models/OD/tflite/od_tflite_model.tflite" },
927                                                 { 451, 474, 714, 969 }),
928                                 // face detection test
929                                 ParamType_Infer(
930                                                 "armnn", INFERENCE_TARGET_CPU, TEST_FACE_DETECTION, INFERENCE_ITERATION,
931                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
932                                                 { "/opt/usr/images/face_detection.bin" }, 300, 300, 3,
933                                                 { "normalized_input_image_tensor" },
934                                                 { "TFLite_Detection_PostProcess",
935                                                   "TFLite_Detection_PostProcess:1",
936                                                   "TFLite_Detection_PostProcess:2",
937                                                   "TFLite_Detection_PostProcess:3" },
938                                                 { "/usr/share/capi-media-vision/models/FD/tflite/fd_tflite_model1.tflite" },
939                                                 { 727, 225, 960, 555 }),
940                                 // pose estimation test
941                                 ParamType_Infer(
942                                                 "armnn", INFERENCE_TARGET_CPU, TEST_POSE_ESTIMATION, INFERENCE_ITERATION,
943                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
944                                                 { "/opt/usr/images/pose_estimation.bin" }, 192, 192, 3,
945                                                 { "image" },
946                                                 { "Convolutional_Pose_Machine/stage_5_out" },
947                                                 { "/usr/share/capi-media-vision/models/PE/tflite/ped_tflite_model.tflite" },
948                                                 { 382, 351, 320, 257, 226, 414, 414, 445, 351, 351,
949                                                   351, 382, 382, 382, 76,  146, 170, 193, 216, 146,
950                                                   123, 99,  287, 381, 451, 287, 381, 475 }),
951                                 // Hand gesture model 1 from AIC
952                                 ParamType_Infer("armnn", INFERENCE_TARGET_CPU, TEST_AIC_HAND_GESTURE_1, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
953                                                 { "/opt/usr/images/hand.bin" }, 224, 224, 3, { "input" }, { "mobilenetv2/boundingbox", "mobilenetv2/heatmap" },
954                                                 { "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_lite_224.tflite" }, { 0 }),
955                                 // Hand gesture model 2 from AIC
956                                 ParamType_Infer("armnn", INFERENCE_TARGET_CPU, TEST_AIC_HAND_GESTURE_2, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
957                                                 { "/opt/usr/images/hand.bin" }, 56, 56, 21, { "input" }, { "mobilenetv2/coord_refine", "mobilenetv2/gesture" },
958                                                 { "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_lite_224.tflite" },
959                                                 { 55, 39, 51, 40, 50, 42, 61, 43, 71, 39,
960                                                   78, 36, 82, 42, 82, 44, 83, 45, 35, 37,
961                                                   61, 36, 59, 36, 52, 39, 35, 32, 40, 34,
962                                                   62, 39, 70, 40, 58, 41, 34, 42, 34, 41,
963                                                   38, 38, 12 }),
964                                 // mobilenet based image classification test
965                                 ParamType_Infer(
966                                                 "armnn", INFERENCE_TARGET_GPU,
967                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
968                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
969                                                 { "/opt/usr/images/image_classification.bin" }, 224,
970                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
971                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
972                                                 { 3 }),
973                                 // quantized mobilenet based image classification test
974                                 ParamType_Infer(
975                                                 "armnn", INFERENCE_TARGET_GPU,
976                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
977                                                 INFERENCE_TENSOR_DATA_TYPE_UINT8,
978                                                 { "/opt/usr/images/image_classification_q.bin" }, 224,
979                                                 224, 3, { "input" },
980                                                 { "MobilenetV1/Predictions/Reshape_1" },
981                                                 { "/usr/share/capi-media-vision/models/IC_Q/tflite/ic_tflite_q_model.tflite" },
982                                                 { 955 }),
983                                 // object detection test
984                                 ParamType_Infer(
985                                                 "armnn", INFERENCE_TARGET_GPU, TEST_OBJECT_DETECTION,
986                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
987                                                 { "/opt/usr/images/object_detection.bin" }, 300, 300, 3,
988                                                 { "normalized_input_image_tensor" },
989                                                 { "TFLite_Detection_PostProcess",
990                                                   "TFLite_Detection_PostProcess:1",
991                                                   "TFLite_Detection_PostProcess:2",
992                                                   "TFLite_Detection_PostProcess:3" },
993                                                 { "/usr/share/capi-media-vision/models/OD/tflite/od_tflite_model.tflite" },
994                                                 { 451, 474, 714, 969 }),
995                                 // face detection test
996                                 ParamType_Infer(
997                                                 "armnn", INFERENCE_TARGET_GPU, TEST_FACE_DETECTION, INFERENCE_ITERATION,
998                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
999                                                 { "/opt/usr/images/face_detection.bin" }, 300, 300, 3,
1000                                                 { "normalized_input_image_tensor" },
1001                                                 { "TFLite_Detection_PostProcess",
1002                                                   "TFLite_Detection_PostProcess:1",
1003                                                   "TFLite_Detection_PostProcess:2",
1004                                                   "TFLite_Detection_PostProcess:3" },
1005                                                 { "/usr/share/capi-media-vision/models/FD/tflite/fd_tflite_model1.tflite" },
1006                                                 { 727, 225, 960, 555 }),
1007                                 // pose estimation test
1008                                 ParamType_Infer(
1009                                                 "armnn", INFERENCE_TARGET_GPU, TEST_POSE_ESTIMATION, INFERENCE_ITERATION,
1010                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1011                                                 { "/opt/usr/images/pose_estimation.bin" }, 192, 192, 3,
1012                                                 { "image" },
1013                                                 { "Convolutional_Pose_Machine/stage_5_out" },
1014                                                 { "/usr/share/capi-media-vision/models/PE/tflite/ped_tflite_model.tflite" },
1015                                                 { 382, 351, 320, 257, 226, 414, 414, 445, 351, 351,
1016                                                   351, 382, 382, 382, 76,  146, 170, 193, 216, 146,
1017                                                   123, 99,  287, 381, 451, 287, 381, 475 }),
1018                                 // Hand gesture model 1 from AIC
1019                                 ParamType_Infer("armnn", INFERENCE_TARGET_GPU, TEST_AIC_HAND_GESTURE_1, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1020                                                 { "/opt/usr/images/hand.bin" }, 224, 224, 3, { "input" }, { "mobilenetv2/boundingbox", "mobilenetv2/heatmap" },
1021                                                 { "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_lite_224.tflite" }, { 0 }),
1022                                 // Hand gesture model 2 from AIC
1023                                 ParamType_Infer("armnn", INFERENCE_TARGET_GPU, TEST_AIC_HAND_GESTURE_2, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1024                                                 { "/opt/usr/images/hand.bin" }, 56, 56, 21, { "input" }, { "mobilenetv2/coord_refine", "mobilenetv2/gesture" },
1025                                                 { "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_lite_224.tflite" },
1026                                                 { 55, 39, 51, 40, 50, 42, 61, 43, 71, 39,
1027                                                   78, 36, 82, 42, 82, 44, 83, 45, 35, 37,
1028                                                   61, 36, 59, 36, 52, 39, 35, 32, 40, 34,
1029                                                   62, 39, 70, 40, 58, 41, 34, 42, 34, 41,
1030                                                   38, 38, 12 }),
1031
1032                                 /*********************************************************************************/
1033                                 // parameter order : backend name, target device, input image path/s, height, width, channel count, input layer names, output layer names, model path/s, inference result
1034                                 // mobilenet based image classification test
1035                                 // TFLITE.
1036                                 ParamType_Infer(
1037                                                 "tflite", INFERENCE_TARGET_CPU,
1038                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1039                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1040                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1041                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1042                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1043                                                 { 3 }),
1044                                 // quantized mobilenet based image classification test
1045                                 ParamType_Infer(
1046                                                 "tflite", INFERENCE_TARGET_CPU,
1047                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1048                                                 INFERENCE_TENSOR_DATA_TYPE_UINT8,
1049                                                 { "/opt/usr/images/image_classification_q.bin" }, 224,
1050                                                 224, 3, { "input" },
1051                                                 { "MobilenetV1/Predictions/Reshape_1" },
1052                                                 { "/usr/share/capi-media-vision/models/IC_Q/tflite/ic_tflite_q_model.tflite" },
1053                                                 { 955 }),
1054                                 // object detection test
1055                                 ParamType_Infer(
1056                                                 "tflite", INFERENCE_TARGET_CPU, TEST_OBJECT_DETECTION,
1057                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1058                                                 { "/opt/usr/images/object_detection.bin" }, 300, 300, 3,
1059                                                 { "normalized_input_image_tensor" },
1060                                                 { "TFLite_Detection_PostProcess",
1061                                                   "TFLite_Detection_PostProcess:1",
1062                                                   "TFLite_Detection_PostProcess:2",
1063                                                   "TFLite_Detection_PostProcess:3" },
1064                                                 { "/usr/share/capi-media-vision/models/OD/tflite/od_tflite_model.tflite" },
1065                                                 { 451, 474, 714, 969 }),
1066                                 // face detection test
1067                                 ParamType_Infer(
1068                                                 "tflite", INFERENCE_TARGET_CPU, TEST_FACE_DETECTION, INFERENCE_ITERATION,
1069                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1070                                                 { "/opt/usr/images/face_detection.bin" }, 300, 300, 3,
1071                                                 { "normalized_input_image_tensor" },
1072                                                 { "TFLite_Detection_PostProcess",
1073                                                   "TFLite_Detection_PostProcess:1",
1074                                                   "TFLite_Detection_PostProcess:2",
1075                                                   "TFLite_Detection_PostProcess:3" },
1076                                                 { "/usr/share/capi-media-vision/models/FD/tflite/fd_tflite_model1.tflite" },
1077                                                 { 727, 225, 960, 555 }),
1078                                 // pose estimation test
1079                                 ParamType_Infer(
1080                                                 "tflite", INFERENCE_TARGET_CPU, TEST_POSE_ESTIMATION,
1081                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1082                                                 { "/opt/usr/images/pose_estimation.bin" }, 192, 192, 3,
1083                                                 { "image" },
1084                                                 { "Convolutional_Pose_Machine/stage_5_out" },
1085                                                 { "/usr/share/capi-media-vision/models/PE/tflite/ped_tflite_model.tflite" },
1086                                                 { 382, 351, 320, 257, 226, 414, 414, 445, 351, 351,
1087                                                   351, 382, 382, 382, 76,  146, 170, 193, 216, 146,
1088                                                   123, 99,  287, 381, 451, 287, 381, 475 }),
1089                                 // Hand gesture model 1 from AIC
1090                                 ParamType_Infer("tflite", INFERENCE_TARGET_CPU, TEST_AIC_HAND_GESTURE_1, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1091                                                 { "/opt/usr/images/hand.bin" }, 224, 224, 3, { "input" }, { "mobilenetv2/boundingbox", "mobilenetv2/heatmap" },
1092                                                 { "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_lite_224.tflite" }, { 0 }),
1093                                 // Hand gesture model 2 from AIC
1094                                 ParamType_Infer("tflite", INFERENCE_TARGET_CPU, TEST_AIC_HAND_GESTURE_2, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1095                                                 { "/opt/usr/images/hand.bin" }, 56, 56, 21, { "input" }, { "mobilenetv2/coord_refine", "mobilenetv2/gesture" },
1096                                                 { "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_lite_224.tflite" },
1097                                                 { 55, 39, 51, 40, 50, 42, 61, 43, 71, 39,
1098                                                   78, 36, 82, 42, 82, 44, 83, 45, 35, 37,
1099                                                   61, 36, 59, 36, 52, 39, 35, 32, 40, 34,
1100                                                   62, 39, 70, 40, 58, 41, 34, 42, 34, 41,
1101                                                   38, 38, 12 }),
1102
1103                                 // mobilenet based image classification test
1104                                 ParamType_Infer(
1105                                                 "tflite", INFERENCE_TARGET_GPU,
1106                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1107                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1108                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1109                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1110                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1111                                                 { 3 }),
1112                                 // quantized mobilenet based image classification test
1113                                 ParamType_Infer(
1114                                                 "tflite", INFERENCE_TARGET_GPU,
1115                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1116                                                 INFERENCE_TENSOR_DATA_TYPE_UINT8,
1117                                                 { "/opt/usr/images/image_classification_q.bin" }, 224,
1118                                                 224, 3, { "input" },
1119                                                 { "MobilenetV1/Predictions/Reshape_1" },
1120                                                 { "/usr/share/capi-media-vision/models/IC_Q/tflite/ic_tflite_q_model.tflite" },
1121                                                 { 955 }),
1122                                 // object detection test
1123                                 ParamType_Infer(
1124                                                 "tflite", INFERENCE_TARGET_GPU, TEST_OBJECT_DETECTION,
1125                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1126                                                 { "/opt/usr/images/object_detection.bin" }, 300, 300, 3,
1127                                                 { "normalized_input_image_tensor" },
1128                                                 { "TFLite_Detection_PostProcess",
1129                                                   "TFLite_Detection_PostProcess:1",
1130                                                   "TFLite_Detection_PostProcess:2",
1131                                                   "TFLite_Detection_PostProcess:3" },
1132                                                 { "/usr/share/capi-media-vision/models/OD/tflite/od_tflite_model.tflite" },
1133                                                 { 451, 474, 714, 969 }),
1134                                 // face detection test
1135                                 ParamType_Infer(
1136                                                 "tflite", INFERENCE_TARGET_GPU, TEST_FACE_DETECTION, INFERENCE_ITERATION,
1137                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1138                                                 { "/opt/usr/images/face_detection.bin" }, 300, 300, 3,
1139                                                 { "normalized_input_image_tensor" },
1140                                                 { "TFLite_Detection_PostProcess",
1141                                                   "TFLite_Detection_PostProcess:1",
1142                                                   "TFLite_Detection_PostProcess:2",
1143                                                   "TFLite_Detection_PostProcess:3" },
1144                                                 { "/usr/share/capi-media-vision/models/FD/tflite/fd_tflite_model1.tflite" },
1145                                                 { 727, 225, 960, 555 }),
1146                                 // pose estimation test
1147                                 ParamType_Infer(
1148                                                 "tflite", INFERENCE_TARGET_GPU, TEST_POSE_ESTIMATION,
1149                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1150                                                 { "/opt/usr/images/pose_estimation.bin" }, 192, 192, 3,
1151                                                 { "image" },
1152                                                 { "Convolutional_Pose_Machine/stage_5_out" },
1153                                                 { "/usr/share/capi-media-vision/models/PE/tflite/ped_tflite_model.tflite" },
1154                                                 { 382, 351, 320, 257, 226, 414, 414, 445, 351, 351,
1155                                                   351, 382, 382, 382, 76,  146, 170, 193, 216, 146,
1156                                                   123, 99,  287, 381, 451, 287, 381, 475 }),
1157                                 // Hand gesture model 1 from AIC
1158                                 ParamType_Infer("tflite", INFERENCE_TARGET_GPU, TEST_AIC_HAND_GESTURE_1, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1159                                                 { "/opt/usr/images/hand.bin" }, 224, 224, 3, { "input" }, { "mobilenetv2/boundingbox", "mobilenetv2/heatmap" },
1160                                                 { "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_lite_224.tflite" }, { 0 }),
1161                                 // Hand gesture model 2 from AIC
1162                                 ParamType_Infer("tflite", INFERENCE_TARGET_GPU, TEST_AIC_HAND_GESTURE_2, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1163                                                 { "/opt/usr/images/hand.bin" }, 56, 56, 21, { "input" }, { "mobilenetv2/coord_refine", "mobilenetv2/gesture" },
1164                                                 { "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_lite_224.tflite" },
1165                                                 { 55, 39, 51, 40, 50, 42, 61, 43, 71, 39,
1166                                                   78, 36, 82, 42, 82, 44, 83, 45, 35, 37,
1167                                                   61, 36, 59, 36, 52, 39, 35, 32, 40, 34,
1168                                                   62, 39, 70, 40, 58, 41, 34, 42, 34, 41,
1169                                                   38, 38, 12 })
1170                                 /* TODO */
1171                                 ));
1172
1173 INSTANTIATE_TEST_CASE_P(
1174                 Inhouse, InferenceEngineTfliteTest,
1175                 testing::Values(
1176                                 /*********************************************************************************/
1177                                 // parameter order : backend name, target device, input image path/s, height, width, channel count, input layer names, output layer names, model path/s, inference result
1178                                 // mobilenet based image classification test
1179                                 // ONE via MLAPI.
1180                                 ParamType_Infer(
1181                                                 "one", INFERENCE_TARGET_CPU,
1182                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1183                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1184                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1185                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1186                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1187                                                 { 3 }),
1188                                 // quantized mobilenet based image classification test
1189                                 ParamType_Infer(
1190                                                 "one", INFERENCE_TARGET_CPU,
1191                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1192                                                 INFERENCE_TENSOR_DATA_TYPE_UINT8,
1193                                                 { "/opt/usr/images/image_classification_q.bin" }, 224,
1194                                                 224, 3, { "input" },
1195                                                 { "MobilenetV1/Predictions/Reshape_1" },
1196                                                 { "/usr/share/capi-media-vision/models/IC_Q/tflite/ic_tflite_q_model.tflite" },
1197                                                 { 955 }),
1198                                 // object detection test
1199                                 ParamType_Infer(
1200                                                 "one", INFERENCE_TARGET_CPU, TEST_OBJECT_DETECTION,
1201                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1202                                                 { "/opt/usr/images/object_detection.bin" }, 300, 300, 3,
1203                                                 { "normalized_input_image_tensor" },
1204                                                 { "TFLite_Detection_PostProcess",
1205                                                   "TFLite_Detection_PostProcess:1",
1206                                                   "TFLite_Detection_PostProcess:2",
1207                                                   "TFLite_Detection_PostProcess:3" },
1208                                                 { "/usr/share/capi-media-vision/models/OD/tflite/od_tflite_model.tflite" },
1209                                                 { 451, 474, 714, 969 }),
1210                                 // face detection test
1211                                 ParamType_Infer(
1212                                                 "one", INFERENCE_TARGET_CPU, TEST_FACE_DETECTION, INFERENCE_ITERATION,
1213                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1214                                                 { "/opt/usr/images/face_detection.bin" }, 300, 300, 3,
1215                                                 { "normalized_input_image_tensor" },
1216                                                 { "TFLite_Detection_PostProcess",
1217                                                   "TFLite_Detection_PostProcess:1",
1218                                                   "TFLite_Detection_PostProcess:2",
1219                                                   "TFLite_Detection_PostProcess:3" },
1220                                                 { "/usr/share/capi-media-vision/models/FD/tflite/fd_tflite_model1.tflite" },
1221                                                 { 727, 225, 960, 555 }),
1222                                 // pose estimation test
1223                                 ParamType_Infer(
1224                                                 "one", INFERENCE_TARGET_CPU, TEST_POSE_ESTIMATION,
1225                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1226                                                 { "/opt/usr/images/pose_estimation.bin" }, 192, 192, 3,
1227                                                 { "image" },
1228                                                 { "Convolutional_Pose_Machine/stage_5_out" },
1229                                                 { "/usr/share/capi-media-vision/models/PE/tflite/ped_tflite_model.tflite" },
1230                                                 { 382, 351, 320, 257, 226, 414, 414, 445, 351, 351,
1231                                                   351, 382, 382, 382, 76,  146, 170, 193, 216, 146,
1232                                                   123, 99,  287, 381, 451, 287, 381, 475 }),
1233                                 // Hand gesture model 1 from AIC
1234                                 ParamType_Infer("one", INFERENCE_TARGET_CPU, TEST_AIC_HAND_GESTURE_1, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1235                                                 { "/opt/usr/images/hand.bin" }, 224, 224, 3, { "input" }, { "mobilenetv2/boundingbox", "mobilenetv2/heatmap" },
1236                                                 { "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_lite_224.tflite" }, { 0 }),
1237                                 // Hand gesture model 2 from AIC
1238                                 ParamType_Infer("one", INFERENCE_TARGET_CPU, TEST_AIC_HAND_GESTURE_2, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1239                                                 { "/opt/usr/images/hand.bin" }, 56, 56, 21, { "input" }, { "mobilenetv2/coord_refine", "mobilenetv2/gesture" },
1240                                                 { "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_lite_224.tflite" },
1241                                                 { 55, 39, 51, 40, 50, 42, 61, 43, 71, 39,
1242                                                   78, 36, 82, 42, 82, 44, 83, 45, 35, 37,
1243                                                   61, 36, 59, 36, 52, 39, 35, 32, 40, 34,
1244                                                   62, 39, 70, 40, 58, 41, 34, 42, 34, 41,
1245                                                   38, 38, 12 }),
1246
1247                                 // mobilenet based image classification test
1248                                 ParamType_Infer(
1249                                                 "one", INFERENCE_TARGET_GPU,
1250                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1251                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1252                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1253                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1254                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1255                                                 { 3 }),
1256                                 // quantized mobilenet based image classification test
1257                                 ParamType_Infer(
1258                                                 "one", INFERENCE_TARGET_GPU,
1259                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1260                                                 INFERENCE_TENSOR_DATA_TYPE_UINT8,
1261                                                 { "/opt/usr/images/image_classification_q.bin" }, 224,
1262                                                 224, 3, { "input" },
1263                                                 { "MobilenetV1/Predictions/Reshape_1" },
1264                                                 { "/usr/share/capi-media-vision/models/IC_Q/tflite/ic_tflite_q_model.tflite" },
1265                                                 { 955 }),
1266                                 // object detection test
1267                                 ParamType_Infer(
1268                                                 "one", INFERENCE_TARGET_GPU, TEST_OBJECT_DETECTION,
1269                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1270                                                 { "/opt/usr/images/object_detection.bin" }, 300, 300, 3,
1271                                                 { "normalized_input_image_tensor" },
1272                                                 { "TFLite_Detection_PostProcess",
1273                                                   "TFLite_Detection_PostProcess:1",
1274                                                   "TFLite_Detection_PostProcess:2",
1275                                                   "TFLite_Detection_PostProcess:3" },
1276                                                 { "/usr/share/capi-media-vision/models/OD/tflite/od_tflite_model.tflite" },
1277                                                 { 451, 474, 714, 969 }),
1278                                 // face detection test
1279                                 ParamType_Infer(
1280                                                 "one", INFERENCE_TARGET_GPU, TEST_FACE_DETECTION, INFERENCE_ITERATION,
1281                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1282                                                 { "/opt/usr/images/face_detection.bin" }, 300, 300, 3,
1283                                                 { "normalized_input_image_tensor" },
1284                                                 { "TFLite_Detection_PostProcess",
1285                                                   "TFLite_Detection_PostProcess:1",
1286                                                   "TFLite_Detection_PostProcess:2",
1287                                                   "TFLite_Detection_PostProcess:3" },
1288                                                 { "/usr/share/capi-media-vision/models/FD/tflite/fd_tflite_model1.tflite" },
1289                                                 { 727, 225, 960, 555 }),
1290                                 // pose estimation test
1291                                 ParamType_Infer(
1292                                                 "one", INFERENCE_TARGET_GPU, TEST_POSE_ESTIMATION,
1293                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1294                                                 { "/opt/usr/images/pose_estimation.bin" }, 192, 192, 3,
1295                                                 { "image" },
1296                                                 { "Convolutional_Pose_Machine/stage_5_out" },
1297                                                 { "/usr/share/capi-media-vision/models/PE/tflite/ped_tflite_model.tflite" },
1298                                                 { 382, 351, 320, 257, 226, 414, 414, 445, 351, 351,
1299                                                   351, 382, 382, 382, 76,  146, 170, 193, 216, 146,
1300                                                   123, 99,  287, 381, 451, 287, 381, 475 }),
1301                                 // Hand gesture model 1 from AIC
1302                                 ParamType_Infer("one", INFERENCE_TARGET_GPU, TEST_AIC_HAND_GESTURE_1, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1303                                                 { "/opt/usr/images/hand.bin" }, 224, 224, 3, { "input" }, { "mobilenetv2/boundingbox", "mobilenetv2/heatmap" },
1304                                                 { "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_lite_224.tflite" }, { 0 }),
1305                                 // Hand gesture model 2 from AIC
1306                                 ParamType_Infer("one", INFERENCE_TARGET_GPU, TEST_AIC_HAND_GESTURE_2, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1307                                                 { "/opt/usr/images/hand.bin" }, 56, 56, 21, { "input" }, { "mobilenetv2/coord_refine", "mobilenetv2/gesture" },
1308                                                 { "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_lite_224.tflite" },
1309                                                 { 55, 39, 51, 40, 50, 42, 61, 43, 71, 39,
1310                                                   78, 36, 82, 42, 82, 44, 83, 45, 35, 37,
1311                                                   61, 36, 59, 36, 52, 39, 35, 32, 40, 34,
1312                                                   62, 39, 70, 40, 58, 41, 34, 42, 34, 41,
1313                                                   38, 38, 12 }),
1314
1315                                 /*********************************************************************************/
1316                                 // parameter order : backend name, target device, input image path/s, height, width, channel count, input layer names, output layer names, model path/s, inference result
1317                                 // mobilenet based image classification test
1318                                 // TFLITE via MLAPI.
1319                                 ParamType_Infer(
1320                                                 "one", INFERENCE_TARGET_CPU,
1321                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1322                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1323                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1324                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1325                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1326                                                 { 3 }),
1327                                 // quantized mobilenet based image classification test
1328                                 ParamType_Infer(
1329                                                 "one", INFERENCE_TARGET_CPU,
1330                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1331                                                 INFERENCE_TENSOR_DATA_TYPE_UINT8,
1332                                                 { "/opt/usr/images/image_classification_q.bin" }, 224,
1333                                                 224, 3, { "input" },
1334                                                 { "MobilenetV1/Predictions/Reshape_1" },
1335                                                 { "/usr/share/capi-media-vision/models/IC_Q/tflite/ic_tflite_q_model.tflite" },
1336                                                 { 955 }),
1337                                 // object detection test
1338                                 ParamType_Infer(
1339                                                 "one", INFERENCE_TARGET_CPU, TEST_OBJECT_DETECTION,
1340                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1341                                                 { "/opt/usr/images/object_detection.bin" }, 300, 300, 3,
1342                                                 { "normalized_input_image_tensor" },
1343                                                 { "TFLite_Detection_PostProcess",
1344                                                   "TFLite_Detection_PostProcess:1",
1345                                                   "TFLite_Detection_PostProcess:2",
1346                                                   "TFLite_Detection_PostProcess:3" },
1347                                                 { "/usr/share/capi-media-vision/models/OD/tflite/od_tflite_model.tflite" },
1348                                                 { 451, 474, 714, 969 }),
1349                                 // face detection test
1350                                 ParamType_Infer(
1351                                                 "one", INFERENCE_TARGET_CPU, TEST_FACE_DETECTION, INFERENCE_ITERATION,
1352                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1353                                                 { "/opt/usr/images/face_detection.bin" }, 300, 300, 3,
1354                                                 { "normalized_input_image_tensor" },
1355                                                 { "TFLite_Detection_PostProcess",
1356                                                   "TFLite_Detection_PostProcess:1",
1357                                                   "TFLite_Detection_PostProcess:2",
1358                                                   "TFLite_Detection_PostProcess:3" },
1359                                                 { "/usr/share/capi-media-vision/models/FD/tflite/fd_tflite_model1.tflite" },
1360                                                 { 727, 225, 960, 555 }),
1361                                 // pose estimation test
1362                                 ParamType_Infer(
1363                                                 "one", INFERENCE_TARGET_CPU, TEST_POSE_ESTIMATION,
1364                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1365                                                 { "/opt/usr/images/pose_estimation.bin" }, 192, 192, 3,
1366                                                 { "image" },
1367                                                 { "Convolutional_Pose_Machine/stage_5_out" },
1368                                                 { "/usr/share/capi-media-vision/models/PE/tflite/ped_tflite_model.tflite" },
1369                                                 { 382, 351, 320, 257, 226, 414, 414, 445, 351, 351,
1370                                                   351, 382, 382, 382, 76,  146, 170, 193, 216, 146,
1371                                                   123, 99,  287, 381, 451, 287, 381, 475 }),
1372                                 // Hand gesture model 1 from AIC
1373                                 ParamType_Infer("one", INFERENCE_TARGET_CPU, TEST_AIC_HAND_GESTURE_1, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1374                                                 { "/opt/usr/images/hand.bin" }, 224, 224, 3, { "input" }, { "mobilenetv2/boundingbox", "mobilenetv2/heatmap" },
1375                                                 { "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_lite_224.tflite" }, { 0 }),
1376                                 // Hand gesture model 2 from AIC
1377                                 ParamType_Infer("one", INFERENCE_TARGET_CPU, TEST_AIC_HAND_GESTURE_2, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1378                                                 { "/opt/usr/images/hand.bin" }, 56, 56, 21, { "input" }, { "mobilenetv2/coord_refine", "mobilenetv2/gesture" },
1379                                                 { "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_lite_224.tflite" },
1380                                                 { 55, 39, 51, 40, 50, 42, 61, 43, 71, 39,
1381                                                   78, 36, 82, 42, 82, 44, 83, 45, 35, 37,
1382                                                   61, 36, 59, 36, 52, 39, 35, 32, 40, 34,
1383                                                   62, 39, 70, 40, 58, 41, 34, 42, 34, 41,
1384                                                   38, 38, 12 }),
1385
1386                                 // mobilenet based image classification test
1387                                 ParamType_Infer(
1388                                                 "one", INFERENCE_TARGET_GPU,
1389                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1390                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1391                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1392                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1393                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1394                                                 { 3 }),
1395
1396                                 // quantized mobilenet based image classification test
1397                                 ParamType_Infer(
1398                                                 "one", INFERENCE_TARGET_GPU,
1399                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1400                                                 INFERENCE_TENSOR_DATA_TYPE_UINT8,
1401                                                 { "/opt/usr/images/image_classification_q.bin" }, 224,
1402                                                 224, 3, { "input" },
1403                                                 { "MobilenetV1/Predictions/Reshape_1" },
1404                                                 { "/usr/share/capi-media-vision/models/IC_Q/tflite/ic_tflite_q_model.tflite" },
1405                                                 { 955 }),
1406
1407                                 // object detection test
1408                                 ParamType_Infer(
1409                                                 "one", INFERENCE_TARGET_GPU, TEST_OBJECT_DETECTION,
1410                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1411                                                 { "/opt/usr/images/object_detection.bin" }, 300, 300, 3,
1412                                                 { "normalized_input_image_tensor" },
1413                                                 { "TFLite_Detection_PostProcess",
1414                                                   "TFLite_Detection_PostProcess:1",
1415                                                   "TFLite_Detection_PostProcess:2",
1416                                                   "TFLite_Detection_PostProcess:3" },
1417                                                 { "/usr/share/capi-media-vision/models/OD/tflite/od_tflite_model.tflite" },
1418                                                 { 451, 474, 714, 969 }),
1419
1420                                 // face detection test
1421                                 ParamType_Infer(
1422                                                 "one", INFERENCE_TARGET_GPU, TEST_FACE_DETECTION, INFERENCE_ITERATION,
1423                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1424                                                 { "/opt/usr/images/face_detection.bin" }, 300, 300, 3,
1425                                                 { "normalized_input_image_tensor" },
1426                                                 { "TFLite_Detection_PostProcess",
1427                                                   "TFLite_Detection_PostProcess:1",
1428                                                   "TFLite_Detection_PostProcess:2",
1429                                                   "TFLite_Detection_PostProcess:3" },
1430                                                 { "/usr/share/capi-media-vision/models/FD/tflite/fd_tflite_model1.tflite" },
1431                                                 { 727, 225, 960, 555 }),
1432
1433                                 // pose estimation test
1434                                 ParamType_Infer(
1435                                                 "one", INFERENCE_TARGET_GPU, TEST_POSE_ESTIMATION,
1436                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1437                                                 { "/opt/usr/images/pose_estimation.bin" }, 192, 192, 3,
1438                                                 { "image" },
1439                                                 { "Convolutional_Pose_Machine/stage_5_out" },
1440                                                 { "/usr/share/capi-media-vision/models/PE/tflite/ped_tflite_model.tflite" },
1441                                                 { 382, 351, 320, 257, 226, 414, 414, 445, 351, 351,
1442                                                   351, 382, 382, 382, 76,  146, 170, 193, 216, 146,
1443                                                   123, 99,  287, 381, 451, 287, 381, 475 }),
1444                                 // Hand gesture model 1 from AIC
1445                                 ParamType_Infer("one", INFERENCE_TARGET_GPU, TEST_AIC_HAND_GESTURE_1, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1446                                                 { "/opt/usr/images/hand.bin" }, 224, 224, 3, { "input" }, { "mobilenetv2/boundingbox", "mobilenetv2/heatmap" },
1447                                                 { "/usr/share/capi-media-vision/models/PE_1/tflite/posenet1_lite_224.tflite" }, { 0 }),
1448                                 // Hand gesture model 2 from AIC
1449                                 ParamType_Infer("one", INFERENCE_TARGET_GPU, TEST_AIC_HAND_GESTURE_2, INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1450                                                 { "/opt/usr/images/hand.bin" }, 56, 56, 21, { "input" }, { "mobilenetv2/coord_refine", "mobilenetv2/gesture" },
1451                                                 { "/usr/share/capi-media-vision/models/PE_2/tflite/posenet2_lite_224.tflite" },
1452                                                 { 55, 39, 51, 40, 50, 42, 61, 43, 71, 39,
1453                                                   78, 36, 82, 42, 82, 44, 83, 45, 35, 37,
1454                                                   61, 36, 59, 36, 52, 39, 35, 32, 40, 34,
1455                                                   62, 39, 70, 40, 58, 41, 34, 42, 34, 41,
1456                                                   38, 38, 12 })
1457                                 /* TODO */
1458                                 ));
1459
1460 INSTANTIATE_TEST_CASE_P(
1461                 Opensource, InferenceEngineTfliteCLTunerTest,
1462                 testing::Values(
1463                                 // parameter order : backend name, target device, CLTuner active flag, CLTuner update flag, CLTuner tuning mode, input image path/s, height, width, channel count, input layer names, output layer names, model path/s, inference result
1464                                 // mobilenet based image classification test
1465                                 // ARMNN.
1466                                 ParamType_CLTuner(
1467                                                 "armnn", INFERENCE_TARGET_GPU, true, true, INFERENCE_ENGINE_CLTUNER_RAPID,
1468                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1469                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1470                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1471                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1472                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1473                                                 { 3 }),
1474                                 ParamType_CLTuner(
1475                                                 "armnn", INFERENCE_TARGET_GPU, true, false, INFERENCE_ENGINE_CLTUNER_READ,
1476                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1477                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1478                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1479                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1480                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1481                                                 { 3 }),
1482                                 ParamType_CLTuner(
1483                                                 "armnn", INFERENCE_TARGET_GPU, true, true, INFERENCE_ENGINE_CLTUNER_NORMAL,
1484                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1485                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1486                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1487                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1488                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1489                                                 { 3 }),
1490                                 ParamType_CLTuner(
1491                                                 "armnn", INFERENCE_TARGET_GPU, true, false, INFERENCE_ENGINE_CLTUNER_READ,
1492                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1493                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1494                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1495                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1496                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1497                                                 { 3 }),
1498                                 ParamType_CLTuner(
1499                                                 "armnn", INFERENCE_TARGET_GPU, true, true, INFERENCE_ENGINE_CLTUNER_EXHAUSTIVE,
1500                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1501                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1502                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1503                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1504                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1505                                                 { 3 }),
1506                                 ParamType_CLTuner(
1507                                                 "armnn", INFERENCE_TARGET_GPU, true, false, INFERENCE_ENGINE_CLTUNER_READ,
1508                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1509                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1510                                                 { "/opt/usr/images/image_classification.bin" }, 224,
1511                                                 224, 3, { "input_2" }, { "dense_3/Softmax" },
1512                                                 { "/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite" },
1513                                                 { 3 })
1514                                 /* TODO */
1515                                 ));
1516
1517 INSTANTIATE_TEST_CASE_P(
1518                 Opensource, InferenceEngineCaffeTest,
1519                 testing::Values(
1520                                 // parameter order : backend_name, target_devices, test_type, iteration, tensor_type, image_paths, height, width, ch, input_layers, output_layers, model_paths, answers
1521                                 // OPENCV
1522                                 // squeezenet based image classification test
1523                                 ParamType_Infer(
1524                                                 "opencv", INFERENCE_TARGET_CPU,
1525                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1526                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1527                                                 { "/opt/usr/images/image_classification_caffe.bin" },
1528                                                 227, 227, 3, { "data" }, { "prob" },
1529                                                 { "/usr/share/capi-media-vision/models/IC/caffe/ic_caffe_model_squeezenet.caffemodel",
1530                                                   "/usr/share/capi-media-vision/models/IC/caffe/ic_caffe_model_squeezenet.prototxt" },
1531                                                 { 281 }),
1532                                 ParamType_Infer(
1533                                                 "opencv", INFERENCE_TARGET_GPU,
1534                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1535                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1536                                                 { "/opt/usr/images/image_classification_caffe.bin" },
1537                                                 227, 227, 3, { "data" }, { "prob" },
1538                                                 { "/usr/share/capi-media-vision/models/IC/caffe/ic_caffe_model_squeezenet.caffemodel",
1539                                                   "/usr/share/capi-media-vision/models/IC/caffe/ic_caffe_model_squeezenet.prototxt" },
1540                                                 { 281 }),
1541
1542                                 // mobilenet-ssd based object detection test
1543                                 ParamType_Infer(
1544                                                 "opencv", INFERENCE_TARGET_CPU, TEST_OBJECT_DETECTION,
1545                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1546                                                 { "/opt/usr/images/object_detection_caffe.bin" }, 300,
1547                                                 300, 3, { "data" }, { "detection_out" },
1548                                                 { "/usr/share/capi-media-vision/models/OD/caffe/od_caffe_model_mobilenetv1ssd.caffemodel",
1549                                                   "/usr/share/capi-media-vision/models/OD/caffe/od_caffe_model_mobilenetv1ssd.prototxt" },
1550                                                 { 15, 19, 335, 557 }),
1551                                 ParamType_Infer(
1552                                                 "opencv", INFERENCE_TARGET_GPU, TEST_OBJECT_DETECTION,
1553                                                 INFERENCE_ITERATION, INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1554                                                 { "/opt/usr/images/object_detection_caffe.bin" }, 300,
1555                                                 300, 3, { "data" }, { "detection_out" },
1556                                                 { "/usr/share/capi-media-vision/models/OD/caffe/od_caffe_model_mobilenetv1ssd.caffemodel",
1557                                                   "/usr/share/capi-media-vision/models/OD/caffe/od_caffe_model_mobilenetv1ssd.prototxt" },
1558                                                 { 15, 19, 335, 557 }),
1559
1560                                 // mobilenet-ssd based object detection test
1561                                 ParamType_Infer(
1562                                                 "opencv", INFERENCE_TARGET_CPU, TEST_FACE_DETECTION, INFERENCE_ITERATION,
1563                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1564                                                 { "/opt/usr/images/face_detection_caffe.bin" }, 300,
1565                                                 300, 3, { "data" }, { "detection_out" },
1566                                                 { "/usr/share/capi-media-vision/models/FD/caffe/fd_caffe_model_resnet10ssd.caffemodel",
1567                                                   "/usr/share/capi-media-vision/models/FD/caffe/fd_caffe_model_resnet10ssd.prototxt" },
1568                                                 { 733, 233, 965, 539 }),
1569                                 ParamType_Infer(
1570                                                 "opencv", INFERENCE_TARGET_GPU, TEST_FACE_DETECTION, INFERENCE_ITERATION,
1571                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1572                                                 { "/opt/usr/images/face_detection_caffe.bin" }, 300,
1573                                                 300, 3, { "data" }, { "detection_out" },
1574                                                 { "/usr/share/capi-media-vision/models/FD/caffe/fd_caffe_model_resnet10ssd.caffemodel",
1575                                                   "/usr/share/capi-media-vision/models/FD/caffe/fd_caffe_model_resnet10ssd.prototxt" },
1576                                                 { 733, 233, 965, 539 }),
1577
1578                                 // tweakcnn based facial landmark detection test
1579                                 ParamType_Infer(
1580                                                 "opencv", INFERENCE_TARGET_CPU,
1581                                                 TEST_FACIAL_LANDMARK_DETECTION, INFERENCE_ITERATION,
1582                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1583                                                 { "/opt/usr/images/faciallandmark_detection_caffe.bin" },
1584                                                 128, 128, 3, { "data" }, { "Sigmoid_fc2" },
1585                                                 { "/usr/share/capi-media-vision/models/FLD/caffe/fld_caffe_model_tweak.caffemodel",
1586                                                   "/usr/share/capi-media-vision/models/FLD/caffe/fld_caffe_model_tweak.prototxt" },
1587                                                 { 53, 45, 85, 46, 66, 64, 54, 78, 82, 79 }),
1588                                 ParamType_Infer(
1589                                                 "opencv", INFERENCE_TARGET_GPU,
1590                                                 TEST_FACIAL_LANDMARK_DETECTION, INFERENCE_ITERATION,
1591                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1592                                                 { "/opt/usr/images/faciallandmark_detection_caffe.bin" },
1593                                                 128, 128, 3, { "data" }, { "Sigmoid_fc2" },
1594                                                 { "/usr/share/capi-media-vision/models/FLD/caffe/fld_caffe_model_tweak.caffemodel",
1595                                                   "/usr/share/capi-media-vision/models/FLD/caffe/fld_caffe_model_tweak.prototxt" },
1596                                                 { 53, 45, 85, 46, 66, 64, 54, 78, 82, 79 })
1597                                 /* TODO */
1598                                 ));
1599
1600 INSTANTIATE_TEST_CASE_P(
1601                 Opensource, InferenceEngineDldtTest,
1602                 testing::Values(
1603                                 // DLDT
1604                                 ParamType_Infer(
1605                                                 "dldt", INFERENCE_TARGET_CUSTOM,
1606                                                 TEST_IMAGE_CLASSIFICATION, INFERENCE_ITERATION,
1607                                                 INFERENCE_TENSOR_DATA_TYPE_FLOAT32,
1608                                                 { "/opt/usr/images/dldt_banana_classification.bin" },
1609                                                 224, 224, 3, { "data" }, { "prob" },
1610                                                 { "/usr/share/capi-media-vision/models/IC/dldt/googlenet-v1.xml",
1611                                                   "/usr/share/capi-media-vision/models/IC/dldt/googlenet-v1.bin" },
1612                                                 { 954 })));