Skip to content

Commit 9aa401a

Browse files
authored
Merge pull request opencv#17978 from sl-sergei:fix_17516_17531
* Fix ONNX loading in issues opencv#17516, opencv#17531 * Add tests for Linear and Matmul layers * Disable tests for IE versions lower than 20.4 * Skip unstable tests with OpenCL FP16 on Intel GPU * Add correct test filtering for OpenCL FP16 tests
1 parent a160e4f commit 9aa401a

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

modules/dnn/src/onnx/onnx_importer.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,19 @@ void ONNXImporter::populateNet(Net dstNet)
946946
Mat bias = getBlob(node_proto, constBlobs, 2);
947947
layerParams.blobs.push_back(bias);
948948
}
949+
if (constBlobs.find(node_proto.input(0)) != constBlobs.end())
950+
{
951+
Mat inputBuf = getBlob(node_proto, constBlobs, 0);
952+
953+
LayerParams constParams;
954+
constParams.name = node_proto.input(0);
955+
constParams.type = "Const";
956+
constParams.blobs.push_back(inputBuf);
957+
958+
opencv_onnx::NodeProto proto;
959+
proto.add_output(constParams.name);
960+
addLayer(dstNet, constParams, proto, layer_id, outShapes);
961+
}
949962

950963
layerParams.set("num_output", layerParams.blobs[0].size[ind_num_out]);
951964
layerParams.set("bias_term", node_proto.input_size() == 3);

modules/dnn/test/test_onnx_importer.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,26 @@ TEST_P(Test_ONNX_layers, Pad2d_Unfused)
611611
testONNXModels("ZeroPad2d");
612612
}
613613

614+
TEST_P(Test_ONNX_layers, LinearWithConstant)
615+
{
616+
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
617+
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
618+
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2020040000)
619+
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE);
620+
#endif
621+
testONNXModels("lin_with_constant");
622+
}
623+
624+
TEST_P(Test_ONNX_layers, MatmulWithTwoInputs)
625+
{
626+
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
627+
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
628+
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2020040000)
629+
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE);
630+
#endif
631+
testONNXModels("matmul_with_two_inputs");
632+
}
633+
614634
INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_ONNX_layers, dnnBackendsAndTargets());
615635

616636
class Test_ONNX_nets : public Test_ONNX_layers

0 commit comments

Comments
 (0)