12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036 |
- // This file is part of OpenCV project.
- // It is subject to the license terms in the LICENSE file found in the top-level directory
- // of this distribution and at http://opencv.org/license.html.
- // Copyright (C) 2018-2019, Intel Corporation, all rights reserved.
- // Third party copyrights are property of their respective owners.
- #include "test_precomp.hpp"
- #include "npy_blob.hpp"
- #include <opencv2/dnn/shape_utils.hpp>
- namespace opencv_test { namespace {
- template<typename TString>
- static std::string _tf(TString filename, bool required = true)
- {
- return findDataFile(std::string("dnn/onnx/") + filename, required);
- }
- class Test_ONNX_layers : public DNNTestLayer
- {
- public:
- bool required;
- Test_ONNX_layers() : required(true) { }
- enum Extension
- {
- npy,
- pb
- };
- void testONNXModels(const String& basename, const Extension ext = npy,
- const double l1 = 0, const float lInf = 0, const bool useSoftmax = false,
- bool checkNoFallbacks = true, int numInps = 1)
- {
- String onnxmodel = _tf("models/" + basename + ".onnx", required);
- std::vector<Mat> inps(numInps);
- Mat ref;
- if (ext == npy) {
- for (int i = 0; i < numInps; ++i)
- inps[i] = blobFromNPY(_tf("data/input_" + basename + (numInps > 1 ? format("_%d", i) : "") + ".npy"));
- ref = blobFromNPY(_tf("data/output_" + basename + ".npy"));
- }
- else if (ext == pb) {
- for (int i = 0; i < numInps; ++i)
- inps[i] = readTensorFromONNX(_tf("data/input_" + basename + (numInps > 1 ? format("_%d", i) : "") + ".pb"));
- ref = readTensorFromONNX(_tf("data/output_" + basename + ".pb"));
- }
- else
- CV_Error(Error::StsUnsupportedFormat, "Unsupported extension");
- checkBackend(&inps[0], &ref);
- Net net = readNetFromONNX(onnxmodel);
- ASSERT_FALSE(net.empty());
- net.setPreferableBackend(backend);
- net.setPreferableTarget(target);
- std::vector<String> inputNames;
- for (int i = 0; i < numInps; ++i)
- inputNames.push_back(format("%d", i));
- net.setInputsNames(inputNames);
- for (int i = 0; i < numInps; ++i)
- net.setInput(inps[i], inputNames[i]);
- Mat out = net.forward("");
- if (useSoftmax)
- {
- LayerParams lp;
- Net netSoftmax;
- netSoftmax.addLayerToPrev("softmaxLayer", "Softmax", lp);
- netSoftmax.setPreferableBackend(DNN_BACKEND_OPENCV);
- netSoftmax.setInput(out);
- out = netSoftmax.forward();
- netSoftmax.setInput(ref);
- ref = netSoftmax.forward();
- }
- normAssert(ref, out, "", l1 ? l1 : default_l1, lInf ? lInf : default_lInf);
- if (checkNoFallbacks)
- expectNoFallbacksFromIE(net);
- }
- };
- TEST_P(Test_ONNX_layers, InstanceNorm)
- {
- if(backend == DNN_BACKEND_CUDA)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); /* MVN is not supported */
- if (target == DNN_TARGET_MYRIAD)
- testONNXModels("instancenorm", npy, 0, 0, false, false);
- else
- testONNXModels("instancenorm", npy);
- }
- TEST_P(Test_ONNX_layers, MaxPooling)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2020020000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- #endif
- testONNXModels("maxpooling", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, MaxPooling_2)
- {
- testONNXModels("two_maxpooling", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, Convolution)
- {
- testONNXModels("convolution");
- testONNXModels("conv_asymmetric_pads");
- }
- TEST_P(Test_ONNX_layers, Convolution_variable_weight)
- {
- if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH ||
- backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019) && target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- if (backend == DNN_BACKEND_CUDA)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); // not supported
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN); // not supported
- String basename = "conv_variable_w";
- Net net = readNetFromONNX(_tf("models/" + basename + ".onnx"));
- ASSERT_FALSE(net.empty());
- net.setPreferableBackend(backend);
- net.setPreferableTarget(target);
- for (int i = 0; i < 2; i++)
- {
- Mat input = blobFromNPY(_tf("data/input_" + basename + format("_%d", i) + "_0.npy"));
- Mat weights = blobFromNPY(_tf("data/input_" + basename + format("_%d", i) + "_1.npy"));
- Mat ref = blobFromNPY(_tf("data/output_" + basename + format("_%d", i) + ".npy"));
- net.setInput(input, "0");
- net.setInput(weights, "1");
- Mat out = net.forward();
- normAssert(ref, out, "", default_l1, default_lInf);
- }
- }
- TEST_P(Test_ONNX_layers, Convolution_variable_weight_bias)
- {
- if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH ||
- backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019) && target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- if (backend == DNN_BACKEND_CUDA)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); // not supported
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN); // not supported
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU &&
- getInferenceEngineCPUType() == CV_DNN_INFERENCE_ENGINE_CPU_TYPE_ARM_COMPUTE)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_ARM_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- String basename = "conv_variable_wb";
- Net net = readNetFromONNX(_tf("models/" + basename + ".onnx"));
- ASSERT_FALSE(net.empty());
- net.setPreferableBackend(backend);
- net.setPreferableTarget(target);
- for (int i = 0; i < 2; i++)
- {
- Mat input = blobFromNPY(_tf("data/input_" + basename + format("_%d", i) + "_0.npy"));
- Mat weights = blobFromNPY(_tf("data/input_" + basename + format("_%d", i) + "_1.npy"));
- Mat bias = blobFromNPY(_tf("data/input_" + basename + format("_%d", i) + "_2.npy"));
- Mat ref = blobFromNPY(_tf("data/output_" + basename + format("_%d", i) + ".npy"));
- net.setInput(input, "0");
- net.setInput(weights, "1");
- net.setInput(bias, "bias");
- Mat out = net.forward();
- normAssert(ref, out, "", default_l1, default_lInf);
- }
- }
- TEST_P(Test_ONNX_layers, Gather)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("gather");
- // GPU plugin unsupported slice for constant
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- testONNXModels("gather_scalar", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, Convolution3D)
- {
- testONNXModels("conv3d");
- }
- TEST_P(Test_ONNX_layers, Convolution3D_bias)
- {
- testONNXModels("conv3d_bias");
- }
- TEST_P(Test_ONNX_layers, Two_convolution)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD
- && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X
- )
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- #endif
- // Reference output values are in range [-0.855, 0.611]
- testONNXModels("two_convolution");
- }
- TEST_P(Test_ONNX_layers, Deconvolution)
- {
- testONNXModels("deconvolution", npy, 0, 0, false, false);
- testONNXModels("two_deconvolution", npy, 0, 0, false, false);
- testONNXModels("deconvolution_group", npy, 0, 0, false, false);
- testONNXModels("deconvolution_output_shape", npy, 0, 0, false, false);
- if (target != DNN_TARGET_CUDA_FP16) // bug
- testONNXModels("deconv_adjpad_2d", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, Deconvolution3D)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // [ GENERAL_ERROR ] vpu/graph_transformer/src/frontend/frontend.cpp:439 Failed to compile layer "2":
- // [ 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)
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- if (backend == DNN_BACKEND_OPENCV)
- throw SkipTestException("OpenCV backend is not supported"); // FIXIT use tags
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
- testONNXModels("deconv3d");
- }
- TEST_P(Test_ONNX_layers, Deconvolution3D_bias)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // [ GENERAL_ERROR ] vpu/graph_transformer/src/frontend/frontend.cpp:439 Failed to compile layer "2":
- // [ 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)
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- if (backend == DNN_BACKEND_OPENCV)
- throw SkipTestException("OpenCV backend is not supported"); // FIXIT use tags
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
- testONNXModels("deconv3d_bias");
- }
- TEST_P(Test_ONNX_layers, Deconvolution3D_pad)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // [ GENERAL_ERROR ] vpu/graph_transformer/src/frontend/frontend.cpp:439 Failed to compile layer "2":
- // [ 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)
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- if (backend == DNN_BACKEND_OPENCV)
- throw SkipTestException("OpenCV backend is not supported"); // FIXIT use tags
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
- testONNXModels("deconv3d_pad");
- }
- TEST_P(Test_ONNX_layers, Deconvolution3D_adjpad)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // [ GENERAL_ERROR ] vpu/graph_transformer/src/frontend/frontend.cpp:439 Failed to compile layer "2":
- // [ 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)
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- if (backend == DNN_BACKEND_OPENCV)
- throw SkipTestException("OpenCV backend is not supported"); // FIXIT use tags
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
- testONNXModels("deconv3d_adjpad");
- }
- TEST_P(Test_ONNX_layers, Dropout)
- {
- testONNXModels("dropout");
- }
- TEST_P(Test_ONNX_layers, Linear)
- {
- if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
- testONNXModels("linear");
- }
- TEST_P(Test_ONNX_layers, ReLU)
- {
- testONNXModels("ReLU");
- }
- TEST_P(Test_ONNX_layers, PReLU)
- {
- testONNXModels("PReLU_slope");
- }
- TEST_P(Test_ONNX_layers, Clip)
- {
- testONNXModels("clip", npy);
- }
- TEST_P(Test_ONNX_layers, Shape)
- {
- testONNXModels("shape_of_constant");
- }
- TEST_P(Test_ONNX_layers, ReduceMean)
- {
- testONNXModels("reduce_mean");
- testONNXModels("reduce_mean_axis1");
- testONNXModels("reduce_mean_axis2");
- }
- TEST_P(Test_ONNX_layers, ReduceSum)
- {
- testONNXModels("reduce_sum");
- }
- TEST_P(Test_ONNX_layers, ReduceMax)
- {
- testONNXModels("reduce_max");
- testONNXModels("reduce_max_axis_0");
- testONNXModels("reduce_max_axis_1");
- }
- TEST_P(Test_ONNX_layers, Min)
- {
- testONNXModels("min", npy, 0, 0, false, true, 2);
- }
- TEST_P(Test_ONNX_layers, ArgLayer)
- {
- if (backend != DNN_BACKEND_OPENCV || target != DNN_TARGET_CPU)
- throw SkipTestException("Only CPU is supported"); // FIXIT use tags
- testONNXModels("argmax");
- testONNXModels("argmin");
- }
- TEST_P(Test_ONNX_layers, Scale)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("scale");
- testONNXModels("scale_broadcast", npy, 0, 0, false, true, 3);
- testONNXModels("scale_broadcast_mid", npy, 0, 0, false, true, 2);
- }
- TEST_P(Test_ONNX_layers, ReduceMean3D)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
- else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
- #endif
- if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
- throw SkipTestException("Only CPU is supported"); // FIXIT use tags
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
- testONNXModels("reduce_mean3d");
- }
- TEST_P(Test_ONNX_layers, MaxPooling_Sigmoid)
- {
- testONNXModels("maxpooling_sigmoid");
- }
- TEST_P(Test_ONNX_layers, Cast)
- {
- testONNXModels("cast");
- }
- TEST_P(Test_ONNX_layers, Power)
- {
- testONNXModels("pow2", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, Exp)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("exp");
- }
- TEST_P(Test_ONNX_layers, Elementwise_Ceil)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- testONNXModels("ceil");
- }
- TEST_P(Test_ONNX_layers, Elementwise_Floor)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- testONNXModels("floor");
- }
- TEST_P(Test_ONNX_layers, Elementwise_Log)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- testONNXModels("log");
- }
- TEST_P(Test_ONNX_layers, Elementwise_Round)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- testONNXModels("round");
- }
- TEST_P(Test_ONNX_layers, Elementwise_Sqrt)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- testONNXModels("sqrt");
- #endif
- }
- TEST_P(Test_ONNX_layers, Elementwise_not)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- testONNXModels("not");
- }
- TEST_P(Test_ONNX_layers, Compare_EQ)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- testONNXModels("equal");
- }
- TEST_P(Test_ONNX_layers, Compare_GT)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- testONNXModels("greater");
- }
- TEST_P(Test_ONNX_layers, Compare_LT)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- testONNXModels("less");
- }
- TEST_P(Test_ONNX_layers, CompareSameDims_EQ)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- testONNXModels("equal_same_dims", npy, 0, 0, false, true, 2);
- }
- TEST_P(Test_ONNX_layers, CompareSameDims_GT)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- testONNXModels("greater_same_dims", npy, 0, 0, false, true, 2);
- }
- TEST_P(Test_ONNX_layers, CompareSameDims_LT)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- testONNXModels("less_same_dims", npy, 0, 0, false, true, 2);
- }
- TEST_P(Test_ONNX_layers, Concatenation)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- testONNXModels("concatenation");
- testONNXModels("concat_const_blobs");
- }
- TEST_P(Test_ONNX_layers, Eltwise3D)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
- else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
- #endif
- testONNXModels("eltwise3d");
- }
- TEST_P(Test_ONNX_layers, AveragePooling)
- {
- testONNXModels("average_pooling");
- }
- TEST_P(Test_ONNX_layers, MaxPooling3D)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // accuracy
- if (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- // IE exception: [ GENERAL_ERROR ] AssertionFailed: !expired()
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
- else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
- #endif
- if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
- throw SkipTestException("Only CPU is supported"); // FIXIT use tags
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
- testONNXModels("max_pool3d", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, AvePooling3D)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
- else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
- #endif
- if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
- throw SkipTestException("Only CPU is supported"); // FIXIT use tags
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
- testONNXModels("ave_pool3d");
- }
- TEST_P(Test_ONNX_layers, PoolConv3D)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
- else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
- #endif
- if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
- throw SkipTestException("Only CPU is supported"); // FIXIT use tags
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
- testONNXModels("pool_conv_3d");
- }
- TEST_P(Test_ONNX_layers, BatchNormalization)
- {
- testONNXModels("batch_norm");
- }
- TEST_P(Test_ONNX_layers, BatchNormalization3D)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- testONNXModels("batch_norm_3d");
- }
- TEST_P(Test_ONNX_layers, BatchNormalizationUnfused)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021030000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
- #endif
- testONNXModels("frozenBatchNorm2d");
- }
- TEST_P(Test_ONNX_layers, BatchNormalizationSubgraph)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021030000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
- #endif
- testONNXModels("batch_norm_subgraph");
- }
- TEST_P(Test_ONNX_layers, NormalizeFusionSubgraph)
- {
- testONNXModels("normalize_fusion");
- }
- TEST_P(Test_ONNX_layers, Transpose)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- testONNXModels("transpose");
- }
- TEST_P(Test_ONNX_layers, Multiplication)
- {
- if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("mul");
- }
- TEST_P(Test_ONNX_layers, MatMul)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("matmul_2d");
- testONNXModels("matmul_3d");
- testONNXModels("matmul_4d");
- }
- TEST_P(Test_ONNX_layers, MatMulAdd)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
- testONNXModels("matmul_add");
- }
- TEST_P(Test_ONNX_layers, Expand)
- {
- testONNXModels("expand");
- testONNXModels("expand_identity");
- testONNXModels("expand_batch");
- testONNXModels("expand_channels");
- testONNXModels("expand_neg_batch");
- }
- TEST_P(Test_ONNX_layers, ExpandHW)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("expand_hw");
- }
- TEST_P(Test_ONNX_layers, Constant)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2018050000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD
- && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- #endif
- testONNXModels("constant");
- }
- TEST_P(Test_ONNX_layers, Padding)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
- testONNXModels("padding", npy, 0, 0, false, false);
- #else
- testONNXModels("padding");
- #endif
- }
- TEST_P(Test_ONNX_layers, Resize)
- {
- testONNXModels("resize_nearest");
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("resize_bilinear");
- }
- TEST_P(Test_ONNX_layers, ResizeUnfused)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("upsample_unfused_torch1.2");
- testONNXModels("upsample_unfused_opset9_torch1.4");
- testONNXModels("resize_nearest_unfused_opset11_torch1.4");
- testONNXModels("resize_nearest_unfused_opset11_torch1.3");
- testONNXModels("resize_bilinear_unfused_opset11_torch1.4");
- }
- TEST_P(Test_ONNX_layers, ResizeUnfusedTwoInputs)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- testONNXModels("upsample_unfused_two_inputs_opset9_torch1.4", npy, 0, 0, false, true, 2);
- testONNXModels("upsample_unfused_two_inputs_opset11_torch1.4", npy, 0, 0, false, true, 2);
- }
- TEST_P(Test_ONNX_layers, MultyInputs)
- {
- testONNXModels("multy_inputs", npy, 0, 0, false, true, 2);
- }
- TEST_P(Test_ONNX_layers, Broadcast)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("channel_broadcast", npy, 0, 0, false, true, 2);
- }
- TEST_P(Test_ONNX_layers, DynamicResize)
- {
- testONNXModels("dynamic_resize_9", npy, 0, 0, false, true, 2);
- testONNXModels("dynamic_resize_10", npy, 0, 0, false, true, 2);
- testONNXModels("dynamic_resize_11", npy, 0, 0, false, true, 2);
- testONNXModels("dynamic_resize_13", npy, 0, 0, false, true, 2);
- testONNXModels("dynamic_resize_scale_9", npy, 0, 0, false, true, 2);
- testONNXModels("dynamic_resize_scale_10", npy, 0, 0, false, true, 2);
- testONNXModels("dynamic_resize_scale_11", npy, 0, 0, false, true, 2);
- testONNXModels("dynamic_resize_scale_13", npy, 0, 0, false, true, 2);
- testONNXModels("resize_size_opset11");
- testONNXModels("resize_size_opset13");
- }
- TEST_P(Test_ONNX_layers, Resize_HumanSeg)
- {
- testONNXModels("resize_humanseg");
- }
- TEST_P(Test_ONNX_layers, Div)
- {
- const String model = _tf("models/div.onnx");
- Net net = readNetFromONNX(model);
- ASSERT_FALSE(net.empty());
- net.setPreferableBackend(backend);
- net.setPreferableTarget(target);
- // Reference output values range is -68.80928, 2.991873. So to avoid computational
- // difference for FP16 we'll perform reversed division (just swap inputs).
- Mat inp1 = blobFromNPY(_tf("data/input_div_1.npy"));
- Mat inp2 = blobFromNPY(_tf("data/input_div_0.npy"));
- Mat ref = blobFromNPY(_tf("data/output_div.npy"));
- cv::divide(1.0, ref, ref);
- checkBackend(&inp1, &ref);
- net.setInput(inp1, "0");
- net.setInput(inp2, "1");
- Mat out = net.forward();
- normAssert(ref, out, "", default_l1, default_lInf);
- expectNoFallbacksFromIE(net);
- expectNoFallbacksFromCUDA(net);
- }
- TEST_P(Test_ONNX_layers, DynamicReshape)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("dynamic_reshape");
- testONNXModels("dynamic_reshape_opset_11");
- testONNXModels("flatten_by_prod");
- testONNXModels("flatten_const");
- }
- TEST_P(Test_ONNX_layers, Reshape)
- {
- testONNXModels("unsqueeze");
- testONNXModels("unsqueeze_opset_13");
- }
- TEST_P(Test_ONNX_layers, Squeeze)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- testONNXModels("squeeze");
- }
- TEST_P(Test_ONNX_layers, ReduceL2)
- {
- testONNXModels("reduceL2");
- testONNXModels("reduceL2_subgraph");
- testONNXModels("reduceL2_subgraph_2");
- testONNXModels("reduceL2_subgraph2_2");
- }
- TEST_P(Test_ONNX_layers, Split)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- testONNXModels("split_1");
- testONNXModels("split_2");
- testONNXModels("split_3");
- testONNXModels("split_4");
- testONNXModels("split_sizes");
- testONNXModels("split_neg_axis");
- }
- TEST_P(Test_ONNX_layers, Slice)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
- testONNXModels("slice", npy, 0, 0, false, false);
- #else
- testONNXModels("slice");
- testONNXModels("slice_neg_starts");
- testONNXModels("slice_opset_11");
- #endif
- }
- TEST_P(Test_ONNX_layers, Slice_Steps_2DInput)
- {
- testONNXModels("slice_opset_11_steps_2d");
- }
- TEST_P(Test_ONNX_layers, Slice_Steps_3DInput)
- {
- testONNXModels("slice_opset_11_steps_3d");
- }
- TEST_P(Test_ONNX_layers, Slice_Steps_4DInput)
- {
- testONNXModels("slice_opset_11_steps_4d");
- }
- TEST_P(Test_ONNX_layers, Slice_Steps_5DInput)
- {
- testONNXModels("slice_opset_11_steps_5d");
- }
- TEST_P(Test_ONNX_layers, Softmax)
- {
- testONNXModels("softmax");
- testONNXModels("log_softmax", npy, 0, 0, false, false);
- testONNXModels("softmax_unfused");
- }
- TEST_P(Test_ONNX_layers, Split_EltwiseMax)
- {
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- testONNXModels("split_max");
- }
- TEST_P(Test_ONNX_layers, LSTM_Activations)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- // 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
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- #endif
- testONNXModels("lstm_cntk_tanh", pb, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, LSTM)
- {
- testONNXModels("lstm", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, LSTM_bidirectional)
- {
- testONNXModels("lstm_bidirectional", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, LSTM_hidden)
- {
- testONNXModels("hidden_lstm", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, LSTM_hidden_bidirectional)
- {
- testONNXModels("hidden_lstm_bi", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, GRU)
- {
- testONNXModels("gru", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, GRU_bidirectional)
- {
- testONNXModels("gru_bi", npy, 0, 0, false, false);
- }
- TEST_P(Test_ONNX_layers, Pad2d_Unfused)
- {
- testONNXModels("ReflectionPad2d");
- testONNXModels("ZeroPad2d");
- }
- TEST_P(Test_ONNX_layers, LinearWithConstant)
- {
- if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2020040000)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE);
- #endif
- if (backend == DNN_BACKEND_CUDA)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA);
- testONNXModels("lin_with_constant");
- }
- TEST_P(Test_ONNX_layers, MatmulWithTwoInputs)
- {
- if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2020040000)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE);
- #endif
- testONNXModels("matmul_with_two_inputs");
- }
- TEST_P(Test_ONNX_layers, ResizeOpset11_Torch1_6)
- {
- testONNXModels("resize_opset11_torch1.6");
- }
- TEST_P(Test_ONNX_layers, Mish)
- {
- testONNXModels("mish");
- }
- TEST_P(Test_ONNX_layers, CalculatePads)
- {
- testONNXModels("calc_pads");
- }
- TEST_P(Test_ONNX_layers, Conv1d)
- {
- testONNXModels("conv1d");
- }
- TEST_P(Test_ONNX_layers, Conv1d_bias)
- {
- testONNXModels("conv1d_bias");
- }
- TEST_P(Test_ONNX_layers, Conv1d_variable_weight)
- {
- if (backend == DNN_BACKEND_CUDA)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); // not supported
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN); // not supported
- String basename = "conv1d_variable_w";
- Net net = readNetFromONNX(_tf("models/" + basename + ".onnx"));
- ASSERT_FALSE(net.empty());
- net.setPreferableBackend(backend);
- net.setPreferableTarget(target);
- Mat input = blobFromNPY(_tf("data/input_" + basename + "_0.npy"));
- Mat weights = blobFromNPY(_tf("data/input_" + basename + "_1.npy"));
- Mat ref = blobFromNPY(_tf("data/output_" + basename + ".npy"));
- net.setInput(input, "0");
- net.setInput(weights, "1");
- Mat out = net.forward();
- normAssert(ref, out, "", default_l1, default_lInf);
- }
- TEST_P(Test_ONNX_layers, Conv1d_variable_weight_bias)
- {
- if (backend == DNN_BACKEND_CUDA)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); // not supported
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN); // not supported
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- if (target == DNN_TARGET_CPU && getInferenceEngineCPUType() == CV_DNN_INFERENCE_ENGINE_CPU_TYPE_ARM_COMPUTE)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_ARM_CPU, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- String basename = "conv1d_variable_wb";
- Net net = readNetFromONNX(_tf("models/" + basename + ".onnx"));
- ASSERT_FALSE(net.empty());
- net.setPreferableBackend(backend);
- net.setPreferableTarget(target);
- Mat input = blobFromNPY(_tf("data/input_" + basename + "_0.npy"));
- Mat weights = blobFromNPY(_tf("data/input_" + basename + "_1.npy"));
- Mat bias = blobFromNPY(_tf("data/input_" + basename + "_2.npy"));
- Mat ref = blobFromNPY(_tf("data/output_" + basename + ".npy"));
- net.setInput(input, "0");
- net.setInput(weights, "1");
- net.setInput(bias, "bias");
- Mat out = net.forward();
- normAssert(ref, out, "", default_l1, default_lInf);
- }
- TEST_P(Test_ONNX_layers, GatherMultiOutput)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- // IE Exception: Ngraph operation Reshape with name 6 has dynamic output shape on 0 port, but CPU plug-in supports only static shape
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021030000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LE(2021030000)
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE);
- #endif
- testONNXModels("gather_multi_output");
- }
- TEST_P(Test_ONNX_layers, DynamicAxes_squeeze_and_conv)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #if INF_ENGINE_VER_MAJOR_LT(2021000000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #endif
- testONNXModels("squeeze_and_conv_dynamic_axes");
- }
- TEST_P(Test_ONNX_layers, DynamicAxes_unsqueeze_and_conv)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #if INF_ENGINE_VER_MAJOR_LT(2021000000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #endif
- testONNXModels("unsqueeze_and_conv_dynamic_axes");
- }
- TEST_P(Test_ONNX_layers, DynamicAxes_gather)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #if INF_ENGINE_VER_MAJOR_LT(2021000000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #endif
- testONNXModels("gather_dynamic_axes");
- }
- TEST_P(Test_ONNX_layers, DynamicAxes_gather_scalar)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- // accuracy
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- #endif
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #if INF_ENGINE_VER_MAJOR_LT(2021000000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #endif
- testONNXModels("gather_scalar_dynamic_axes");
- }
- TEST_P(Test_ONNX_layers, DynamicAxes_slice)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #if INF_ENGINE_VER_MAJOR_LT(2021000000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #endif
- testONNXModels("slice_dynamic_axes");
- }
- TEST_P(Test_ONNX_layers, DynamicAxes_slice_opset_11)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #if INF_ENGINE_VER_MAJOR_LT(2021000000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #endif
- testONNXModels("slice_opset_11_dynamic_axes");
- }
- TEST_P(Test_ONNX_layers, DynamicAxes_resize_opset11_torch16)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #if INF_ENGINE_VER_MAJOR_LT(2021000000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #endif
- testONNXModels("resize_opset11_torch1.6_dynamic_axes");
- }
- TEST_P(Test_ONNX_layers, DynamicAxes_average_pooling)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #if INF_ENGINE_VER_MAJOR_LT(2021000000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #endif
- testONNXModels("average_pooling_dynamic_axes");
- }
- TEST_P(Test_ONNX_layers, DynamicAxes_maxpooling_sigmoid)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #if INF_ENGINE_VER_MAJOR_LT(2021000000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #endif
- testONNXModels("maxpooling_sigmoid_dynamic_axes");
- }
- TEST_P(Test_ONNX_layers, DynamicAxes_dynamic_batch)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #if INF_ENGINE_VER_MAJOR_LT(2021000000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #endif
- testONNXModels("dynamic_batch");
- }
- TEST_P(Test_ONNX_layers, MaxPool1d)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_MYRIAD)
- {
- // 2021.4: [ GENERAL_ERROR ] AssertionFailed: !expired()
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- testONNXModels("maxpooling_1d");
- }
- TEST_P(Test_ONNX_layers, MaxPoolSigmoid1d)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- testONNXModels("maxpooling_sigmoid_1d");
- }
- TEST_P(Test_ONNX_layers, MaxPool1d_Twise)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- testONNXModels("two_maxpooling_1d");
- }
- TEST_P(Test_ONNX_layers, AvePool1d)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- testONNXModels("average_pooling_1d");
- }
- TEST_P(Test_ONNX_layers, PoolConv1d)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- #endif
- testONNXModels("pool_conv_1d");
- }
- TEST_P(Test_ONNX_layers, ConvResizePool1d)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- // IE Exception: Ngraph operation Reshape with name 15 has dynamic output shape on 0 port, but CPU plug-in supports only static shape
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
- 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_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION
- );
- #endif
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #if INF_ENGINE_VER_MAJOR_EQ(2021030000)
- if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
- if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // exception
- #endif
- }
- #endif
- testONNXModels("conv_resize_pool_1d");
- }
- TEST_P(Test_ONNX_layers, SubFromConst)
- {
- testONNXModels("sub_from_const1");
- testONNXModels("sub_from_const_eltwise");
- testONNXModels("sub_from_const_broadcast");
- }
- TEST_P(Test_ONNX_layers, DivConst)
- {
- testONNXModels("div_const");
- }
- TEST_P(Test_ONNX_layers, Quantized_Convolution)
- {
- testONNXModels("quantized_conv_uint8_weights", npy, 0.004, 0.02);
- testONNXModels("quantized_conv_int8_weights", npy, 0.03, 0.5);
- testONNXModels("quantized_conv_per_channel_weights", npy, 0.06, 0.4);
- }
- TEST_P(Test_ONNX_layers, Quantized_MatMul)
- {
- testONNXModels("quantized_matmul_uint8_weights", npy, 0.005, 0.007);
- testONNXModels("quantized_matmul_int8_weights", npy, 0.06, 0.2);
- testONNXModels("quantized_matmul_per_channel_weights", npy, 0.06, 0.22);
- }
- TEST_P(Test_ONNX_layers, Quantized_MatMul_Variable_Weights)
- {
- // Unsupported
- EXPECT_THROW(
- {
- testONNXModels("quantized_matmul_variable_inputs");
- }, cv::Exception);
- }
- TEST_P(Test_ONNX_layers, Quantized_Eltwise)
- {
- testONNXModels("quantized_eltwise");
- }
- TEST_P(Test_ONNX_layers, Quantized_Eltwise_Scalar)
- {
- testONNXModels("quantized_eltwise_scalar");
- }
- TEST_P(Test_ONNX_layers, Quantized_Eltwise_Broadcast)
- {
- testONNXModels("quantized_eltwise_broadcast");
- }
- TEST_P(Test_ONNX_layers, Quantized_LeakyReLU)
- {
- testONNXModels("quantized_leaky_relu");
- }
- TEST_P(Test_ONNX_layers, Quantized_Sigmoid)
- {
- testONNXModels("quantized_sigmoid");
- }
- TEST_P(Test_ONNX_layers, Quantized_MaxPool)
- {
- testONNXModels("quantized_maxpool");
- }
- TEST_P(Test_ONNX_layers, Quantized_AvgPool)
- {
- testONNXModels("quantized_avgpool");
- }
- TEST_P(Test_ONNX_layers, Quantized_Split)
- {
- testONNXModels("quantized_split");
- }
- TEST_P(Test_ONNX_layers, Quantized_Pad)
- {
- testONNXModels("quantized_padding");
- }
- TEST_P(Test_ONNX_layers, Quantized_Reshape)
- {
- testONNXModels("quantized_reshape");
- }
- TEST_P(Test_ONNX_layers, Quantized_Transpose)
- {
- testONNXModels("quantized_transpose");
- }
- TEST_P(Test_ONNX_layers, Quantized_Squeeze)
- {
- testONNXModels("quantized_squeeze");
- }
- TEST_P(Test_ONNX_layers, Quantized_Unsqueeze)
- {
- testONNXModels("quantized_unsqueeze");
- }
- TEST_P(Test_ONNX_layers, Quantized_Resize)
- {
- testONNXModels("quantized_resize_nearest");
- testONNXModels("quantized_resize_bilinear", npy, 2e-4, 0.003);
- testONNXModels("quantized_resize_bilinear_align", npy, 3e-4, 0.003);
- }
- TEST_P(Test_ONNX_layers, Quantized_Concat)
- {
- testONNXModels("quantized_concat");
- testONNXModels("quantized_concat_const_blob");
- }
- TEST_P(Test_ONNX_layers, Quantized_Constant)
- {
- testONNXModels("quantized_constant", npy, 0.002, 0.008);
- }
- INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_ONNX_layers, dnnBackendsAndTargets());
- class Test_ONNX_nets : public Test_ONNX_layers
- {
- public:
- Test_ONNX_nets() { required = false; }
- };
- TEST_P(Test_ONNX_nets, Alexnet)
- {
- #if defined(OPENCV_32BIT_CONFIGURATION) && (defined(HAVE_OPENCL) || defined(_WIN32))
- applyTestTag(CV_TEST_TAG_MEMORY_2GB);
- #else
- applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
- #endif
- const String model = _tf("models/alexnet.onnx", false);
- Net net = readNetFromONNX(model);
- ASSERT_FALSE(net.empty());
- net.setPreferableBackend(backend);
- net.setPreferableTarget(target);
- Mat inp = imread(_tf("../grace_hopper_227.png"));
- Mat ref = blobFromNPY(_tf("../caffe_alexnet_prob.npy"));
- checkBackend(&inp, &ref);
- net.setInput(blobFromImage(inp, 1.0f, Size(227, 227), Scalar(), false));
- ASSERT_FALSE(net.empty());
- Mat out = net.forward();
- normAssert(out, ref, "", default_l1, default_lInf);
- expectNoFallbacksFromIE(net);
- }
- TEST_P(Test_ONNX_nets, Squeezenet)
- {
- testONNXModels("squeezenet", pb);
- }
- TEST_P(Test_ONNX_nets, Googlenet)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- // accuracy
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- #endif
- const String model = _tf("models/googlenet.onnx", false);
- Net net = readNetFromONNX(model);
- ASSERT_FALSE(net.empty());
- net.setPreferableBackend(backend);
- net.setPreferableTarget(target);
- std::vector<Mat> images;
- images.push_back( imread(_tf("../googlenet_0.png")) );
- images.push_back( imread(_tf("../googlenet_1.png")) );
- Mat inp = blobFromImages(images, 1.0f, Size(), Scalar(), false);
- Mat ref = blobFromNPY(_tf("../googlenet_prob.npy"));
- checkBackend(&inp, &ref);
- net.setInput(inp);
- ASSERT_FALSE(net.empty());
- Mat out = net.forward();
- normAssert(ref, out, "", default_l1, default_lInf);
- expectNoFallbacksFromIE(net);
- }
- TEST_P(Test_ONNX_nets, CaffeNet)
- {
- #if defined(OPENCV_32BIT_CONFIGURATION) && (defined(HAVE_OPENCL) || defined(_WIN32))
- applyTestTag(CV_TEST_TAG_MEMORY_2GB);
- #else
- applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019030000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD
- && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- #endif
- testONNXModels("caffenet", pb);
- }
- TEST_P(Test_ONNX_nets, RCNN_ILSVRC13)
- {
- #if defined(OPENCV_32BIT_CONFIGURATION) && (defined(HAVE_OPENCL) || defined(_WIN32))
- applyTestTag(CV_TEST_TAG_MEMORY_2GB);
- #else
- applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019030000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD
- && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- #endif
- // Reference output values are in range [-4.992, -1.161]
- testONNXModels("rcnn_ilsvrc13", pb, 0.0046);
- }
- TEST_P(Test_ONNX_nets, VGG16_bn)
- {
- applyTestTag(CV_TEST_TAG_MEMORY_6GB); // > 2.3Gb
- // output range: [-16; 27], after Softmax [0; 0.67]
- const double lInf = (target == DNN_TARGET_MYRIAD) ? 0.038 : default_lInf;
- testONNXModels("vgg16-bn", pb, default_l1, lInf, true);
- }
- TEST_P(Test_ONNX_nets, ZFNet)
- {
- applyTestTag(CV_TEST_TAG_MEMORY_2GB);
- testONNXModels("zfnet512", pb);
- }
- TEST_P(Test_ONNX_nets, ResNet18v1)
- {
- applyTestTag(CV_TEST_TAG_MEMORY_512MB);
- // output range: [-16; 22], after Softmax [0, 0.51]
- testONNXModels("resnet18v1", pb, default_l1, default_lInf, true, target != DNN_TARGET_MYRIAD);
- }
- TEST_P(Test_ONNX_nets, ResNet50v1)
- {
- applyTestTag(CV_TEST_TAG_MEMORY_512MB);
- // output range: [-67; 75], after Softmax [0, 0.98]
- testONNXModels("resnet50v1", pb, default_l1, default_lInf, true, target != DNN_TARGET_MYRIAD);
- }
- TEST_P(Test_ONNX_nets, ResNet50_Int8)
- {
- testONNXModels("resnet50_int8", pb, default_l1, default_lInf, true);
- }
- TEST_P(Test_ONNX_nets, ResNet101_DUC_HDC)
- {
- applyTestTag(CV_TEST_TAG_VERYLONG);
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2019010000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- #endif
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- #endif
- if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_OPENCL)
- {
- if (backend == DNN_BACKEND_OPENCV)
- applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_OPENCL : CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
- throw SkipTestException("Test is disabled for OpenCL targets");
- }
- testONNXModels("resnet101_duc_hdc", pb);
- }
- TEST_P(Test_ONNX_nets, TinyYolov2)
- {
- applyTestTag(CV_TEST_TAG_MEMORY_512MB);
- if (cvtest::skipUnstableTests)
- throw SkipTestException("Skip unstable test");
- #if defined(INF_ENGINE_RELEASE)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019
- && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16)
- )
- 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);
- if (target == DNN_TARGET_MYRIAD && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X
- )
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X,
- backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ?
- CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER :
- CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- // output range: [-11; 8]
- double l1 = default_l1, lInf = default_lInf;
- if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
- {
- l1 = 0.02;
- lInf = 0.2;
- }
- else if (target == DNN_TARGET_CUDA_FP16)
- {
- l1 = 0.018;
- lInf = 0.16;
- }
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2020040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
- {
- l1 = 0.018f; lInf = 0.16f;
- }
- #endif
- testONNXModels("tiny_yolo2", pb, l1, lInf);
- }
- TEST_P(Test_ONNX_nets, CNN_MNIST)
- {
- // output range: [-1952; 6574], after Softmax [0; 1]
- testONNXModels("cnn_mnist", pb, default_l1, default_lInf, true);
- }
- TEST_P(Test_ONNX_nets, MobileNet_v2)
- {
- // output range: [-166; 317], after Softmax [0; 1]
- testONNXModels("mobilenetv2", pb, default_l1, default_lInf, true);
- }
- TEST_P(Test_ONNX_nets, LResNet100E_IR)
- {
- applyTestTag(
- #if defined(OPENCV_32BIT_CONFIGURATION) && defined(HAVE_OPENCL)
- CV_TEST_TAG_MEMORY_2GB,
- #else
- (target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB),
- #endif
- CV_TEST_TAG_DEBUG_LONG
- );
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- }
- double l1 = default_l1, lInf = default_lInf;
- // output range: [-3; 3]
- if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
- {
- l1 = 0.009;
- lInf = 0.035;
- }
- else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_CPU)
- {
- l1 = 4.6e-5;
- lInf = 1.9e-4;
- }
- else if (target == DNN_TARGET_CUDA_FP16)
- {
- l1 = 0.008;
- lInf = 0.04;
- }
- testONNXModels("LResNet100E_IR", pb, l1, lInf);
- }
- TEST_P(Test_ONNX_nets, Emotion_ferplus)
- {
- #if defined(INF_ENGINE_RELEASE)
- if (target == DNN_TARGET_MYRIAD && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X,
- backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ?
- CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER :
- CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
- #endif
- double l1 = default_l1;
- double lInf = default_lInf;
- // Output values are in range [-2.011, 2.111]
- if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
- l1 = 0.007;
- else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_OPENCL_FP16)
- {
- l1 = 0.021;
- lInf = 0.034;
- }
- else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && (target == DNN_TARGET_CPU || target == DNN_TARGET_OPENCL)) {
- l1 = 2.4e-4;
- lInf = 6e-4;
- }
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2020040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
- {
- l1 = 0.013f; lInf = 0.035f;
- }
- #endif
- testONNXModels("emotion_ferplus", pb, l1, lInf);
- }
- TEST_P(Test_ONNX_nets, Inception_v2)
- {
- testONNXModels("inception_v2", pb, default_l1, default_lInf, true);
- }
- TEST_P(Test_ONNX_nets, DenseNet121)
- {
- applyTestTag(CV_TEST_TAG_MEMORY_512MB);
- // output range: [-87; 138], after Softmax [0; 1]
- testONNXModels("densenet121", pb, default_l1, default_lInf, true, target != DNN_TARGET_MYRIAD);
- }
- TEST_P(Test_ONNX_nets, Inception_v1)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if ((backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ||
- backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH) && target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD);
- #endif
- testONNXModels("inception_v1", pb);
- }
- TEST_P(Test_ONNX_nets, Shufflenet)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019)
- {
- if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (target == DNN_TARGET_OPENCL) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
- }
- #endif
- testONNXModels("shufflenet", pb);
- }
- TEST_P(Test_ONNX_nets, Resnet34_kinetics)
- {
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER); // Only CPU on DLIE backend is supported
- else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target != DNN_TARGET_CPU)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH); // Only CPU on DLIE backend is supported
- #endif
- #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
- {
- // IE exception: Function contains several inputs and outputs with one friendly name!
- if (target == DNN_TARGET_MYRIAD)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NGRAPH, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
- }
- #endif
- if (backend == DNN_BACKEND_OPENCV && target != DNN_TARGET_CPU)
- throw SkipTestException("Only CPU is supported"); // FIXIT use tags
- if (backend == DNN_BACKEND_VKCOM)
- applyTestTag(CV_TEST_TAG_DNN_SKIP_VULKAN);
- String onnxmodel = findDataFile("dnn/resnet-34_kinetics.onnx", false);
- Mat image0 = imread(findDataFile("dnn/dog416.png"));
- Mat image1 = imread(findDataFile("dnn/street.png"));
- Mat ref0 = blobFromNPY(_tf("data/output_kinetics0.npy"));
- Mat ref1 = blobFromNPY(_tf("data/output_kinetics1.npy"));
- std::vector<Mat> images_0(16, image0);
- std::vector<Mat> images_1(16, image1);
- Mat blob0 = blobFromImages(images_0, 1.0, Size(112, 112), Scalar(114.7748, 107.7354, 99.4750), true, true);
- Mat blob1 = blobFromImages(images_1, 1.0, Size(112, 112), Scalar(114.7748, 107.7354, 99.4750), true, true);
- Net permute;
- LayerParams lp;
- int order[] = {1, 0, 2, 3};
- lp.set("order", DictValue::arrayInt<int*>(&order[0], 4));
- permute.addLayerToPrev("perm", "Permute", lp);
- permute.setPreferableBackend(backend);
- permute.setPreferableTarget(target);
- permute.setInput(blob0);
- Mat input0 = permute.forward().clone();
- permute.setInput(blob1);
- Mat input1 = permute.forward().clone();
- int dims[] = {1, 3, 16, 112, 112};
- input0 = input0.reshape(0, 5, &dims[0]);
- input1 = input1.reshape(0, 5, &dims[0]);
- Net net = readNetFromONNX(onnxmodel);
- ASSERT_FALSE(net.empty());
- net.setPreferableBackend(backend);
- net.setPreferableTarget(target);
- // output range [-5, 11]
- float l1 = 0.0013;
- float lInf = 0.009;
- if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH && target == DNN_TARGET_OPENCL_FP16)
- {
- l1 = 0.02;
- lInf = 0.07;
- }
- if (target == DNN_TARGET_CUDA_FP16)
- {
- l1 = 0.01;
- lInf = 0.06;
- }
- checkBackend(&input0, &ref0);
- net.setInput(input0);
- Mat out = net.forward().clone();
- normAssert(ref0, out, "", l1, lInf);
- checkBackend(&input1, &ref1);
- net.setInput(input1);
- out = net.forward().clone();
- normAssert(ref1, out, "", l1, lInf);
- expectNoFallbacksFromIE(net);
- }
- TEST_P(Test_ONNX_layers, CumSum)
- {
- testONNXModels("cumsum_1d_exclusive_1");
- testONNXModels("cumsum_1d_reverse");
- testONNXModels("cumsum_1d_exclusive_1_reverse");
- testONNXModels("cumsum_2d_dim_1");
- testONNXModels("cumsum_3d_dim_2");
- }
- INSTANTIATE_TEST_CASE_P(/**/, Test_ONNX_nets, dnnBackendsAndTargets());
- }} // namespace
|