1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
5 // Copyright (C) 2018-2019, Intel Corporation, all rights reserved.
6 // Third party copyrights are property of their respective owners.
9 #include "test_precomp.hpp"
10 #include "npy_blob.hpp"
11 #include <opencv2/dnn/shape_utils.hpp>
12 namespace opencv_test { namespace {
14 template<typename TString>
15 static std::string _tf(TString filename, bool required = true)
17 return findDataFile(std::string("dnn/onnx/") + filename, required);
20 class Test_ONNX_layers : public DNNTestLayer
25 Test_ONNX_layers() : required(true) { }
33 void testONNXModels(const String& basename, const Extension ext = npy,
34 const double l1 = 0, const float lInf = 0, const bool useSoftmax = false,
35 bool checkNoFallbacks = true, int numInps = 1)
37 String onnxmodel = _tf("models/" + basename + ".onnx", required);
38 std::vector<Mat> inps(numInps);
41 for (int i = 0; i < numInps; ++i)
42 inps[i] = blobFromNPY(_tf("data/input_" + basename + (numInps > 1 ? format("_%d", i) : "") + ".npy"));
43 ref = blobFromNPY(_tf("data/output_" + basename + ".npy"));
46 for (int i = 0; i < numInps; ++i)
47 inps[i] = readTensorFromONNX(_tf("data/input_" + basename + (numInps > 1 ? format("_%d", i) : "") + ".pb"));
48 ref = readTensorFromONNX(_tf("data/output_" + basename + ".pb"));
51 CV_Error(Error::StsUnsupportedFormat, "Unsupported extension");
53 checkBackend(&inps[0], &ref);
54 Net net = readNetFromONNX(onnxmodel);
55 ASSERT_FALSE(net.empty());
57 net.setPreferableBackend(backend);
58 net.setPreferableTarget(target);
60 std::vector<String> inputNames;
61 for (int i = 0; i < numInps; ++i)
62 inputNames.push_back(format("%d", i));
63 net.setInputsNames(inputNames);
65 for (int i = 0; i < numInps; ++i)
66 net.setInput(inps[i], inputNames[i]);
67 Mat out = net.forward("");
73 netSoftmax.addLayerToPrev("softmaxLayer", "Softmax", lp);
74 netSoftmax.setPreferableBackend(DNN_BACKEND_OPENCV);
76 netSoftmax.setInput(out);
77 out = netSoftmax.forward();
79 netSoftmax.setInput(ref);
80 ref = netSoftmax.forward();
82 normAssert(ref, out, "", l1 ? l1 : default_l1, lInf ? lInf : default_lInf);
84 expectNoFallbacksFromIE(net);
88 TEST_P(Test_ONNX_layers, InstanceNorm)
90 if(backend == DNN_BACKEND_CUDA)
91 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); /* MVN is not supported */
93 if (target == DNN_TARGET_MYRIAD)
94 testONNXModels("instancenorm", npy, 0, 0, false, false);
96 testONNXModels("instancenorm", npy);
99 TEST_P(Test_ONNX_layers, MaxPooling)
101 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2020020000)
102 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
103 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
105 testONNXModels("maxpooling", npy, 0, 0, false, false);
107 TEST_P(Test_ONNX_layers, MaxPooling_2)
109 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
110 // IE exception: Cannot get memory!
111 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
112 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
115 testONNXModels("two_maxpooling", npy, 0, 0, false, false);
118 TEST_P(Test_ONNX_layers, Convolution)
120 testONNXModels("convolution");
121 testONNXModels("conv_asymmetric_pads");
124 TEST_P(Test_ONNX_layers, Convolution_variable_weight)
126 if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH ||
127 backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019) && target == DNN_TARGET_MYRIAD)
128 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
130 if (backend == DNN_BACKEND_CUDA)
131 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); // not supported
132 if (backend == DNN_BACKEND_VKCOM)
133 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN); // not supported
134 String basename = "conv_variable_w";
135 Net net = readNetFromONNX(_tf("models/" + basename + ".onnx"));
136 ASSERT_FALSE(net.empty());
138 net.setPreferableBackend(backend);
139 net.setPreferableTarget(target);
141 for (int i = 0; i < 2; i++)
143 Mat input = blobFromNPY(_tf("data/input_" + basename + format("_%d", i) + "_0.npy"));
144 Mat weights = blobFromNPY(_tf("data/input_" + basename + format("_%d", i) + "_1.npy"));
145 Mat ref = blobFromNPY(_tf("data/output_" + basename + format("_%d", i) + ".npy"));
147 net.setInput(input, "0");
148 net.setInput(weights, "1");
150 Mat out = net.forward();
151 normAssert(ref, out, "", default_l1, default_lInf);
155 TEST_P(Test_ONNX_layers, Convolution_variable_weight_bias)
157 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
158 // openvino/src/plugins/intel_myriad/common/src/ngraph/transformations/extract_dynamic_batch/slice_convolution.cpp:14 Expecting operation v1::GroupConvolution GroupConvolution_6904725 (Reshape_17[0]:f32{1,4,5,5}, Reshape_6904719[0]:f32{4,1,1,2,2}) -> (f32{1,4,4,4}) to have constant kernel, got Reshape_6904719[0]:f32{4,1,1,2,2}
159 // openvino\src\plugins\intel_myriad\common\src\ngraph\transformations\extract_dynamic_batch\slice_convolution.cpp:15 Expecting operation v1::GroupConvolution GroupConvolution_6904692 (Reshape_17[0]:f32{1,4,5,5}, Reshape_6904686[0]:f32{4,1,1,2,2}) -> (f32{1,4,4,4}) to have constant kernel, got Reshape_6904686[0]:f32{4,1,1,2,2}
160 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
161 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
162 // accuracy (depends on OpenCL version / HW)
163 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
164 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
165 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
167 #elif defined(INF_ENGINE_RELEASE)
168 if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH ||
169 backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019) && target == DNN_TARGET_MYRIAD)
170 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
172 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU &&
173 getInferenceEngineCPUType() == CV_DNN_INFERENCE_ENGINE_CPU_TYPE_ARM_COMPUTE)
174 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_ARM_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
177 if (backend == DNN_BACKEND_CUDA)
178 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); // supports only <= 2 inputs
180 if (backend == DNN_BACKEND_VKCOM)
181 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN); // not supported
183 String basename = "conv_variable_wb";
184 Net net = readNetFromONNX(_tf("models/" + basename + ".onnx"));
185 ASSERT_FALSE(net.empty());
187 net.setPreferableBackend(backend);
188 net.setPreferableTarget(target);
190 for (int i = 0; i < 2; i++)
192 Mat input = blobFromNPY(_tf("data/input_" + basename + format("_%d", i) + "_0.npy"));
193 Mat weights = blobFromNPY(_tf("data/input_" + basename + format("_%d", i) + "_1.npy"));
194 Mat bias = blobFromNPY(_tf("data/input_" + basename + format("_%d", i) + "_2.npy"));
195 Mat ref = blobFromNPY(_tf("data/output_" + basename + format("_%d", i) + ".npy"));
197 net.setInput(input, "0");
198 net.setInput(weights, "1");
199 net.setInput(bias, "bias");
201 Mat out = net.forward();
202 normAssert(ref, out, "", default_l1, default_lInf);
206 TEST_P(Test_ONNX_layers, Gather)
208 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
209 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
210 testONNXModels("gather", npy, 0, 0, false, false);
211 testONNXModels("gather_scalar", npy, 0, 0, false, false);
214 TEST_P(Test_ONNX_layers, GatherMulti)
216 // GPU plugin unsupported slice for constant
217 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
218 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
219 testONNXModels("gather_multi", npy, 0, 0, false, false);
222 TEST_P(Test_ONNX_layers, Convolution3D)
224 if (backend == DNN_BACKEND_CUDA && target == DNN_TARGET_CUDA_FP16)
226 // CUDA_FP16: cuDNN did not return a suitable algorithm for convolution.
227 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
229 testONNXModels("conv3d");
232 TEST_P(Test_ONNX_layers, Convolution3D_bias)
234 if (backend == DNN_BACKEND_CUDA && target == DNN_TARGET_CUDA_FP16)
236 // CUDA_FP16: cuDNN did not return a suitable algorithm for convolution.
237 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
239 testONNXModels("conv3d_bias");
242 TEST_P(Test_ONNX_layers, Two_convolution)
244 #if defined(INF_ENGINE_RELEASE)
245 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD
246 && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X
248 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
250 // Reference output values are in range [-0.855, 0.611]
251 testONNXModels("two_convolution");
254 TEST_P(Test_ONNX_layers, Deconvolution)
256 testONNXModels("deconvolution", npy, 0, 0, false, false);
257 testONNXModels("two_deconvolution", npy, 0, 0, false, false);
258 testONNXModels("deconvolution_group", npy, 0, 0, false, false);
259 testONNXModels("deconvolution_output_shape", npy, 0, 0, false, false);
260 if (target != DNN_TARGET_CUDA_FP16) // bug
261 testONNXModels("deconv_adjpad_2d", npy, 0, 0, false, false);
264 TEST_P(Test_ONNX_layers, Deconvolution3D)
266 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
267 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
269 // [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/frontend/frontend.cpp:592 Failed to compile layer "2":
270 // [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/model/model.cpp:198 duplicateData error: while duplicating 2@weights Const data got different desc and content byte sizes (162 and 486 respectively)
271 if (target == DNN_TARGET_MYRIAD)
272 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
274 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
275 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
277 // [ GENERAL_ERROR ] vpu/graph_transformer/src/frontend/frontend.cpp:439 Failed to compile layer "2":
278 // [ GENERAL_ERROR ] vpu/graph_transformer/src/model/model.cpp:198 duplicateData error: while duplicating 2@weights Const data got different desc and content byte sizes (162 and 486 respectively)
279 if (target == DNN_TARGET_MYRIAD)
280 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
284 if (backend == DNN_BACKEND_OPENCV)
285 throw SkipTestException("OpenCV backend is not supported"); // FIXIT use tags
287 if (backend == DNN_BACKEND_VKCOM)
288 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
290 testONNXModels("deconv3d");
293 TEST_P(Test_ONNX_layers, Deconvolution3D_bias)
295 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
296 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
298 // [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/frontend/frontend.cpp:592 Failed to compile layer "3":
299 // [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/model/model.cpp:198 duplicateData error: while duplicating 3@weights Const data got different desc and content byte sizes (270 and 810 respectively)
300 if (target == DNN_TARGET_MYRIAD)
301 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
303 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
304 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
306 // [ GENERAL_ERROR ] vpu/graph_transformer/src/frontend/frontend.cpp:439 Failed to compile layer "2":
307 // [ GENERAL_ERROR ] vpu/graph_transformer/src/model/model.cpp:198 duplicateData error: while duplicating 2@weights Const data got different desc and content byte sizes (162 and 486 respectively)
308 if (target == DNN_TARGET_MYRIAD)
309 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
313 if (backend == DNN_BACKEND_OPENCV)
314 throw SkipTestException("OpenCV backend is not supported"); // FIXIT use tags
316 if (backend == DNN_BACKEND_VKCOM)
317 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
319 testONNXModels("deconv3d_bias");
322 TEST_P(Test_ONNX_layers, Deconvolution3D_pad)
324 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
325 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
327 // [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/frontend/frontend.cpp:592 Failed to compile layer "3":
328 // [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/model/model.cpp:198 duplicateData error: while duplicating 3@weights Const data got different desc and content byte sizes (108 and 432 respectively)
329 if (target == DNN_TARGET_MYRIAD)
330 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
332 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
333 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
335 // [ GENERAL_ERROR ] vpu/graph_transformer/src/frontend/frontend.cpp:439 Failed to compile layer "2":
336 // [ GENERAL_ERROR ] vpu/graph_transformer/src/model/model.cpp:198 duplicateData error: while duplicating 2@weights Const data got different desc and content byte sizes (162 and 486 respectively)
337 if (target == DNN_TARGET_MYRIAD)
338 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
342 if (backend == DNN_BACKEND_OPENCV)
343 throw SkipTestException("OpenCV backend is not supported"); // FIXIT use tags
345 if (backend == DNN_BACKEND_VKCOM)
346 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
348 testONNXModels("deconv3d_pad");
351 TEST_P(Test_ONNX_layers, Deconvolution3D_adjpad)
353 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
354 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
356 // [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/frontend/frontend.cpp:592 Failed to compile layer "3":
357 // [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/model/model.cpp:198 duplicateData error: while duplicating 3@weights Const data got different desc and content byte sizes (90 and 180 respectively)
358 if (target == DNN_TARGET_MYRIAD)
359 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
361 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
362 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
364 // [ GENERAL_ERROR ] vpu/graph_transformer/src/frontend/frontend.cpp:439 Failed to compile layer "2":
365 // [ GENERAL_ERROR ] vpu/graph_transformer/src/model/model.cpp:198 duplicateData error: while duplicating 2@weights Const data got different desc and content byte sizes (162 and 486 respectively)
366 if (target == DNN_TARGET_MYRIAD)
367 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
371 if (backend == DNN_BACKEND_OPENCV)
372 throw SkipTestException("OpenCV backend is not supported"); // FIXIT use tags
374 if (backend == DNN_BACKEND_VKCOM)
375 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
377 testONNXModels("deconv3d_adjpad");
380 TEST_P(Test_ONNX_layers, Dropout)
382 testONNXModels("dropout");
385 TEST_P(Test_ONNX_layers, Linear)
387 if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
388 applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
389 testONNXModels("linear");
392 TEST_P(Test_ONNX_layers, ReLU)
394 testONNXModels("ReLU");
397 TEST_P(Test_ONNX_layers, PReLU)
399 testONNXModels("PReLU_slope");
402 TEST_P(Test_ONNX_layers, Clip)
404 testONNXModels("clip", npy);
407 TEST_P(Test_ONNX_layers, Clip_init)
409 testONNXModels("clip_init_min_max");
410 testONNXModels("clip_init_min");
411 testONNXModels("clip_init_max");
414 TEST_P(Test_ONNX_layers, Shape)
416 testONNXModels("shape_of_constant");
419 TEST_P(Test_ONNX_layers, ReduceMean)
421 testONNXModels("reduce_mean");
422 testONNXModels("reduce_mean_axis1");
423 testONNXModels("reduce_mean_axis2");
426 TEST_P(Test_ONNX_layers, ReduceSum)
428 testONNXModels("reduce_sum");
429 testONNXModels("reduce_sum_axis_dynamic_batch");
432 TEST_P(Test_ONNX_layers, ReduceMax)
434 testONNXModels("reduce_max");
436 TEST_P(Test_ONNX_layers, ReduceMax_axis_0)
438 testONNXModels("reduce_max_axis_0");
440 TEST_P(Test_ONNX_layers, ReduceMax_axis_1)
442 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
443 // [ GENERAL_ERROR ] AssertionFailed: !out.networkInputs.empty()
444 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
445 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
447 testONNXModels("reduce_max_axis_1");
450 TEST_P(Test_ONNX_layers, Min)
452 testONNXModels("min", npy, 0, 0, false, true, 2);
455 TEST_P(Test_ONNX_layers, ArgLayer)
457 if (backend != DNN_BACKEND_OPENCV || target != DNN_TARGET_CPU)
458 throw SkipTestException("Only CPU is supported"); // FIXIT use tags
460 testONNXModels("argmax");
461 testONNXModels("argmin");
464 TEST_P(Test_ONNX_layers, Scale)
466 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
467 // accuracy (inf/nan)
468 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
469 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
470 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
472 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
473 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
474 // IE exception: mkldnn_node.cpp:238 Ngraph operation Reshape with name ReduceMean_0 has dynamic output shape on 0 port, but CPU plug-in supports only static shape
475 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
476 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
477 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
479 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
480 // Ngraph operation Reshape with name ReduceMean_0 has dynamic output shape on 0 port, but CPU plug-in supports only static shape
481 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL)
482 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
483 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
484 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
486 testONNXModels("scale");
489 TEST_P(Test_ONNX_layers, Scale_broadcast)
491 if (backend == DNN_BACKEND_CUDA)
492 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); // doesn't support broadcasting
493 testONNXModels("scale_broadcast", npy, 0, 0, false, true, 3);
496 TEST_P(Test_ONNX_layers, Scale_broadcast_mid)
498 if (backend == DNN_BACKEND_CUDA)
499 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); // doesn't support broadcasting
500 testONNXModels("scale_broadcast_mid", npy, 0, 0, false, true, 2);
503 TEST_P(Test_ONNX_layers, ReduceMean3D)
505 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
506 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
507 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
508 else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
509 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
511 if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
512 throw SkipTestException("Only CPU is supported"); // FIXIT use tags
514 if (backend == DNN_BACKEND_VKCOM)
515 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
517 testONNXModels("reduce_mean3d");
520 TEST_P(Test_ONNX_layers, MaxPooling_Sigmoid)
522 testONNXModels("maxpooling_sigmoid");
525 TEST_P(Test_ONNX_layers, Cast)
527 testONNXModels("cast");
530 TEST_P(Test_ONNX_layers, Power)
532 testONNXModels("pow2", npy, 0, 0, false, false);
535 TEST_P(Test_ONNX_layers, Exp)
537 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
538 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
539 testONNXModels("exp");
542 TEST_P(Test_ONNX_layers, Elementwise_Ceil)
544 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
545 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
546 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
547 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
548 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
550 testONNXModels("ceil");
553 TEST_P(Test_ONNX_layers, Elementwise_Floor)
555 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
556 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
557 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
558 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
559 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
561 testONNXModels("floor");
564 TEST_P(Test_ONNX_layers, Elementwise_Log)
566 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
567 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
568 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
569 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
570 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
572 testONNXModels("log");
575 TEST_P(Test_ONNX_layers, Elementwise_Round)
577 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
578 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
579 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
580 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
581 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
583 testONNXModels("round");
586 TEST_P(Test_ONNX_layers, Elementwise_Sqrt)
588 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
589 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
590 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
591 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
592 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
593 testONNXModels("sqrt");
597 TEST_P(Test_ONNX_layers, Elementwise_not)
599 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
600 // Cannot get memory!
601 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
602 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
603 // Cannot get memory!
604 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
605 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
606 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
608 // Cannot get memory!
609 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
610 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
611 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
612 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
613 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
614 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
615 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
617 testONNXModels("not");
620 TEST_P(Test_ONNX_layers, Compare_EQ)
622 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
623 // Cannot get memory!
624 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
625 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
626 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
627 // IE exception: Function contains several inputs and outputs with one friendly name!
628 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
629 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
630 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
632 // IE exception: Function contains several inputs and outputs with one friendly name!
633 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
634 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
635 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
636 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
637 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
638 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
639 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
642 testONNXModels("equal");
645 TEST_P(Test_ONNX_layers, Compare_GT)
647 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
648 // Cannot get memory!
649 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
650 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
651 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
652 // IE exception: Function contains several inputs and outputs with one friendly name!
653 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
654 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
655 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
657 // IE exception: Function contains several inputs and outputs with one friendly name!
658 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
659 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
660 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
661 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
662 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
663 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
664 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
667 testONNXModels("greater");
670 TEST_P(Test_ONNX_layers, Compare_LT)
672 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
673 // Cannot get memory!
674 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
675 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
676 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
677 // IE exception: Function contains several inputs and outputs with one friendly name!
678 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
679 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
680 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
682 // IE exception: Function contains several inputs and outputs with one friendly name!
683 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
684 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
685 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
686 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
687 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
688 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
689 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
692 testONNXModels("less");
695 TEST_P(Test_ONNX_layers, Compare_GTorEQ)
697 testONNXModels("greater_or_equal");
700 TEST_P(Test_ONNX_layers, Compare_LEorEQ)
702 testONNXModels("less_or_equal");
705 TEST_P(Test_ONNX_layers, CompareSameDims_EQ)
707 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
708 // Cannot get memory!
709 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
710 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
711 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
712 // IE exception: Function contains several inputs and outputs with one friendly name!
713 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
714 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
715 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
717 // IE exception: Function contains several inputs and outputs with one friendly name!
718 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
719 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
720 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
721 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
722 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
723 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
724 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
727 testONNXModels("equal_same_dims", npy, 0, 0, false, true, 2);
730 TEST_P(Test_ONNX_layers, CompareSameDims_GT)
732 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
733 // Cannot get memory!
734 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
735 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
736 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
737 // IE exception: Function contains several inputs and outputs with one friendly name!
738 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
739 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
740 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
742 // IE exception: Function contains several inputs and outputs with one friendly name!
743 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
744 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
745 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
746 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
747 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
748 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
749 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
752 testONNXModels("greater_same_dims", npy, 0, 0, false, true, 2);
755 TEST_P(Test_ONNX_layers, CompareSameDims_LT)
757 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
758 // Cannot get memory!
759 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
760 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
761 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
762 // IE exception: Function contains several inputs and outputs with one friendly name!
763 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
764 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
765 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
767 // IE exception: Function contains several inputs and outputs with one friendly name!
768 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
769 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
770 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
771 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
772 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
773 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
774 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
777 testONNXModels("less_same_dims", npy, 0, 0, false, true, 2);
780 TEST_P(Test_ONNX_layers, Concatenation)
782 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
784 if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
785 if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
786 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
788 testONNXModels("concatenation");
789 testONNXModels("concat_const_blobs");
792 TEST_P(Test_ONNX_layers, Eltwise3D)
794 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
795 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
796 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
797 else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
798 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
800 testONNXModels("eltwise3d");
803 TEST_P(Test_ONNX_layers, AveragePooling)
805 testONNXModels("average_pooling");
808 TEST_P(Test_ONNX_layers, MaxPooling3D)
810 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
811 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
814 if (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
815 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
816 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
818 // IE exception: [ GENERAL_ERROR ] AssertionFailed: !expired()
819 if (target == DNN_TARGET_MYRIAD)
820 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
822 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
823 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
826 if (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
827 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
828 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
830 // IE exception: [ GENERAL_ERROR ] AssertionFailed: !expired()
831 if (target == DNN_TARGET_MYRIAD)
832 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
835 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
836 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
837 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
838 else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
839 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
841 if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
842 throw SkipTestException("Only CPU is supported"); // FIXIT use tags
844 if (backend == DNN_BACKEND_VKCOM)
845 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
847 testONNXModels("max_pool3d", npy, 0, 0, false, false);
850 TEST_P(Test_ONNX_layers, AvePooling3D)
852 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
853 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
854 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
855 else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
856 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
858 if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
859 throw SkipTestException("Only CPU is supported"); // FIXIT use tags
861 if (backend == DNN_BACKEND_VKCOM)
862 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
864 testONNXModels("ave_pool3d");
867 TEST_P(Test_ONNX_layers, PoolConv3D)
869 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
870 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
871 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
872 else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
873 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
875 if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
876 throw SkipTestException("Only CPU is supported"); // FIXIT use tags
878 if (backend == DNN_BACKEND_VKCOM)
879 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
881 if (backend == DNN_BACKEND_CUDA && target == DNN_TARGET_CUDA_FP16)
883 // CUDA_FP16: cuDNN did not return a suitable algorithm for convolution.
884 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
887 testONNXModels("pool_conv_3d");
890 TEST_P(Test_ONNX_layers, BatchNormalization)
892 testONNXModels("batch_norm");
895 TEST_P(Test_ONNX_layers, BatchNormalization3D)
897 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
899 if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
900 if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
901 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
903 testONNXModels("batch_norm_3d");
906 TEST_P(Test_ONNX_layers, BatchNormalizationUnfused)
908 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021030000)
909 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
910 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
912 testONNXModels("frozenBatchNorm2d");
915 TEST_P(Test_ONNX_layers, BatchNormalizationSubgraph)
917 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021030000)
918 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
919 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
921 testONNXModels("batch_norm_subgraph");
924 TEST_P(Test_ONNX_layers, NormalizeFusionSubgraph)
926 testONNXModels("normalize_fusion");
929 TEST_P(Test_ONNX_layers, Transpose)
931 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
933 if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
934 if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
935 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
937 testONNXModels("transpose");
940 TEST_P(Test_ONNX_layers, Multiplication)
942 if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
943 applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
944 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
945 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
946 testONNXModels("mul");
949 TEST_P(Test_ONNX_layers, MatMul)
951 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
952 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
954 testONNXModels("matmul_2d");
955 testONNXModels("matmul_3d");
956 testONNXModels("matmul_4d");
959 TEST_P(Test_ONNX_layers, MatMulAdd)
961 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
963 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
964 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
965 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021010000)
966 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
967 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
969 if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
970 applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
971 testONNXModels("matmul_add");
974 TEST_P(Test_ONNX_layers, Expand)
976 testONNXModels("expand");
977 testONNXModels("expand_identity");
978 testONNXModels("expand_batch");
979 testONNXModels("expand_channels");
980 testONNXModels("expand_neg_batch");
983 TEST_P(Test_ONNX_layers, ExpandHW)
985 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
986 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
987 testONNXModels("expand_hw");
990 TEST_P(Test_ONNX_layers, Constant)
992 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2018050000)
993 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD
994 && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
995 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
997 testONNXModels("constant");
1000 TEST_P(Test_ONNX_layers, Padding)
1002 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
1003 testONNXModels("padding", npy, 0, 0, false, false);
1005 testONNXModels("padding");
1009 TEST_P(Test_ONNX_layers, Resize)
1011 testONNXModels("resize_nearest");
1012 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1013 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1014 testONNXModels("resize_bilinear");
1017 TEST_P(Test_ONNX_layers, ResizeUnfused)
1019 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1020 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1021 testONNXModels("upsample_unfused_torch1.2");
1022 testONNXModels("upsample_unfused_opset9_torch1.4");
1023 testONNXModels("resize_nearest_unfused_opset11_torch1.4");
1024 testONNXModels("resize_nearest_unfused_opset11_torch1.3");
1025 testONNXModels("resize_bilinear_unfused_opset11_torch1.4");
1028 TEST_P(Test_ONNX_layers, ResizeUnfusedTwoInputs)
1030 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1031 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1032 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1033 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1034 testONNXModels("upsample_unfused_two_inputs_opset9_torch1.4", npy, 0, 0, false, true, 2);
1035 testONNXModels("upsample_unfused_two_inputs_opset11_torch1.4", npy, 0, 0, false, true, 2);
1038 TEST_P(Test_ONNX_layers, MultyInputs)
1040 testONNXModels("multy_inputs", npy, 0, 0, false, true, 2);
1043 TEST_P(Test_ONNX_layers, Broadcast)
1045 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1046 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1047 testONNXModels("channel_broadcast", npy, 0, 0, false, true, 2);
1050 TEST_P(Test_ONNX_layers, DynamicResize)
1052 testONNXModels("dynamic_resize_9", npy, 0, 0, false, true, 2);
1053 testONNXModels("dynamic_resize_10", npy, 0, 0, false, true, 2);
1054 testONNXModels("dynamic_resize_11", npy, 0, 0, false, true, 2);
1055 testONNXModels("dynamic_resize_13", npy, 0, 0, false, true, 2);
1056 testONNXModels("dynamic_resize_scale_9", npy, 0, 0, false, true, 2);
1057 testONNXModels("dynamic_resize_scale_10", npy, 0, 0, false, true, 2);
1058 testONNXModels("dynamic_resize_scale_11", npy, 0, 0, false, true, 2);
1059 testONNXModels("dynamic_resize_scale_13", npy, 0, 0, false, true, 2);
1061 testONNXModels("resize_size_opset11");
1062 testONNXModels("resize_size_opset13");
1065 TEST_P(Test_ONNX_layers, Resize_HumanSeg)
1067 testONNXModels("resize_humanseg");
1070 TEST_P(Test_ONNX_layers, Div)
1072 const String model = _tf("models/div.onnx");
1073 Net net = readNetFromONNX(model);
1074 ASSERT_FALSE(net.empty());
1076 net.setPreferableBackend(backend);
1077 net.setPreferableTarget(target);
1079 // Reference output values range is -68.80928, 2.991873. So to avoid computational
1080 // difference for FP16 we'll perform reversed division (just swap inputs).
1081 Mat inp1 = blobFromNPY(_tf("data/input_div_1.npy"));
1082 Mat inp2 = blobFromNPY(_tf("data/input_div_0.npy"));
1083 Mat ref = blobFromNPY(_tf("data/output_div.npy"));
1084 cv::divide(1.0, ref, ref);
1085 checkBackend(&inp1, &ref);
1087 net.setInput(inp1, "0");
1088 net.setInput(inp2, "1");
1089 Mat out = net.forward();
1091 normAssert(ref, out, "", default_l1, default_lInf);
1093 // NaryEltwise layer suuports only CPU for now
1094 testONNXModels("div_test_1x1", npy, 0, 0, false, false, 2);
1097 TEST_P(Test_ONNX_layers, DynamicReshape)
1099 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1100 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1102 testONNXModels("dynamic_reshape");
1103 testONNXModels("dynamic_reshape_opset_11");
1104 testONNXModels("flatten_by_prod");
1105 testONNXModels("flatten_const");
1108 TEST_P(Test_ONNX_layers, Reshape)
1110 testONNXModels("unsqueeze");
1111 testONNXModels("unsqueeze_opset_13");
1114 TEST_P(Test_ONNX_layers, Unsqueeze_Neg_Axes)
1116 testONNXModels("unsqueeze_neg_axes");
1119 TEST_P(Test_ONNX_layers, Squeeze)
1121 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
1122 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1123 testONNXModels("squeeze");
1124 testONNXModels("squeeze_axes_op13");
1127 TEST_P(Test_ONNX_layers, ReduceL2)
1129 testONNXModels("reduceL2");
1130 testONNXModels("reduceL2_subgraph");
1131 testONNXModels("reduceL2_subgraph_2");
1132 testONNXModels("reduceL2_subgraph2_2");
1135 TEST_P(Test_ONNX_layers, Split)
1137 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1138 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1139 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1140 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1141 testONNXModels("split_1");
1142 testONNXModels("split_2");
1143 testONNXModels("split_3");
1144 testONNXModels("split_4");
1145 testONNXModels("split_neg_axis");
1148 // Mul inside with 0-d tensor, output should be A x 1, but is 1 x A. PR #22652
1149 TEST_P(Test_ONNX_layers, DISABLED_Split_sizes_0d)
1151 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1152 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1153 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1154 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1155 testONNXModels("split_sizes");
1158 TEST_P(Test_ONNX_layers, Slice)
1160 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
1161 testONNXModels("slice", npy, 0, 0, false, false);
1163 testONNXModels("slice");
1164 testONNXModels("slice_neg_starts");
1165 testONNXModels("slice_opset_11");
1169 TEST_P(Test_ONNX_layers, Slice_Steps_2DInput)
1171 testONNXModels("slice_opset_11_steps_2d");
1174 TEST_P(Test_ONNX_layers, Slice_Steps_3DInput)
1176 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1177 // Cannot get memory!
1178 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
1179 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1180 // IE exception: Cannot get memory!
1181 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1182 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1183 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1187 testONNXModels("slice_opset_11_steps_3d");
1190 TEST_P(Test_ONNX_layers, Slice_Steps_4DInput)
1192 testONNXModels("slice_opset_11_steps_4d");
1195 TEST_P(Test_ONNX_layers, Slice_Steps_5DInput)
1197 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1198 // Cannot get memory!
1199 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
1200 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1201 // IE exception: Cannot get memory!
1202 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1203 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1204 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1206 // Cannot get memory!
1207 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
1208 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1211 testONNXModels("slice_opset_11_steps_5d");
1214 TEST_P(Test_ONNX_layers, Slice_Nonseq_Axes)
1216 testONNXModels("slice_nonseq_axes");
1217 testONNXModels("slice_nonseq_axes_steps");
1218 testONNXModels("slice_nonseq_miss_axes_steps");
1221 TEST_P(Test_ONNX_layers, Slice_Neg_Axes)
1223 testONNXModels("slice_neg_axes");
1224 testONNXModels("slice_neg_axes_steps");
1225 testONNXModels("slice_neg_miss_axes_steps");
1228 TEST_P(Test_ONNX_layers, Softmax)
1230 testONNXModels("softmax");
1231 testONNXModels("log_softmax", npy, 0, 0, false, false);
1232 testONNXModels("softmax_unfused");
1235 TEST_P(Test_ONNX_layers, Split_EltwiseMax)
1237 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1238 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1239 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1240 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1241 testONNXModels("split_max");
1244 TEST_P(Test_ONNX_layers, LSTM_Activations)
1246 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1247 // Cannot get memory!
1248 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
1249 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1250 // IE exception: Node Block1326/lstm/reshape_0/permute was not assigned on any pointed device
1251 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1252 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1253 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1255 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
1256 // IE Exception: Ngraph operation Reshape with name Block1237_Output_0_before_reshape has dynamic output shape on 0 port, but CPU plug-in supports only static shape
1257 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1258 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1259 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1263 testONNXModels("lstm_cntk_tanh", pb, 0, 0, false, false);
1266 // disabled due to poor handling of 1-d mats
1267 TEST_P(Test_ONNX_layers, DISABLED_LSTM)
1269 testONNXModels("lstm", npy, 0, 0, false, false);
1272 // disabled due to poor handling of 1-d mats
1273 TEST_P(Test_ONNX_layers, DISABLED_LSTM_bidirectional)
1275 testONNXModels("lstm_bidirectional", npy, 0, 0, false, false);
1278 TEST_P(Test_ONNX_layers, LSTM_hidden)
1280 testONNXModels("hidden_lstm", npy, 0, 0, false, false);
1283 TEST_P(Test_ONNX_layers, LSTM_hidden_bidirectional)
1285 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1286 // Cannot get memory!
1287 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
1288 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1289 // IE exception: Node Transpose_45 was not assigned on any pointed device.
1290 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1291 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1292 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1296 testONNXModels("hidden_lstm_bi", npy, 0, 0, false, false);
1299 TEST_P(Test_ONNX_layers, GRU)
1301 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1302 // Cannot get memory!
1303 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
1304 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1305 // IE exception: Node GRU_22 was not assigned on any pointed device
1306 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1307 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1308 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1311 testONNXModels("gru", npy, 0, 0, false, false);
1314 TEST_P(Test_ONNX_layers, GRU_bidirectional)
1316 testONNXModels("gru_bi", npy, 0, 0, false, false);
1319 TEST_P(Test_ONNX_layers, LSTM_cell_forward)
1321 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1323 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
1324 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1325 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
1326 // Ngraph operation Reshape with name LSTM_16/lstm_y/reshape has dynamic output shape on 0 port, but CPU plug-in supports only static shape
1327 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL)
1328 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1329 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
1330 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1332 testONNXModels("lstm_cell_forward", npy, 0, 0, false, false);
1334 TEST_P(Test_ONNX_layers, LSTM_cell_bidirectional)
1336 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1337 // Cannot get memory!
1338 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
1339 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1340 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
1341 // Ngraph operation Reshape with name LSTM_16/lstm_y/reshape has dynamic output shape on 0 port, but CPU plug-in supports only static shape
1342 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL)
1343 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1344 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
1345 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1347 testONNXModels("lstm_cell_bidirectional", npy, 0, 0, false, false);
1349 TEST_P(Test_ONNX_layers, LSTM_cell_with_peepholes)
1351 testONNXModels("lstm_cell_with_peepholes", npy, 0, 0, false, false);
1354 TEST_P(Test_ONNX_layers, Pad2d_Unfused)
1356 testONNXModels("ReflectionPad2d");
1357 testONNXModels("ZeroPad2d");
1360 TEST_P(Test_ONNX_layers, LinearWithConstant)
1362 if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
1363 applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
1364 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2020040000)
1365 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE);
1367 if (backend == DNN_BACKEND_CUDA)
1368 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA);
1369 testONNXModels("lin_with_constant");
1372 TEST_P(Test_ONNX_layers, MatmulWithTwoInputs)
1374 if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
1375 applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
1376 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2020040000)
1377 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE);
1379 testONNXModels("matmul_with_two_inputs");
1382 TEST_P(Test_ONNX_layers, ResizeOpset11_Torch1_6)
1384 testONNXModels("resize_opset11_torch1.6");
1387 TEST_P(Test_ONNX_layers, Mish)
1389 testONNXModels("mish");
1390 testONNXModels("mish_no_softplus");
1393 TEST_P(Test_ONNX_layers, CalculatePads)
1395 testONNXModels("calc_pads");
1398 TEST_P(Test_ONNX_layers, Conv1d)
1400 testONNXModels("conv1d");
1403 TEST_P(Test_ONNX_layers, Conv1d_bias)
1405 testONNXModels("conv1d_bias");
1408 TEST_P(Test_ONNX_layers, Conv1d_variable_weight)
1410 if (backend == DNN_BACKEND_CUDA)
1411 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); // not supported
1412 if (backend == DNN_BACKEND_VKCOM)
1413 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN); // not supported
1414 String basename = "conv1d_variable_w";
1415 Net net = readNetFromONNX(_tf("models/" + basename + ".onnx"));
1416 ASSERT_FALSE(net.empty());
1418 net.setPreferableBackend(backend);
1419 net.setPreferableTarget(target);
1421 Mat input = blobFromNPY(_tf("data/input_" + basename + "_0.npy"));
1422 Mat weights = blobFromNPY(_tf("data/input_" + basename + "_1.npy"));
1423 Mat ref = blobFromNPY(_tf("data/output_" + basename + ".npy"));
1425 net.setInput(input, "0");
1426 net.setInput(weights, "1");
1428 Mat out = net.forward();
1429 normAssert(ref, out, "", default_l1, default_lInf);
1432 TEST_P(Test_ONNX_layers, Conv1d_variable_weight_bias)
1434 if (backend == DNN_BACKEND_CUDA)
1435 applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); // not supported
1436 if (backend == DNN_BACKEND_VKCOM)
1437 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN); // not supported
1438 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1440 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1441 if (target == DNN_TARGET_CPU && getInferenceEngineCPUType() == CV_DNN_INFERENCE_ENGINE_CPU_TYPE_ARM_COMPUTE)
1442 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_ARM_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1444 String basename = "conv1d_variable_wb";
1445 Net net = readNetFromONNX(_tf("models/" + basename + ".onnx"));
1446 ASSERT_FALSE(net.empty());
1448 net.setPreferableBackend(backend);
1449 net.setPreferableTarget(target);
1451 Mat input = blobFromNPY(_tf("data/input_" + basename + "_0.npy"));
1452 Mat weights = blobFromNPY(_tf("data/input_" + basename + "_1.npy"));
1453 Mat bias = blobFromNPY(_tf("data/input_" + basename + "_2.npy"));
1454 Mat ref = blobFromNPY(_tf("data/output_" + basename + ".npy"));
1456 net.setInput(input, "0");
1457 net.setInput(weights, "1");
1458 net.setInput(bias, "bias");
1460 Mat out = net.forward();
1461 normAssert(ref, out, "", default_l1, default_lInf);
1464 TEST_P(Test_ONNX_layers, GatherMultiOutput)
1466 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
1467 // IE Exception: Ngraph operation Reshape with name 6 has dynamic output shape on 0 port, but CPU plug-in supports only static shape
1468 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1469 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1470 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1473 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021030000)
1474 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL)
1475 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
1476 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
1477 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
1480 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LE(2021030000)
1481 if (target == DNN_TARGET_MYRIAD)
1482 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE);
1485 testONNXModels("gather_multi_output", npy, 0, 0, false, false);
1488 TEST_P(Test_ONNX_layers, DynamicAxes_squeeze_and_conv)
1490 #if defined(INF_ENGINE_RELEASE)
1491 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1493 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1495 #if INF_ENGINE_VER_MAJOR_LT(2021000000)
1496 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1498 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1502 testONNXModels("squeeze_and_conv_dynamic_axes");
1505 TEST_P(Test_ONNX_layers, DynamicAxes_unsqueeze_and_conv)
1507 #if defined(INF_ENGINE_RELEASE)
1508 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1510 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1512 #if INF_ENGINE_VER_MAJOR_LT(2021000000)
1513 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1515 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1519 testONNXModels("unsqueeze_and_conv_dynamic_axes");
1522 TEST_P(Test_ONNX_layers, DynamicAxes_gather)
1524 #if defined(INF_ENGINE_RELEASE)
1525 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1527 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1529 #if INF_ENGINE_VER_MAJOR_LT(2021000000)
1530 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1532 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1536 testONNXModels("gather_dynamic_axes", npy, 0, 0, false, false);
1539 TEST_P(Test_ONNX_layers, DynamicAxes_gather_scalar)
1541 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1543 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1544 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1545 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1547 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
1549 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1550 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1551 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1553 #elif defined(INF_ENGINE_RELEASE)
1554 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1556 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1558 #if INF_ENGINE_VER_MAJOR_LT(2021000000)
1559 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1561 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1565 testONNXModels("gather_scalar_dynamic_axes", npy, 0, 0, false, false);
1568 TEST_P(Test_ONNX_layers, DynamicAxes_slice)
1570 #if defined(INF_ENGINE_RELEASE)
1571 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1573 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1575 #if INF_ENGINE_VER_MAJOR_LT(2021000000)
1576 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1578 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1582 testONNXModels("slice_dynamic_axes");
1585 TEST_P(Test_ONNX_layers, DynamicAxes_slice_opset_11)
1587 #if defined(INF_ENGINE_RELEASE)
1588 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1590 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1592 #if INF_ENGINE_VER_MAJOR_LT(2021000000)
1593 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1595 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1599 testONNXModels("slice_opset_11_dynamic_axes");
1602 TEST_P(Test_ONNX_layers, DynamicAxes_resize_opset11_torch16)
1604 #if defined(INF_ENGINE_RELEASE)
1605 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1607 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1609 #if INF_ENGINE_VER_MAJOR_LT(2021000000)
1610 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1612 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1616 testONNXModels("resize_opset11_torch1.6_dynamic_axes");
1619 TEST_P(Test_ONNX_layers, DynamicAxes_average_pooling)
1621 #if defined(INF_ENGINE_RELEASE)
1622 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1624 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1626 #if INF_ENGINE_VER_MAJOR_LT(2021000000)
1627 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1629 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1633 testONNXModels("average_pooling_dynamic_axes");
1636 TEST_P(Test_ONNX_layers, DynamicAxes_maxpooling_sigmoid)
1638 #if defined(INF_ENGINE_RELEASE)
1639 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1641 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1643 #if INF_ENGINE_VER_MAJOR_LT(2021000000)
1644 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1646 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1650 testONNXModels("maxpooling_sigmoid_dynamic_axes");
1653 TEST_P(Test_ONNX_layers, DynamicAxes_dynamic_batch)
1655 #if defined(INF_ENGINE_RELEASE)
1656 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1658 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1660 #if INF_ENGINE_VER_MAJOR_LT(2021000000)
1661 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1663 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1667 testONNXModels("dynamic_batch");
1671 TEST_P(Test_ONNX_layers, MaxPool1d)
1673 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
1674 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1676 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1678 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1680 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1683 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2021040000)
1684 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
1686 // 2021.4: [ GENERAL_ERROR ] AssertionFailed: !expired()
1687 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1690 testONNXModels("maxpooling_1d");
1693 TEST_P(Test_ONNX_layers, MaxPoolSigmoid1d)
1695 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1696 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
1697 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1698 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
1699 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1701 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1703 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1705 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1708 testONNXModels("maxpooling_sigmoid_1d");
1711 TEST_P(Test_ONNX_layers, MaxPool1d_Twise)
1713 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1714 // Cannot get memory!
1715 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
1716 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1717 // Cannot get memory!
1718 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1719 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1720 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1722 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
1723 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1725 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1727 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1729 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1732 testONNXModels("two_maxpooling_1d");
1735 TEST_P(Test_ONNX_layers, AvePool1d)
1737 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1738 // Cannot get memory!
1739 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
1740 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1741 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
1742 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1744 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1746 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1748 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1751 testONNXModels("average_pooling_1d");
1754 TEST_P(Test_ONNX_layers, PoolConv1d)
1756 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1757 // Cannot get memory!
1758 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
1759 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1760 // Cannot get memory!
1761 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
1762 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
1763 // Cannot get memory!
1764 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1765 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1766 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1768 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
1769 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1771 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1773 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1775 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1778 testONNXModels("pool_conv_1d");
1781 TEST_P(Test_ONNX_layers, ConvResizePool1d)
1783 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
1784 // IE Exception: Ngraph operation Reshape with name 15 has dynamic output shape on 0 port, but CPU plug-in supports only static shape
1785 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
1786 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
1787 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
1790 #if defined(INF_ENGINE_RELEASE)
1791 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
1793 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
1795 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
1797 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
1798 #if INF_ENGINE_VER_MAJOR_EQ(2021030000)
1799 if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
1800 if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
1804 testONNXModels("conv_resize_pool_1d");
1807 TEST_P(Test_ONNX_layers, SubFromConst)
1809 testONNXModels("sub_from_const1");
1810 testONNXModels("sub_from_const_eltwise");
1811 testONNXModels("sub_from_const_broadcast");
1814 TEST_P(Test_ONNX_layers, DivConst)
1816 testONNXModels("div_const");
1819 TEST_P(Test_ONNX_layers, Gemm)
1821 testONNXModels("gemm_no_transB");
1822 testONNXModels("gemm_transB_0");
1825 TEST_P(Test_ONNX_layers, Quantized_Convolution)
1827 // The difference of QOperator and QDQ format:
1828 // https://onnxruntime.ai/docs/performance/quantization.html#onnx-quantization-representation-format.
1830 SCOPED_TRACE("QOperator quantized model.");
1831 testONNXModels("quantized_conv_uint8_weights", npy, 0.004, 0.02);
1832 testONNXModels("quantized_conv_int8_weights", npy, 0.03, 0.5);
1833 testONNXModels("quantized_conv_per_channel_weights", npy, 0.06, 0.4);
1834 testONNXModels("quantized_conv_asymmetric_pads_int8_weights");
1838 SCOPED_TRACE("QDQ quantized model.");
1839 testONNXModels("quantized_conv_uint8_weights_qdq", npy, 0.004, 0.02);
1840 testONNXModels("quantized_conv_int8_weights_qdq", npy, 0.03, 0.5);
1841 testONNXModels("quantized_conv_per_channel_weights_qdq", npy, 0.06, 0.4);
1845 TEST_P(Test_ONNX_layers, Quantized_MatMul)
1847 testONNXModels("quantized_matmul_uint8_weights", npy, 0.005, 0.007);
1848 testONNXModels("quantized_matmul_int8_weights", npy, 0.06, 0.2);
1849 testONNXModels("quantized_matmul_per_channel_weights", npy, 0.06, 0.22);
1852 TEST_P(Test_ONNX_layers, Quantized_Gemm)
1854 testONNXModels("quantized_gemm", npy);
1857 TEST_P(Test_ONNX_layers, Quantized_MatMul_Variable_Weights)
1862 testONNXModels("quantized_matmul_variable_inputs");
1866 TEST_P(Test_ONNX_layers, Quantized_Eltwise)
1868 testONNXModels("quantized_eltwise");
1871 TEST_P(Test_ONNX_layers, Quantized_Eltwise_Scalar)
1873 testONNXModels("quantized_eltwise_scalar");
1876 TEST_P(Test_ONNX_layers, Quantized_Eltwise_Broadcast)
1878 testONNXModels("quantized_eltwise_broadcast");
1881 TEST_P(Test_ONNX_layers, Quantized_LeakyReLU)
1883 testONNXModels("quantized_leaky_relu");
1886 TEST_P(Test_ONNX_layers, Quantized_Sigmoid)
1888 testONNXModels("quantized_sigmoid");
1891 TEST_P(Test_ONNX_layers, Quantized_MaxPool)
1893 testONNXModels("quantized_maxpool");
1896 TEST_P(Test_ONNX_layers, Quantized_AvgPool)
1898 testONNXModels("quantized_avgpool");
1901 TEST_P(Test_ONNX_layers, Quantized_Split)
1903 testONNXModels("quantized_split");
1906 TEST_P(Test_ONNX_layers, Quantized_Pad)
1908 testONNXModels("quantized_padding");
1911 TEST_P(Test_ONNX_layers, Quantized_Reshape)
1913 testONNXModels("quantized_reshape");
1916 TEST_P(Test_ONNX_layers, Quantized_Transpose)
1918 testONNXModels("quantized_transpose");
1921 TEST_P(Test_ONNX_layers, Quantized_Squeeze)
1923 testONNXModels("quantized_squeeze");
1926 TEST_P(Test_ONNX_layers, Quantized_Unsqueeze)
1928 testONNXModels("quantized_unsqueeze");
1931 TEST_P(Test_ONNX_layers, Quantized_Resize)
1933 testONNXModels("quantized_resize_nearest");
1934 testONNXModels("quantized_resize_bilinear", npy, 2e-4, 0.003);
1935 testONNXModels("quantized_resize_bilinear_align", npy, 3e-4, 0.003);
1938 TEST_P(Test_ONNX_layers, Quantized_Concat)
1940 testONNXModels("quantized_concat");
1941 testONNXModels("quantized_concat_const_blob");
1944 TEST_P(Test_ONNX_layers, Quantized_Constant)
1946 testONNXModels("quantized_constant", npy, 0.002, 0.008);
1949 TEST_P(Test_ONNX_layers, OutputRegistration)
1951 testONNXModels("output_registration", npy, 0, 0, false, true, 2);
1954 INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_ONNX_layers, dnnBackendsAndTargets());
1956 class Test_ONNX_nets : public Test_ONNX_layers
1959 Test_ONNX_nets() { required = false; }
1962 TEST_P(Test_ONNX_nets, Alexnet)
1964 #if defined(OPENCV_32BIT_CONFIGURATION) && (defined(HAVE_OPENCL) || defined(_WIN32))
1965 applyTestTag(CV_TEST_TAG_MEMORY_2GB);
1967 applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
1970 const String model = _tf("models/alexnet.onnx", false);
1972 Net net = readNetFromONNX(model);
1973 ASSERT_FALSE(net.empty());
1975 net.setPreferableBackend(backend);
1976 net.setPreferableTarget(target);
1978 Mat inp = imread(_tf("../grace_hopper_227.png"));
1979 Mat ref = blobFromNPY(_tf("../caffe_alexnet_prob.npy"));
1980 checkBackend(&inp, &ref);
1982 net.setInput(blobFromImage(inp, 1.0f, Size(227, 227), Scalar(), false));
1983 ASSERT_FALSE(net.empty());
1984 Mat out = net.forward();
1986 normAssert(out, ref, "", default_l1, default_lInf);
1987 expectNoFallbacksFromIE(net);
1990 TEST_P(Test_ONNX_nets, Squeezenet)
1992 testONNXModels("squeezenet", pb);
1995 TEST_P(Test_ONNX_nets, Googlenet)
1997 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
1999 if (target == DNN_TARGET_MYRIAD)
2000 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
2001 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2003 if (target == DNN_TARGET_MYRIAD)
2004 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
2005 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2006 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
2007 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
2009 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
2010 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
2013 const String model = _tf("models/googlenet.onnx", false);
2015 Net net = readNetFromONNX(model);
2016 ASSERT_FALSE(net.empty());
2018 net.setPreferableBackend(backend);
2019 net.setPreferableTarget(target);
2021 std::vector<Mat> images;
2022 images.push_back( imread(_tf("../googlenet_0.png")) );
2023 images.push_back( imread(_tf("../googlenet_1.png")) );
2024 Mat inp = blobFromImages(images, 1.0f, Size(), Scalar(), false);
2025 Mat ref = blobFromNPY(_tf("../googlenet_prob.npy"));
2026 checkBackend(&inp, &ref);
2029 ASSERT_FALSE(net.empty());
2030 Mat out = net.forward();
2032 normAssert(ref, out, "", default_l1, default_lInf);
2033 expectNoFallbacksFromIE(net);
2036 TEST_P(Test_ONNX_nets, CaffeNet)
2038 #if defined(OPENCV_32BIT_CONFIGURATION) && (defined(HAVE_OPENCL) || defined(_WIN32))
2039 applyTestTag(CV_TEST_TAG_MEMORY_2GB);
2041 applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
2044 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019030000)
2045 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD
2046 && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
2047 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
2049 testONNXModels("caffenet", pb);
2052 TEST_P(Test_ONNX_nets, RCNN_ILSVRC13)
2054 #if defined(OPENCV_32BIT_CONFIGURATION) && (defined(HAVE_OPENCL) || defined(_WIN32))
2055 applyTestTag(CV_TEST_TAG_MEMORY_2GB);
2057 applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
2060 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019030000)
2061 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD
2062 && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
2063 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
2065 // Reference output values are in range [-4.992, -1.161]
2066 testONNXModels("rcnn_ilsvrc13", pb, 0.0046);
2069 TEST_P(Test_ONNX_nets, VGG16_bn)
2071 applyTestTag(CV_TEST_TAG_MEMORY_6GB); // > 2.3Gb
2073 // output range: [-16; 27], after Softmax [0; 0.67]
2074 const double lInf = (target == DNN_TARGET_MYRIAD) ? 0.038 : default_lInf;
2075 testONNXModels("vgg16-bn", pb, default_l1, lInf, true);
2078 TEST_P(Test_ONNX_nets, ZFNet)
2080 applyTestTag(CV_TEST_TAG_MEMORY_2GB);
2081 testONNXModels("zfnet512", pb);
2084 TEST_P(Test_ONNX_nets, ResNet18v1)
2086 applyTestTag(CV_TEST_TAG_MEMORY_512MB);
2088 // output range: [-16; 22], after Softmax [0, 0.51]
2089 testONNXModels("resnet18v1", pb, default_l1, default_lInf, true, target != DNN_TARGET_MYRIAD);
2092 TEST_P(Test_ONNX_nets, ResNet50v1)
2094 applyTestTag(CV_TEST_TAG_MEMORY_512MB);
2096 // output range: [-67; 75], after Softmax [0, 0.98]
2097 testONNXModels("resnet50v1", pb, default_l1, default_lInf, true, target != DNN_TARGET_MYRIAD);
2100 TEST_P(Test_ONNX_nets, ResNet50_Int8)
2102 testONNXModels("resnet50_int8", pb, default_l1, default_lInf, true);
2105 TEST_P(Test_ONNX_nets, ResNet101_DUC_HDC)
2107 applyTestTag(CV_TEST_TAG_VERYLONG);
2109 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2019010000)
2110 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
2111 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
2113 #if defined(INF_ENGINE_RELEASE)
2114 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
2115 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
2117 if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_OPENCL)
2119 if (backend == DNN_BACKEND_OPENCV)
2120 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_OPENCL : CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
2121 throw SkipTestException("Test is disabled for OpenCL targets");
2123 testONNXModels("resnet101_duc_hdc", pb);
2126 TEST_P(Test_ONNX_nets, TinyYolov2)
2128 applyTestTag(CV_TEST_TAG_MEMORY_512MB);
2130 if (cvtest::skipUnstableTests)
2131 throw SkipTestException("Skip unstable test");
2132 #if defined(INF_ENGINE_RELEASE)
2133 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019
2134 && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
2136 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
2138 if (target == DNN_TARGET_MYRIAD && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X
2140 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X,
2141 backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ?
2142 CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER :
2143 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
2146 // output range: [-11; 8]
2147 double l1 = default_l1, lInf = default_lInf;
2148 if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
2153 else if (target == DNN_TARGET_CUDA_FP16)
2158 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2020040000)
2159 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
2161 l1 = 0.018f; lInf = 0.16f;
2165 testONNXModels("tiny_yolo2", pb, l1, lInf);
2168 TEST_P(Test_ONNX_nets, CNN_MNIST)
2170 // output range: [-1952; 6574], after Softmax [0; 1]
2171 testONNXModels("cnn_mnist", pb, default_l1, default_lInf, true);
2174 TEST_P(Test_ONNX_nets, MobileNet_v2)
2176 // output range: [-166; 317], after Softmax [0; 1]
2177 testONNXModels("mobilenetv2", pb, default_l1, default_lInf, true);
2180 TEST_P(Test_ONNX_nets, MobileNet_v2_FP16)
2182 testONNXModels("mobilenetv2_fp16", npy, default_l1, default_lInf, true);
2185 TEST_P(Test_ONNX_nets, LResNet100E_IR)
2188 #if defined(OPENCV_32BIT_CONFIGURATION) && defined(HAVE_OPENCL)
2189 CV_TEST_TAG_MEMORY_2GB,
2191 (target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB),
2193 CV_TEST_TAG_DEBUG_LONG
2195 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
2197 if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
2198 if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
2199 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
2201 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
2203 if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
2204 if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
2205 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
2208 double l1 = default_l1, lInf = default_lInf;
2209 // output range: [-3; 3]
2210 if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
2215 else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_CPU)
2220 else if (target == DNN_TARGET_CUDA_FP16)
2225 testONNXModels("LResNet100E_IR", pb, l1, lInf);
2228 TEST_P(Test_ONNX_nets, Emotion_ferplus)
2230 #if defined(INF_ENGINE_RELEASE)
2231 if (target == DNN_TARGET_MYRIAD && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
2232 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X,
2233 backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ?
2234 CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER :
2235 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
2238 double l1 = default_l1;
2239 double lInf = default_lInf;
2241 // Output values are in range [-2.011, 2.111]
2242 if ((backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) || (target == DNN_TARGET_CUDA_FP16))
2244 else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_OPENCL_FP16)
2249 else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && (target == DNN_TARGET_CPU || target == DNN_TARGET_OPENCL)) {
2253 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2020040000)
2254 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
2256 l1 = 0.013f; lInf = 0.035f;
2260 testONNXModels("emotion_ferplus", pb, l1, lInf);
2263 TEST_P(Test_ONNX_nets, Inception_v2)
2265 testONNXModels("inception_v2", pb, default_l1, default_lInf, true);
2268 TEST_P(Test_ONNX_nets, DenseNet121)
2270 applyTestTag(CV_TEST_TAG_MEMORY_512MB);
2272 // output range: [-87; 138], after Softmax [0; 1]
2273 testONNXModels("densenet121", pb, default_l1, default_lInf, true, target != DNN_TARGET_MYRIAD);
2276 TEST_P(Test_ONNX_nets, Inception_v1)
2278 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2279 if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ||
2280 backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH) && target == DNN_TARGET_MYRIAD)
2281 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD);
2283 testONNXModels("inception_v1", pb);
2286 TEST_P(Test_ONNX_nets, Shufflenet)
2288 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2289 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
2291 if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
2292 if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
2293 if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
2296 testONNXModels("shufflenet", pb);
2299 TEST_P(Test_ONNX_nets, Resnet34_kinetics)
2301 applyTestTag(CV_TEST_TAG_DEBUG_VERYLONG);
2302 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
2303 // IE exception: Failed to allocate graph: MYRIAD device is not opened
2304 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
2305 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
2307 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
2308 applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16,
2309 CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
2311 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2312 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
2314 // IE exception: Function contains several inputs and outputs with one friendly name!
2315 if (target == DNN_TARGET_MYRIAD)
2316 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
2318 #elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2319 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
2320 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
2321 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
2322 applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
2324 if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
2325 throw SkipTestException("Only CPU is supported"); // FIXIT use tags
2327 if (backend == DNN_BACKEND_VKCOM)
2328 applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
2330 String onnxmodel = findDataFile("dnn/resnet-34_kinetics.onnx", false);
2331 Mat image0 = imread(findDataFile("dnn/dog416.png"));
2332 Mat image1 = imread(findDataFile("dnn/street.png"));
2334 Mat ref0 = blobFromNPY(_tf("data/output_kinetics0.npy"));
2335 Mat ref1 = blobFromNPY(_tf("data/output_kinetics1.npy"));
2337 std::vector<Mat> images_0(16, image0);
2338 std::vector<Mat> images_1(16, image1);
2339 Mat blob0 = blobFromImages(images_0, 1.0, Size(112, 112), Scalar(114.7748, 107.7354, 99.4750), true, true);
2340 Mat blob1 = blobFromImages(images_1, 1.0, Size(112, 112), Scalar(114.7748, 107.7354, 99.4750), true, true);
2344 int order[] = {1, 0, 2, 3};
2345 lp.set("order", DictValue::arrayInt<int*>(&order[0], 4));
2346 permute.addLayerToPrev("perm", "Permute", lp);
2348 permute.setPreferableBackend(backend);
2349 permute.setPreferableTarget(target);
2351 permute.setInput(blob0);
2352 Mat input0 = permute.forward().clone();
2354 permute.setInput(blob1);
2355 Mat input1 = permute.forward().clone();
2357 int dims[] = {1, 3, 16, 112, 112};
2358 input0 = input0.reshape(0, 5, &dims[0]);
2359 input1 = input1.reshape(0, 5, &dims[0]);
2361 Net net = readNetFromONNX(onnxmodel);
2362 ASSERT_FALSE(net.empty());
2363 net.setPreferableBackend(backend);
2364 net.setPreferableTarget(target);
2366 // output range [-5, 11]
2369 if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
2374 if (target == DNN_TARGET_CUDA_FP16)
2380 checkBackend(&input0, &ref0);
2381 net.setInput(input0);
2382 Mat out = net.forward().clone();
2383 normAssert(ref0, out, "", l1, lInf);
2385 checkBackend(&input1, &ref1);
2386 net.setInput(input1);
2387 out = net.forward().clone();
2388 normAssert(ref1, out, "", l1, lInf);
2390 expectNoFallbacksFromIE(net);
2393 TEST_P(Test_ONNX_layers, CumSum)
2395 testONNXModels("cumsum_1d_exclusive_1");
2396 testONNXModels("cumsum_1d_reverse");
2397 testONNXModels("cumsum_1d_exclusive_1_reverse");
2398 testONNXModels("cumsum_2d_dim_1");
2399 testONNXModels("cumsum_3d_dim_2");
2402 // This test is mainly to test:
2403 // 1. identity node with constant input
2404 // 2. limited support to range operator (all inputs are constant)
2405 // 3. parseExpand with multiple broadcast axes
2406 // 4. 1D mat dimension issue with the output of range operator
2407 TEST_P(Test_ONNX_layers, YOLOv7)
2409 std::string weightPath = _tf("models/yolov7_not_simplified.onnx", false);
2410 std::string imgPath = _tf("../dog_orig_size.png");
2412 Size targetSize{640, 640};
2413 float conf_threshold = 0.3;
2414 float iou_threshold = 0.5;
2416 // Reference, which is collected with input size of 640x640
2417 std::vector<int> refClassIds{1, 16, 7};
2418 std::vector<float> refScores{0.9614331f, 0.9589417f, 0.8679074f};
2419 // [x1, y1, x2, y2] x 3
2420 std::vector<Rect2d> refBoxes{Rect2d(105.973236f, 150.16716f, 472.59012f, 466.48834f),
2421 Rect2d(109.97953f, 246.17862f, 259.83676f, 600.76624f),
2422 Rect2d(385.96185f, 83.02809f, 576.07355f, 189.82793f)};
2424 Mat img = imread(imgPath);
2425 Mat inp = blobFromImage(img, 1/255.0, targetSize, Scalar(0, 0, 0), true, false);
2427 Net net = readNet(weightPath);
2430 std::vector<Mat> outs;
2431 net.forward(outs, net.getUnconnectedOutLayersNames());
2433 Mat preds = outs[3].reshape(1, outs[3].size[1]); // [1, 25200, 85]
2436 std::vector<int> classIds;
2437 std::vector<float> confidences;
2438 std::vector<Rect2d> boxes;
2439 // each row is [cx, cy, w, h, conf_obj, conf_class1, ..., conf_class80]
2440 for (int i = 0; i < preds.rows; ++i)
2442 // filter out non objects
2443 float obj_conf = preds.row(i).at<float>(4);
2444 if (obj_conf < conf_threshold)
2447 // get class id and conf
2448 Mat scores = preds.row(i).colRange(5, preds.cols);
2451 minMaxLoc(scores, 0, &conf, 0, &maxLoc);
2453 if (conf < conf_threshold)
2457 float* det = preds.ptr<float>(i);
2463 boxes.push_back(Rect2d(cx - 0.5 * w, cy - 0.5 * h,
2464 cx + 0.5 * w, cy + 0.5 * h));
2465 classIds.push_back(maxLoc.x);
2466 confidences.push_back(conf);
2470 std::vector<int> keep_idx;
2471 NMSBoxes(boxes, confidences, conf_threshold, iou_threshold, keep_idx);
2473 std::vector<int> keep_classIds;
2474 std::vector<float> keep_confidences;
2475 std::vector<Rect2d> keep_boxes;
2476 for (auto i : keep_idx)
2478 keep_classIds.push_back(classIds[i]);
2479 keep_confidences.push_back(confidences[i]);
2480 keep_boxes.push_back(boxes[i]);
2483 normAssertDetections(refClassIds, refScores, refBoxes, keep_classIds, keep_confidences, keep_boxes);
2486 INSTANTIATE_TEST_CASE_P(/**/, Test_ONNX_nets, dnnBackendsAndTargets());