2018-09-11 02:07:51 +08:00
// 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.
2019-03-29 21:42:58 +08:00
// Copyright (C) 2018-2019, Intel Corporation, all rights reserved.
2018-09-11 02:07:51 +08:00
// 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 >
2019-06-20 21:43:28 +08:00
static std : : string _tf ( TString filename , bool required = true )
2018-09-11 02:07:51 +08:00
{
2019-06-20 21:43:28 +08:00
return findDataFile ( std : : string ( " dnn/onnx/ " ) + filename , required ) ;
2018-09-11 02:07:51 +08:00
}
class Test_ONNX_layers : public DNNTestLayer
{
public :
2019-06-20 21:43:28 +08:00
bool required ;
Test_ONNX_layers ( ) : required ( true ) { }
2018-09-11 02:07:51 +08:00
enum Extension
{
npy ,
pb
} ;
2019-03-29 21:42:58 +08:00
void testONNXModels ( const String & basename , const Extension ext = npy ,
2019-04-19 19:54:08 +08:00
const double l1 = 0 , const float lInf = 0 , const bool useSoftmax = false ,
2020-03-06 04:53:50 +08:00
bool checkNoFallbacks = true , int numInps = 1 )
2018-09-11 02:07:51 +08:00
{
2019-06-20 21:43:28 +08:00
String onnxmodel = _tf ( " models/ " + basename + " .onnx " , required ) ;
2020-03-06 04:53:50 +08:00
std : : vector < Mat > inps ( numInps ) ;
Mat ref ;
2018-09-11 02:07:51 +08:00
if ( ext = = npy ) {
2020-03-06 04:53:50 +08:00
for ( int i = 0 ; i < numInps ; + + i )
inps [ i ] = blobFromNPY ( _tf ( " data/input_ " + basename + ( numInps > 1 ? format ( " _%d " , i ) : " " ) + " .npy " ) ) ;
2018-09-11 02:07:51 +08:00
ref = blobFromNPY ( _tf ( " data/output_ " + basename + " .npy " ) ) ;
}
else if ( ext = = pb ) {
2020-03-06 04:53:50 +08:00
for ( int i = 0 ; i < numInps ; + + i )
inps [ i ] = readTensorFromONNX ( _tf ( " data/input_ " + basename + ( numInps > 1 ? format ( " _%d " , i ) : " " ) + " .pb " ) ) ;
2018-09-11 02:07:51 +08:00
ref = readTensorFromONNX ( _tf ( " data/output_ " + basename + " .pb " ) ) ;
}
else
CV_Error ( Error : : StsUnsupportedFormat , " Unsupported extension " ) ;
2020-03-06 04:53:50 +08:00
checkBackend ( & inps [ 0 ] , & ref ) ;
2018-09-11 02:07:51 +08:00
Net net = readNetFromONNX ( onnxmodel ) ;
ASSERT_FALSE ( net . empty ( ) ) ;
net . setPreferableBackend ( backend ) ;
net . setPreferableTarget ( target ) ;
2020-03-17 22:31:01 +08:00
std : : vector < String > inputNames ;
2020-03-06 04:53:50 +08:00
for ( int i = 0 ; i < numInps ; + + i )
2020-03-17 22:31:01 +08:00
inputNames . push_back ( format ( " %d " , i ) ) ;
net . setInputsNames ( inputNames ) ;
for ( int i = 0 ; i < numInps ; + + i )
net . setInput ( inps [ i ] , inputNames [ i ] ) ;
2019-03-29 21:42:58 +08:00
Mat out = net . forward ( " " ) ;
if ( useSoftmax )
{
LayerParams lp ;
Net netSoftmax ;
2020-03-22 23:50:15 +08:00
netSoftmax . addLayerToPrev ( " softmaxLayer " , " Softmax " , lp ) ;
2019-03-29 21:42:58 +08:00
netSoftmax . setPreferableBackend ( DNN_BACKEND_OPENCV ) ;
netSoftmax . setInput ( out ) ;
out = netSoftmax . forward ( ) ;
netSoftmax . setInput ( ref ) ;
ref = netSoftmax . forward ( ) ;
}
2018-09-11 02:07:51 +08:00
normAssert ( ref , out , " " , l1 ? l1 : default_l1 , lInf ? lInf : default_lInf ) ;
2019-04-19 19:54:08 +08:00
if ( checkNoFallbacks )
expectNoFallbacksFromIE ( net ) ;
2018-09-11 02:07:51 +08:00
}
} ;
2019-07-05 02:15:04 +08:00
TEST_P ( Test_ONNX_layers , InstanceNorm )
{
if ( target = = DNN_TARGET_MYRIAD )
testONNXModels ( " instancenorm " , npy , 0 , 0 , false , false ) ;
else
testONNXModels ( " instancenorm " , npy ) ;
}
2018-09-11 02:07:51 +08:00
TEST_P ( Test_ONNX_layers , MaxPooling )
{
2020-04-22 17:01:25 +08:00
# 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
2019-10-02 19:05:41 +08:00
testONNXModels ( " maxpooling " , npy , 0 , 0 , false , false ) ;
2020-04-22 17:01:25 +08:00
}
TEST_P ( Test_ONNX_layers , MaxPooling_2 )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// IE exception: Cannot get memory!
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
# endif
2019-10-02 19:05:41 +08:00
testONNXModels ( " two_maxpooling " , npy , 0 , 0 , false , false ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_layers , Convolution )
{
testONNXModels ( " convolution " ) ;
2021-07-16 12:09:41 +08:00
testONNXModels ( " conv_asymmetric_pads " ) ;
2019-03-29 21:42:58 +08:00
}
2020-08-04 02:02:49 +08:00
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 ) ;
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 )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// 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}
// 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}
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 ) ;
// accuracy (depends on OpenCL version / HW)
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
) ;
# elif defined(INF_ENGINE_RELEASE)
2020-08-04 02:02:49 +08:00
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 ) ;
2021-03-20 19:20:02 +08:00
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 ) ;
2022-03-31 03:03:38 +08:00
# endif
2021-03-20 19:20:02 +08:00
2020-08-04 02:02:49 +08:00
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 ) ;
}
}
2020-07-20 17:04:20 +08:00
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 ) ;
}
2019-04-30 22:08:17 +08:00
TEST_P ( Test_ONNX_layers , Convolution3D )
{
testONNXModels ( " conv3d " ) ;
2020-11-14 06:22:10 +08:00
}
TEST_P ( Test_ONNX_layers , Convolution3D_bias )
{
2019-04-30 22:08:17 +08:00
testONNXModels ( " conv3d_bias " ) ;
}
2019-03-29 21:42:58 +08:00
TEST_P ( Test_ONNX_layers , Two_convolution )
{
2019-06-14 23:17:02 +08:00
# if defined(INF_ENGINE_RELEASE)
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 & & target = = DNN_TARGET_MYRIAD
2019-03-29 21:42:58 +08:00
& & getInferenceEngineVPUType ( ) = = CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X
)
2019-12-02 21:16:06 +08:00
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X , CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER ) ;
2019-03-29 21:42:58 +08:00
# endif
// Reference output values are in range [-0.855, 0.611]
2018-09-11 02:07:51 +08:00
testONNXModels ( " two_convolution " ) ;
}
2018-11-17 03:50:40 +08:00
TEST_P ( Test_ONNX_layers , Deconvolution )
{
2019-04-19 19:54:08 +08:00
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 ) ;
testONNXModels ( " deconv_adjpad_2d " , npy , 0 , 0 , false , false ) ;
2018-11-17 03:50:40 +08:00
}
2019-07-12 20:51:44 +08:00
TEST_P ( Test_ONNX_layers , Deconvolution3D )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NGRAPH )
{
// [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/frontend/frontend.cpp:592 Failed to compile layer "2":
// [ 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)
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 ) ;
}
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2021-11-30 20:08:35 +08:00
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 ) ;
}
2019-07-12 20:51:44 +08:00
# endif
2021-11-30 20:08:35 +08:00
if ( backend = = DNN_BACKEND_OPENCV )
throw SkipTestException ( " OpenCV backend is not supported " ) ; // FIXIT use tags
2019-07-12 20:51:44 +08:00
testONNXModels ( " deconv3d " ) ;
2021-11-30 20:08:35 +08:00
}
TEST_P ( Test_ONNX_layers , Deconvolution3D_bias )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NGRAPH )
{
// [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/frontend/frontend.cpp:592 Failed to compile layer "3":
// [ 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)
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 ) ;
}
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2021-11-30 20:08:35 +08:00
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
2019-07-12 20:51:44 +08:00
testONNXModels ( " deconv3d_bias " ) ;
2021-11-30 20:08:35 +08:00
}
TEST_P ( Test_ONNX_layers , Deconvolution3D_pad )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NGRAPH )
{
// [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/frontend/frontend.cpp:592 Failed to compile layer "3":
// [ 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)
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 ) ;
}
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2021-11-30 20:08:35 +08:00
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
2019-07-12 20:51:44 +08:00
testONNXModels ( " deconv3d_pad " ) ;
2021-11-30 20:08:35 +08:00
}
TEST_P ( Test_ONNX_layers , Deconvolution3D_adjpad )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NGRAPH )
{
// [ GENERAL_ERROR ] openvino/src/plugins/intel_myriad/graph_transformer/src/frontend/frontend.cpp:592 Failed to compile layer "3":
// [ 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)
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 ) ;
}
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2021-11-30 20:08:35 +08:00
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
2019-07-12 20:51:44 +08:00
testONNXModels ( " deconv3d_adjpad " ) ;
}
2018-09-11 02:07:51 +08:00
TEST_P ( Test_ONNX_layers , Dropout )
{
testONNXModels ( " dropout " ) ;
}
TEST_P ( Test_ONNX_layers , Linear )
{
if ( backend = = DNN_BACKEND_OPENCV & & target = = DNN_TARGET_OPENCL_FP16 )
2019-06-15 20:17:25 +08:00
applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL_FP16 ) ;
2018-09-11 02:07:51 +08:00
testONNXModels ( " linear " ) ;
}
TEST_P ( Test_ONNX_layers , ReLU )
{
testONNXModels ( " ReLU " ) ;
}
2021-09-10 19:07:16 +08:00
TEST_P ( Test_ONNX_layers , PReLU )
{
testONNXModels ( " PReLU_slope " ) ;
}
2019-07-04 13:56:00 +08:00
TEST_P ( Test_ONNX_layers , Clip )
{
testONNXModels ( " clip " , npy ) ;
}
2020-03-17 22:31:01 +08:00
TEST_P ( Test_ONNX_layers , Shape )
{
testONNXModels ( " shape_of_constant " ) ;
}
2019-07-20 00:18:34 +08:00
TEST_P ( Test_ONNX_layers , ReduceMean )
{
testONNXModels ( " reduce_mean " ) ;
2020-04-07 22:12:18 +08:00
testONNXModels ( " reduce_mean_axis1 " ) ;
testONNXModels ( " reduce_mean_axis2 " ) ;
2019-07-20 00:18:34 +08:00
}
2020-08-15 00:49:42 +08:00
TEST_P ( Test_ONNX_layers , ReduceSum )
{
testONNXModels ( " reduce_sum " ) ;
}
2020-11-17 19:45:36 +08:00
TEST_P ( Test_ONNX_layers , ReduceMax )
2020-09-09 15:40:02 +08:00
{
testONNXModels ( " reduce_max " ) ;
2020-11-17 19:45:36 +08:00
testONNXModels ( " reduce_max_axis_0 " ) ;
testONNXModels ( " reduce_max_axis_1 " ) ;
2020-09-09 15:40:02 +08:00
}
2020-09-18 21:01:14 +08:00
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 " ) ;
2021-08-18 23:37:35 +08:00
testONNXModels ( " scale_broadcast " , npy , 0 , 0 , false , true , 3 ) ;
2021-09-09 19:41:40 +08:00
testONNXModels ( " scale_broadcast_mid " , npy , 0 , 0 , false , true , 2 ) ;
2020-09-18 21:01:14 +08:00
}
2019-07-20 00:18:34 +08:00
TEST_P ( Test_ONNX_layers , ReduceMean3D )
{
2021-11-30 20:08:35 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2019-12-02 21:16:06 +08:00
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
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
2021-11-30 20:08:35 +08:00
# endif
if ( backend = = DNN_BACKEND_OPENCV & & target ! = DNN_TARGET_CPU )
throw SkipTestException ( " Only CPU is supported " ) ; // FIXIT use tags
2019-07-20 00:18:34 +08:00
testONNXModels ( " reduce_mean3d " ) ;
}
2018-09-11 02:07:51 +08:00
TEST_P ( Test_ONNX_layers , MaxPooling_Sigmoid )
{
testONNXModels ( " maxpooling_sigmoid " ) ;
}
2020-03-14 19:05:49 +08:00
TEST_P ( Test_ONNX_layers , Cast )
{
testONNXModels ( " cast " ) ;
}
2020-08-24 15:46:53 +08:00
TEST_P ( Test_ONNX_layers , Power )
{
testONNXModels ( " pow2 " , npy , 0 , 0 , false , false ) ;
}
2021-02-21 00:46:00 +08:00
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 " ) ;
}
2018-09-11 02:07:51 +08:00
TEST_P ( Test_ONNX_layers , Concatenation )
{
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
2019-06-15 20:17:25 +08:00
{
2019-12-02 21:16:06 +08:00
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 ) ;
2019-06-15 20:17:25 +08:00
}
2018-09-11 02:07:51 +08:00
testONNXModels ( " concatenation " ) ;
2021-07-01 00:25:42 +08:00
testONNXModels ( " concat_const_blobs " ) ;
2018-09-11 02:07:51 +08:00
}
2019-06-22 15:13:28 +08:00
TEST_P ( Test_ONNX_layers , Eltwise3D )
{
2021-11-30 20:08:35 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2019-12-02 21:16:06 +08:00
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
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
2021-11-30 20:08:35 +08:00
# endif
2019-06-22 15:13:28 +08:00
testONNXModels ( " eltwise3d " ) ;
}
2018-09-11 02:07:51 +08:00
TEST_P ( Test_ONNX_layers , AveragePooling )
{
testONNXModels ( " average_pooling " ) ;
}
2019-04-30 22:08:17 +08:00
TEST_P ( Test_ONNX_layers , MaxPooling3D )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
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 ) ;
}
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2021-11-30 20:08:35 +08:00
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 ) ;
}
2019-06-14 23:17:02 +08:00
# endif
2021-11-30 20:08:35 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2019-12-02 21:16:06 +08:00
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
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
2021-11-30 20:08:35 +08:00
# endif
if ( backend = = DNN_BACKEND_OPENCV & & target ! = DNN_TARGET_CPU )
throw SkipTestException ( " Only CPU is supported " ) ; // FIXIT use tags
2019-10-02 19:05:41 +08:00
testONNXModels ( " max_pool3d " , npy , 0 , 0 , false , false ) ;
2019-04-30 22:08:17 +08:00
}
TEST_P ( Test_ONNX_layers , AvePooling3D )
{
2021-11-30 20:08:35 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2019-12-02 21:16:06 +08:00
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
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
2021-11-30 20:08:35 +08:00
# endif
if ( backend = = DNN_BACKEND_OPENCV & & target ! = DNN_TARGET_CPU )
throw SkipTestException ( " Only CPU is supported " ) ; // FIXIT use tags
2019-04-30 22:08:17 +08:00
testONNXModels ( " ave_pool3d " ) ;
}
2019-07-12 01:13:52 +08:00
TEST_P ( Test_ONNX_layers , PoolConv3D )
{
2021-11-30 20:08:35 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2019-12-02 21:16:06 +08:00
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
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
2021-11-30 20:08:35 +08:00
# endif
if ( backend = = DNN_BACKEND_OPENCV & & target ! = DNN_TARGET_CPU )
throw SkipTestException ( " Only CPU is supported " ) ; // FIXIT use tags
2019-07-12 01:13:52 +08:00
testONNXModels ( " pool_conv_3d " ) ;
}
2018-09-11 02:07:51 +08:00
TEST_P ( Test_ONNX_layers , BatchNormalization )
{
testONNXModels ( " batch_norm " ) ;
}
2019-04-29 15:29:34 +08:00
TEST_P ( Test_ONNX_layers , BatchNormalization3D )
{
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
2019-06-15 20:17:25 +08:00
{
2019-12-02 21:16:06 +08:00
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 ) ;
2019-06-15 20:17:25 +08:00
}
2019-04-29 15:29:34 +08:00
testONNXModels ( " batch_norm_3d " ) ;
}
2020-03-20 00:52:36 +08:00
TEST_P ( Test_ONNX_layers , BatchNormalizationUnfused )
{
2021-03-24 17:28:05 +08:00
# 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
2020-03-20 00:52:36 +08:00
testONNXModels ( " frozenBatchNorm2d " ) ;
}
2020-05-12 20:33:57 +08:00
TEST_P ( Test_ONNX_layers , BatchNormalizationSubgraph )
{
2021-03-24 17:28:05 +08:00
# 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
2020-05-12 20:33:57 +08:00
testONNXModels ( " batch_norm_subgraph " ) ;
}
2021-02-01 17:38:33 +08:00
TEST_P ( Test_ONNX_layers , NormalizeFusionSubgraph )
{
testONNXModels ( " normalize_fusion " ) ;
}
2018-10-09 03:18:41 +08:00
TEST_P ( Test_ONNX_layers , Transpose )
{
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
2019-06-15 20:17:25 +08:00
{
2019-12-02 21:16:06 +08:00
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 ) ;
2019-06-15 20:17:25 +08:00
}
2018-10-09 03:18:41 +08:00
testONNXModels ( " transpose " ) ;
}
2018-09-11 02:07:51 +08:00
TEST_P ( Test_ONNX_layers , Multiplication )
{
2019-06-15 20:17:25 +08:00
if ( backend = = DNN_BACKEND_OPENCV & & target = = DNN_TARGET_OPENCL_FP16 )
applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL_FP16 ) ;
2019-12-02 21:16:06 +08:00
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 ) ;
2018-09-11 02:07:51 +08:00
testONNXModels ( " mul " ) ;
}
2020-04-07 22:12:18 +08:00
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 " ) ;
}
2020-08-12 20:03:46 +08:00
TEST_P ( Test_ONNX_layers , MatMulAdd )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// accuracy
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021010000)
2020-08-12 20:03:46 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER ) ;
2022-03-31 03:03:38 +08:00
# endif
2020-08-12 20:03:46 +08:00
if ( backend = = DNN_BACKEND_OPENCV & & target = = DNN_TARGET_OPENCL_FP16 )
applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL_FP16 ) ;
testONNXModels ( " matmul_add " ) ;
}
2020-04-07 22:12:18 +08:00
TEST_P ( Test_ONNX_layers , Expand )
{
2021-09-09 19:41:40 +08:00
testONNXModels ( " expand " ) ;
testONNXModels ( " expand_identity " ) ;
2020-04-07 22:12:18 +08:00
testONNXModels ( " expand_batch " ) ;
testONNXModels ( " expand_channels " ) ;
2020-08-15 00:49:42 +08:00
testONNXModels ( " expand_neg_batch " ) ;
2020-04-07 22:12:18 +08:00
}
TEST_P ( Test_ONNX_layers , ExpandHW )
{
2020-05-12 20:50:31 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER ) ;
2020-04-07 22:12:18 +08:00
testONNXModels ( " expand_hw " ) ;
}
2018-09-11 02:07:51 +08:00
TEST_P ( Test_ONNX_layers , Constant )
{
2019-06-25 02:55:32 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2018050000)
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 & & target = = DNN_TARGET_MYRIAD
2019-03-29 21:42:58 +08:00
& & getInferenceEngineVPUType ( ) = = CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X )
2019-12-02 21:16:06 +08:00
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X , CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
2019-03-29 21:42:58 +08:00
# endif
2018-09-11 02:07:51 +08:00
testONNXModels ( " constant " ) ;
}
2018-10-31 23:24:05 +08:00
TEST_P ( Test_ONNX_layers , Padding )
{
2019-06-14 23:17:02 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
testONNXModels ( " padding " , npy , 0 , 0 , false , false ) ;
# else
2018-10-31 23:24:05 +08:00
testONNXModels ( " padding " ) ;
2019-06-14 23:17:02 +08:00
# endif
2018-10-31 23:24:05 +08:00
}
2019-02-22 00:48:46 +08:00
TEST_P ( Test_ONNX_layers , Resize )
{
testONNXModels ( " resize_nearest " ) ;
2020-02-18 03:29:37 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER ) ;
testONNXModels ( " resize_bilinear " ) ;
2019-02-22 00:48:46 +08:00
}
2020-02-13 20:02:35 +08:00
TEST_P ( Test_ONNX_layers , ResizeUnfused )
{
2020-03-02 20:45:29 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER ) ;
2020-03-01 17:39:15 +08:00
testONNXModels ( " upsample_unfused_torch1.2 " ) ;
2020-02-13 20:02:35 +08:00
testONNXModels ( " upsample_unfused_opset9_torch1.4 " ) ;
testONNXModels ( " resize_nearest_unfused_opset11_torch1.4 " ) ;
testONNXModels ( " resize_nearest_unfused_opset11_torch1.3 " ) ;
2020-04-10 14:36:09 +08:00
testONNXModels ( " resize_bilinear_unfused_opset11_torch1.4 " ) ;
2020-02-13 20:02:35 +08:00
}
2020-03-20 00:52:36 +08:00
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 ) ;
}
2018-09-11 02:07:51 +08:00
TEST_P ( Test_ONNX_layers , MultyInputs )
{
2020-03-06 04:53:50 +08:00
testONNXModels ( " multy_inputs " , npy , 0 , 0 , false , true , 2 ) ;
}
2018-09-11 02:07:51 +08:00
2020-03-06 04:53:50 +08:00
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 ) ;
2018-09-11 02:07:51 +08:00
}
2020-03-17 22:31:01 +08:00
TEST_P ( Test_ONNX_layers , DynamicResize )
{
2020-11-20 19:14:00 +08:00
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_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 ) ;
2020-03-17 22:31:01 +08:00
}
2021-09-01 18:10:05 +08:00
TEST_P ( Test_ONNX_layers , Resize_HumanSeg )
{
testONNXModels ( " resize_humanseg " ) ;
}
2019-11-09 19:11:09 +08:00
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 ) ;
2019-12-24 18:34:33 +08:00
// 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 " ) ) ;
2019-11-09 19:11:09 +08:00
Mat ref = blobFromNPY ( _tf ( " data/output_div.npy " ) ) ;
2019-12-24 18:34:33 +08:00
cv : : divide ( 1.0 , ref , ref ) ;
2019-11-09 19:11:09 +08:00
checkBackend ( & inp1 , & ref ) ;
net . setInput ( inp1 , " 0 " ) ;
net . setInput ( inp2 , " 1 " ) ;
Mat out = net . forward ( ) ;
normAssert ( ref , out , " " , default_l1 , default_lInf ) ;
expectNoFallbacksFromIE ( net ) ;
}
2018-12-12 22:36:17 +08:00
TEST_P ( Test_ONNX_layers , DynamicReshape )
{
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
2020-03-17 22:31:01 +08:00
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER ) ;
2018-12-12 22:36:17 +08:00
testONNXModels ( " dynamic_reshape " ) ;
2020-03-04 16:27:10 +08:00
testONNXModels ( " dynamic_reshape_opset_11 " ) ;
testONNXModels ( " flatten_by_prod " ) ;
2020-03-14 19:05:49 +08:00
testONNXModels ( " flatten_const " ) ;
2018-12-12 22:36:17 +08:00
}
2018-09-11 02:07:51 +08:00
2019-02-22 00:48:46 +08:00
TEST_P ( Test_ONNX_layers , Reshape )
{
testONNXModels ( " unsqueeze " ) ;
2021-09-17 20:10:57 +08:00
testONNXModels ( " unsqueeze_opset_13 " ) ;
2019-02-22 00:48:46 +08:00
}
2019-11-09 19:11:09 +08:00
TEST_P ( Test_ONNX_layers , Squeeze )
{
2020-03-22 21:04:30 +08:00
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 ) ;
2019-11-09 19:11:09 +08:00
testONNXModels ( " squeeze " ) ;
}
TEST_P ( Test_ONNX_layers , ReduceL2 )
{
testONNXModels ( " reduceL2 " ) ;
2020-04-07 22:12:18 +08:00
testONNXModels ( " reduceL2_subgraph " ) ;
2020-03-28 23:53:57 +08:00
testONNXModels ( " reduceL2_subgraph_2 " ) ;
2021-09-09 19:41:40 +08:00
testONNXModels ( " reduceL2_subgraph2_2 " ) ;
2019-11-09 19:11:09 +08:00
}
2020-02-15 19:12:20 +08:00
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 " ) ;
2021-08-16 20:44:54 +08:00
testONNXModels ( " split_sizes " ) ;
2021-09-09 19:41:40 +08:00
testONNXModels ( " split_neg_axis " ) ;
2020-02-15 19:12:20 +08:00
}
2019-06-08 21:52:40 +08:00
TEST_P ( Test_ONNX_layers , Slice )
{
2019-06-14 23:17:02 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
testONNXModels ( " slice " , npy , 0 , 0 , false , false ) ;
# else
2019-06-08 21:52:40 +08:00
testONNXModels ( " slice " ) ;
2021-09-09 19:41:40 +08:00
testONNXModels ( " slice_neg_starts " ) ;
2020-03-17 22:31:01 +08:00
testONNXModels ( " slice_opset_11 " ) ;
2019-06-14 23:17:02 +08:00
# endif
2019-06-08 21:52:40 +08:00
}
2021-03-26 19:04:57 +08:00
TEST_P ( Test_ONNX_layers , Slice_Steps_2DInput )
{
testONNXModels ( " slice_opset_11_steps_2d " ) ;
}
TEST_P ( Test_ONNX_layers , Slice_Steps_3DInput )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// Cannot get memory!
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
// IE exception: Cannot get memory!
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
2021-03-26 19:04:57 +08:00
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 )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// Cannot get memory!
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
// IE exception: Cannot get memory!
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
) ;
// Cannot get memory!
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
2021-03-26 19:04:57 +08:00
testONNXModels ( " slice_opset_11_steps_5d " ) ;
}
2019-05-20 15:46:09 +08:00
TEST_P ( Test_ONNX_layers , Softmax )
{
testONNXModels ( " softmax " ) ;
2019-04-30 20:33:32 +08:00
testONNXModels ( " log_softmax " , npy , 0 , 0 , false , false ) ;
2020-01-06 19:03:05 +08:00
testONNXModels ( " softmax_unfused " ) ;
2019-05-20 15:46:09 +08:00
}
2019-07-28 03:10:13 +08:00
TEST_P ( Test_ONNX_layers , Split_EltwiseMax )
{
2019-12-02 21:16:06 +08:00
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 ) ;
2019-07-28 03:10:13 +08:00
testONNXModels ( " split_max " ) ;
}
2021-08-13 20:41:00 +08:00
TEST_P ( Test_ONNX_layers , LSTM_Activations )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// Cannot get memory!
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
// IE exception: Node Block1326/lstm/reshape_0/permute was not assigned on any pointed device
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
) ;
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2021-11-26 03:56:27 +08:00
// 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
2021-08-13 20:41:00 +08:00
testONNXModels ( " lstm_cntk_tanh " , pb , 0 , 0 , false , false ) ;
}
2022-03-15 14:14:05 +08:00
// disabled due to poor handling of 1-d mats
TEST_P ( Test_ONNX_layers , DISABLED_LSTM )
2020-03-16 03:33:05 +08:00
{
2020-03-22 21:04:30 +08:00
testONNXModels ( " lstm " , npy , 0 , 0 , false , false ) ;
2020-03-16 03:33:05 +08:00
}
2022-03-15 14:14:05 +08:00
// disabled due to poor handling of 1-d mats
TEST_P ( Test_ONNX_layers , DISABLED_LSTM_bidirectional )
2020-03-22 05:20:36 +08:00
{
2020-03-22 21:04:30 +08:00
testONNXModels ( " lstm_bidirectional " , npy , 0 , 0 , false , false ) ;
2020-03-22 05:20:36 +08:00
}
2021-07-23 22:11:50 +08:00
TEST_P ( Test_ONNX_layers , LSTM_hidden )
{
testONNXModels ( " hidden_lstm " , npy , 0 , 0 , false , false ) ;
}
TEST_P ( Test_ONNX_layers , LSTM_hidden_bidirectional )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// Cannot get memory!
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
// IE exception: Node Transpose_45 was not assigned on any pointed device.
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
2021-07-23 22:11:50 +08:00
testONNXModels ( " hidden_lstm_bi " , npy , 0 , 0 , false , false ) ;
}
2022-03-30 18:47:59 +08:00
TEST_P ( Test_ONNX_layers , LSTM_cell_forward )
2022-03-15 14:14:05 +08:00
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// accuracy!
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2022-03-30 18:47:59 +08:00
// 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
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_VERSION ) ;
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_VERSION ) ;
# endif
2022-03-15 14:14:05 +08:00
testONNXModels ( " lstm_cell_forward " , npy , 0 , 0 , false , false ) ;
2022-03-30 18:47:59 +08:00
}
TEST_P ( Test_ONNX_layers , LSTM_cell_bidirectional )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// Cannot get memory!
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2022-03-30 18:47:59 +08:00
// 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
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_VERSION ) ;
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_VERSION ) ;
# endif
2022-03-15 14:14:05 +08:00
testONNXModels ( " lstm_cell_bidirectional " , npy , 0 , 0 , false , false ) ;
2022-03-30 18:47:59 +08:00
}
TEST_P ( Test_ONNX_layers , LSTM_cell_with_peepholes )
{
2022-03-15 14:14:05 +08:00
testONNXModels ( " lstm_cell_with_peepholes " , npy , 0 , 0 , false , false ) ;
}
2020-04-05 13:32:12 +08:00
TEST_P ( Test_ONNX_layers , Pad2d_Unfused )
{
testONNXModels ( " ReflectionPad2d " ) ;
testONNXModels ( " ZeroPad2d " ) ;
}
2020-08-26 18:15:59 +08:00
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
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 " ) ;
}
2020-09-17 19:05:22 +08:00
TEST_P ( Test_ONNX_layers , ResizeOpset11_Torch1_6 )
{
testONNXModels ( " resize_opset11_torch1.6 " ) ;
}
2021-01-15 19:01:48 +08:00
TEST_P ( Test_ONNX_layers , Mish )
{
testONNXModels ( " mish " ) ;
}
2021-01-26 06:07:50 +08:00
TEST_P ( Test_ONNX_layers , CalculatePads )
{
testONNXModels ( " calc_pads " ) ;
}
2020-11-14 06:22:10 +08:00
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 )
{
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 )
{
2020-11-17 19:33:39 +08:00
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 ) ;
2021-03-20 19:20:02 +08:00
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 ) ;
2020-11-17 19:33:39 +08:00
}
2020-11-14 06:22:10 +08:00
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 ) ;
}
2020-11-17 17:52:08 +08:00
TEST_P ( Test_ONNX_layers , GatherMultiOutput )
{
2021-11-26 03:56:27 +08:00
# 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
2021-03-24 17:28:05 +08:00
# 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
2021-11-26 03:56:27 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LE(2021030000)
2020-11-18 03:52:07 +08:00
if ( target = = DNN_TARGET_MYRIAD )
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_MYRIAD , CV_TEST_TAG_DNN_SKIP_IE ) ;
# endif
2020-11-17 17:52:08 +08:00
testONNXModels ( " gather_multi_output " ) ;
}
2021-12-23 08:39:09 +08:00
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 )
2020-11-17 18:31:04 +08:00
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
2021-11-26 03:56:27 +08:00
// 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
) ;
2022-03-31 03:03:38 +08:00
# elif 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
) ;
# elif defined(INF_ENGINE_RELEASE)
2020-11-17 18:31:04 +08:00
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 ) ;
}
2021-11-26 03:56:27 +08:00
# if INF_ENGINE_VER_MAJOR_LT(2021000000)
2020-11-17 18:31:04 +08:00
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 ) ;
}
2021-11-26 03:56:27 +08:00
# endif
# endif
2020-11-17 18:31:04 +08:00
testONNXModels ( " gather_scalar_dynamic_axes " ) ;
2021-12-23 08:39:09 +08:00
}
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
2020-11-17 18:31:04 +08:00
testONNXModels ( " slice_dynamic_axes " ) ;
2021-12-23 08:39:09 +08:00
}
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
2020-11-17 18:31:04 +08:00
testONNXModels ( " slice_opset_11_dynamic_axes " ) ;
2021-12-23 08:39:09 +08:00
}
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
2020-11-17 18:31:04 +08:00
testONNXModels ( " resize_opset11_torch1.6_dynamic_axes " ) ;
2021-12-23 08:39:09 +08:00
}
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
2020-11-17 18:31:04 +08:00
testONNXModels ( " average_pooling_dynamic_axes " ) ;
2021-12-23 08:39:09 +08:00
}
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
2020-11-17 18:31:04 +08:00
testONNXModels ( " maxpooling_sigmoid_dynamic_axes " ) ;
2021-12-23 08:39:09 +08:00
}
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
2021-08-18 23:37:35 +08:00
testONNXModels ( " dynamic_batch " ) ;
2020-11-17 18:31:04 +08:00
}
2021-12-23 08:39:09 +08:00
2020-11-25 00:52:45 +08:00
TEST_P ( Test_ONNX_layers , MaxPool1d )
{
2021-11-30 20:08:35 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2020-11-25 00:52:45 +08:00
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 ) ;
}
2021-11-30 20:08:35 +08:00
# 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
2020-11-25 00:52:45 +08:00
testONNXModels ( " maxpooling_1d " ) ;
}
TEST_P ( Test_ONNX_layers , MaxPoolSigmoid1d )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2020-11-25 00:52:45 +08:00
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 ) ;
}
2021-11-30 20:08:35 +08:00
# endif
2020-11-25 00:52:45 +08:00
testONNXModels ( " maxpooling_sigmoid_1d " ) ;
}
TEST_P ( Test_ONNX_layers , MaxPool1d_Twise )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// Cannot get memory!
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
// Cannot get memory!
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
) ;
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2020-11-25 00:52:45 +08:00
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 ) ;
}
2021-11-30 20:08:35 +08:00
# endif
2020-11-25 00:52:45 +08:00
testONNXModels ( " two_maxpooling_1d " ) ;
}
TEST_P ( Test_ONNX_layers , AvePool1d )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// Cannot get memory!
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 ) ;
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2020-11-25 00:52:45 +08:00
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 ) ;
}
2021-11-30 20:08:35 +08:00
# endif
2020-11-25 00:52:45 +08:00
testONNXModels ( " average_pooling_1d " ) ;
}
TEST_P ( Test_ONNX_layers , PoolConv1d )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// Cannot get memory!
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 , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
// Cannot get memory!
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 ) ;
// Cannot get memory!
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
) ;
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2020-11-25 00:52:45 +08:00
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 ) ;
}
2021-11-30 20:08:35 +08:00
# endif
2020-11-25 00:52:45 +08:00
testONNXModels ( " pool_conv_1d " ) ;
}
TEST_P ( Test_ONNX_layers , ConvResizePool1d )
{
2021-11-26 03:56:27 +08:00
# 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
2021-03-24 17:28:05 +08:00
# if defined(INF_ENGINE_RELEASE)
2020-11-25 00:52:45 +08:00
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 ) ;
2021-03-24 17:28:05 +08:00
# 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
2020-11-25 00:52:45 +08:00
}
2021-03-24 17:28:05 +08:00
# endif
2020-11-25 00:52:45 +08:00
testONNXModels ( " conv_resize_pool_1d " ) ;
}
2021-10-11 23:58:10 +08:00
TEST_P ( Test_ONNX_layers , SubFromConst )
{
testONNXModels ( " sub_from_const1 " ) ;
testONNXModels ( " sub_from_const_eltwise " ) ;
testONNXModels ( " sub_from_const_broadcast " ) ;
}
2021-12-21 00:53:37 +08:00
TEST_P ( Test_ONNX_layers , DivConst )
{
testONNXModels ( " div_const " ) ;
}
2022-06-22 21:08:48 +08:00
TEST_P ( Test_ONNX_layers , Gemm )
{
testONNXModels ( " gemm_no_transB " ) ;
testONNXModels ( " gemm_transB_0 " ) ;
}
2022-05-23 22:50:42 +08:00
TEST_P ( Test_ONNX_layers , OutputRegistration )
{
testONNXModels ( " output_registration " , npy , 0 , 0 , false , true , 2 ) ;
}
2018-09-11 02:07:51 +08:00
INSTANTIATE_TEST_CASE_P ( /*nothing*/ , Test_ONNX_layers , dnnBackendsAndTargets ( ) ) ;
2019-06-20 21:43:28 +08:00
class Test_ONNX_nets : public Test_ONNX_layers
{
public :
Test_ONNX_nets ( ) { required = false ; }
} ;
2018-09-11 02:07:51 +08:00
TEST_P ( Test_ONNX_nets , Alexnet )
{
2020-04-30 04:01:10 +08:00
# if defined(OPENCV_32BIT_CONFIGURATION) && (defined(HAVE_OPENCL) || defined(_WIN32))
2020-02-21 04:23:19 +08:00
applyTestTag ( CV_TEST_TAG_MEMORY_2GB ) ;
# else
2018-10-09 06:38:06 +08:00
applyTestTag ( target = = DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB ) ;
2020-02-21 04:23:19 +08:00
# endif
2019-06-20 21:43:28 +08:00
const String model = _tf ( " models/alexnet.onnx " , false ) ;
2018-09-11 02:07:51 +08:00
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 ) ;
2019-04-19 19:54:08 +08:00
expectNoFallbacksFromIE ( net ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_nets , Squeezenet )
{
testONNXModels ( " squeezenet " , pb ) ;
}
TEST_P ( Test_ONNX_nets , Googlenet )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// 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 ) ;
# elif 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 ) ;
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER ) ;
2018-09-11 02:07:51 +08:00
2019-12-24 18:34:33 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NGRAPH )
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_NGRAPH ) ;
2021-11-30 20:08:35 +08:00
# endif
2019-12-24 18:34:33 +08:00
2019-06-20 21:43:28 +08:00
const String model = _tf ( " models/googlenet.onnx " , false ) ;
2018-09-11 02:07:51 +08:00
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 ) ;
2019-04-19 19:54:08 +08:00
expectNoFallbacksFromIE ( net ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_nets , CaffeNet )
{
2020-04-30 04:01:10 +08:00
# if defined(OPENCV_32BIT_CONFIGURATION) && (defined(HAVE_OPENCL) || defined(_WIN32))
2020-02-21 04:23:19 +08:00
applyTestTag ( CV_TEST_TAG_MEMORY_2GB ) ;
# else
2018-10-09 06:38:06 +08:00
applyTestTag ( target = = DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB ) ;
2020-02-21 04:23:19 +08:00
# endif
2019-10-04 15:29:27 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019030000)
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 & & target = = DNN_TARGET_MYRIAD
2019-10-04 15:29:27 +08:00
& & getInferenceEngineVPUType ( ) = = CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X )
2019-12-02 21:16:06 +08:00
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X , CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
2019-10-04 15:29:27 +08:00
# endif
2018-09-11 02:07:51 +08:00
testONNXModels ( " caffenet " , pb ) ;
}
TEST_P ( Test_ONNX_nets , RCNN_ILSVRC13 )
{
2020-04-30 04:01:10 +08:00
# if defined(OPENCV_32BIT_CONFIGURATION) && (defined(HAVE_OPENCL) || defined(_WIN32))
2020-02-21 04:23:19 +08:00
applyTestTag ( CV_TEST_TAG_MEMORY_2GB ) ;
# else
2018-10-09 06:38:06 +08:00
applyTestTag ( target = = DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB ) ;
2020-02-21 04:23:19 +08:00
# endif
2019-10-04 15:29:27 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019030000)
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 & & target = = DNN_TARGET_MYRIAD
2019-10-04 15:29:27 +08:00
& & getInferenceEngineVPUType ( ) = = CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X )
2019-12-02 21:16:06 +08:00
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X , CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER , CV_TEST_TAG_DNN_SKIP_IE_VERSION ) ;
2019-10-04 15:29:27 +08:00
# endif
2019-03-29 21:42:58 +08:00
// Reference output values are in range [-4.992, -1.161]
2019-12-24 18:34:33 +08:00
testONNXModels ( " rcnn_ilsvrc13 " , pb , 0.0046 ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_nets , VGG16_bn )
{
2018-10-09 06:38:06 +08:00
applyTestTag ( CV_TEST_TAG_MEMORY_6GB ) ; // > 2.3Gb
2019-03-29 21:42:58 +08:00
// 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 ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_nets , ZFNet )
{
2019-05-27 20:14:18 +08:00
applyTestTag ( CV_TEST_TAG_MEMORY_2GB ) ;
2018-09-11 02:07:51 +08:00
testONNXModels ( " zfnet512 " , pb ) ;
}
TEST_P ( Test_ONNX_nets , ResNet18v1 )
{
2018-10-09 06:38:06 +08:00
applyTestTag ( CV_TEST_TAG_MEMORY_512MB ) ;
2019-03-29 21:42:58 +08:00
// output range: [-16; 22], after Softmax [0, 0.51]
2019-05-30 22:36:00 +08:00
testONNXModels ( " resnet18v1 " , pb , default_l1 , default_lInf , true , target ! = DNN_TARGET_MYRIAD ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_nets , ResNet50v1 )
{
2018-10-09 06:38:06 +08:00
applyTestTag ( CV_TEST_TAG_MEMORY_512MB ) ;
2019-03-29 21:42:58 +08:00
// output range: [-67; 75], after Softmax [0, 0.98]
2019-05-30 22:36:00 +08:00
testONNXModels ( " resnet50v1 " , pb , default_l1 , default_lInf , true , target ! = DNN_TARGET_MYRIAD ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_nets , ResNet101_DUC_HDC )
{
2018-10-09 06:38:06 +08:00
applyTestTag ( CV_TEST_TAG_VERYLONG ) ;
2019-04-01 20:00:25 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2019010000)
2019-12-02 21:16:06 +08:00
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 ) ;
2019-03-29 21:42:58 +08:00
# endif
# if defined(INF_ENGINE_RELEASE)
2019-12-02 21:16:06 +08:00
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 ) ;
2019-03-29 21:42:58 +08:00
# endif
if ( target = = DNN_TARGET_OPENCL_FP16 | | target = = DNN_TARGET_OPENCL )
2019-06-15 20:17:25 +08:00
{
if ( backend = = DNN_BACKEND_OPENCV )
applyTestTag ( target = = DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_OPENCL : CV_TEST_TAG_DNN_SKIP_OPENCL_FP16 ) ;
2019-03-29 21:42:58 +08:00
throw SkipTestException ( " Test is disabled for OpenCL targets " ) ;
2019-06-15 20:17:25 +08:00
}
2018-09-11 02:07:51 +08:00
testONNXModels ( " resnet101_duc_hdc " , pb ) ;
}
TEST_P ( Test_ONNX_nets , TinyYolov2 )
{
2018-10-09 06:38:06 +08:00
applyTestTag ( CV_TEST_TAG_MEMORY_512MB ) ;
2019-03-29 21:42:58 +08:00
if ( cvtest : : skipUnstableTests )
throw SkipTestException ( " Skip unstable test " ) ;
# if defined(INF_ENGINE_RELEASE)
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019
2019-03-29 21:42:58 +08:00
& & ( target = = DNN_TARGET_OPENCL | | target = = DNN_TARGET_OPENCL_FP16 )
)
2019-12-02 21:16:06 +08:00
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 ) ;
2019-03-29 21:42:58 +08:00
2019-12-24 18:34:33 +08:00
if ( target = = DNN_TARGET_MYRIAD & & getInferenceEngineVPUType ( ) = = CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X
2019-03-29 21:42:58 +08:00
)
2019-12-24 18:34:33 +08:00
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 ) ;
2019-03-29 21:42:58 +08:00
# endif
2018-10-09 06:38:06 +08:00
2018-09-11 02:07:51 +08:00
// output range: [-11; 8]
2021-11-26 03:56:27 +08:00
double l1 = default_l1 , lInf = default_lInf ;
if ( target = = DNN_TARGET_OPENCL_FP16 | | target = = DNN_TARGET_MYRIAD )
{
l1 = 0.02 ;
lInf = 0.2 ;
}
2020-07-16 06:52:08 +08:00
# 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
2018-09-11 02:07:51 +08:00
testONNXModels ( " tiny_yolo2 " , pb , l1 , lInf ) ;
}
TEST_P ( Test_ONNX_nets , CNN_MNIST )
{
2019-03-29 21:42:58 +08:00
// output range: [-1952; 6574], after Softmax [0; 1]
testONNXModels ( " cnn_mnist " , pb , default_l1 , default_lInf , true ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_nets , MobileNet_v2 )
{
2019-03-29 21:42:58 +08:00
// output range: [-166; 317], after Softmax [0; 1]
testONNXModels ( " mobilenetv2 " , pb , default_l1 , default_lInf , true ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_nets , LResNet100E_IR )
{
2019-05-27 20:14:18 +08:00
applyTestTag (
2020-02-25 02:18:33 +08:00
# if defined(OPENCV_32BIT_CONFIGURATION) && defined(HAVE_OPENCL)
CV_TEST_TAG_MEMORY_2GB ,
# else
2019-05-27 20:14:18 +08:00
( target = = DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB ) ,
2020-02-25 02:18:33 +08:00
# endif
2019-05-27 20:14:18 +08:00
CV_TEST_TAG_DEBUG_LONG
) ;
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
2019-06-15 20:17:25 +08:00
{
2019-12-02 21:16:06 +08:00
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 ) ;
2019-06-15 20:17:25 +08:00
}
2019-12-24 18:34:33 +08:00
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 ) ;
}
2018-09-11 02:07:51 +08:00
double l1 = default_l1 ;
double lInf = default_lInf ;
// output range: [-3; 3]
if ( backend = = DNN_BACKEND_OPENCV & & target = = DNN_TARGET_OPENCL_FP16 ) {
l1 = 0.009 ;
lInf = 0.035 ;
}
2019-12-02 21:16:06 +08:00
else if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 & & target = = DNN_TARGET_CPU ) {
2019-04-08 16:29:10 +08:00
l1 = 4.6e-5 ;
2019-01-14 14:55:44 +08:00
lInf = 1.9e-4 ;
}
2018-09-11 02:07:51 +08:00
testONNXModels ( " LResNet100E_IR " , pb , l1 , lInf ) ;
}
TEST_P ( Test_ONNX_nets , Emotion_ferplus )
{
2019-03-29 21:42:58 +08:00
# if defined(INF_ENGINE_RELEASE)
2019-12-24 18:34:33 +08:00
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 ) ;
2019-03-29 21:42:58 +08:00
# endif
2018-12-20 18:14:47 +08:00
double l1 = default_l1 ;
double lInf = default_lInf ;
2019-03-29 21:42:58 +08:00
// Output values are in range [-2.011, 2.111]
2018-12-20 18:14:47 +08:00
if ( backend = = DNN_BACKEND_OPENCV & & target = = DNN_TARGET_OPENCL_FP16 )
l1 = 0.007 ;
2019-12-02 21:16:06 +08:00
else if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 & & target = = DNN_TARGET_OPENCL_FP16 )
2018-12-20 18:14:47 +08:00
{
l1 = 0.021 ;
lInf = 0.034 ;
}
2019-12-02 21:16:06 +08:00
else if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 & & ( target = = DNN_TARGET_CPU | | target = = DNN_TARGET_OPENCL ) ) {
2019-01-14 14:55:44 +08:00
l1 = 2.4e-4 ;
lInf = 6e-4 ;
}
2021-11-26 03:56:27 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_GE(2020040000)
2020-07-16 06:52:08 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NGRAPH & & target = = DNN_TARGET_OPENCL_FP16 )
{
2021-11-26 03:56:27 +08:00
l1 = 0.013f ; lInf = 0.035f ;
2020-07-16 06:52:08 +08:00
}
# endif
2018-12-20 18:14:47 +08:00
testONNXModels ( " emotion_ferplus " , pb , l1 , lInf ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_nets , Inception_v2 )
{
2019-03-29 21:42:58 +08:00
testONNXModels ( " inception_v2 " , pb , default_l1 , default_lInf , true ) ;
2018-09-11 02:07:51 +08:00
}
TEST_P ( Test_ONNX_nets , DenseNet121 )
{
2018-10-09 06:38:06 +08:00
applyTestTag ( CV_TEST_TAG_MEMORY_512MB ) ;
2019-03-29 21:42:58 +08:00
// output range: [-87; 138], after Softmax [0; 1]
2019-05-30 22:36:00 +08:00
testONNXModels ( " densenet121 " , pb , default_l1 , default_lInf , true , target ! = DNN_TARGET_MYRIAD ) ;
2018-09-11 02:07:51 +08:00
}
2018-09-18 01:26:17 +08:00
TEST_P ( Test_ONNX_nets , Inception_v1 )
{
2021-11-30 20:08:35 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2019-12-24 18:34:33 +08:00
if ( ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 | |
backend = = DNN_BACKEND_INFERENCE_ENGINE_NGRAPH ) & & target = = DNN_TARGET_MYRIAD )
2019-06-15 20:17:25 +08:00
applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_MYRIAD ) ;
2018-12-20 18:14:47 +08:00
# endif
2018-09-18 01:26:17 +08:00
testONNXModels ( " inception_v1 " , pb ) ;
}
2018-09-11 02:07:51 +08:00
2018-10-09 03:18:41 +08:00
TEST_P ( Test_ONNX_nets , Shufflenet )
{
2021-11-30 20:08:35 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2021040000)
2019-12-02 21:16:06 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 )
2019-06-15 20:17:25 +08:00
{
2019-12-02 21:16:06 +08:00
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 ) ;
2019-06-15 20:17:25 +08:00
}
2021-11-30 20:08:35 +08:00
# endif
2018-10-09 03:18:41 +08:00
testONNXModels ( " shufflenet " , pb ) ;
}
2019-05-30 22:36:00 +08:00
TEST_P ( Test_ONNX_nets , Resnet34_kinetics )
{
2022-03-31 03:03:38 +08:00
# if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)
// IE exception: Failed to allocate graph: MYRIAD device is not opened
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 ) ;
// 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
) ;
# elif defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2021040000)
2021-11-30 20:08:35 +08:00
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 ) ;
}
2022-03-31 03:03:38 +08:00
# elif 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
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
2021-11-30 20:08:35 +08:00
# endif
if ( backend = = DNN_BACKEND_OPENCV & & target ! = DNN_TARGET_CPU )
throw SkipTestException ( " Only CPU is supported " ) ; // FIXIT use tags
2019-05-30 22:36:00 +08:00
2019-07-16 15:53:50 +08:00
String onnxmodel = findDataFile ( " dnn/resnet-34_kinetics.onnx " , false ) ;
2019-05-30 22:36:00 +08:00
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 ) ;
2019-12-02 21:16:06 +08:00
permute . setPreferableBackend ( backend ) ;
permute . setPreferableTarget ( target ) ;
2019-05-30 22:36:00 +08:00
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 ;
2021-11-30 20:08:35 +08:00
if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NGRAPH & & target = = DNN_TARGET_OPENCL_FP16 )
{
l1 = 0.02 ;
lInf = 0.07 ;
}
2019-05-30 22:36:00 +08:00
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 ) ;
}
2018-09-11 02:07:51 +08:00
INSTANTIATE_TEST_CASE_P ( /**/ , Test_ONNX_nets , dnnBackendsAndTargets ( ) ) ;
} } // namespace