Merge pull request #18353 from l-bat:issue_18350
authorLiubov Batanina <piccione-mail@yandex.ru>
Fri, 18 Sep 2020 13:01:14 +0000 (16:01 +0300)
committerGitHub <noreply@github.com>
Fri, 18 Sep 2020 13:01:14 +0000 (13:01 +0000)
* Fixed bug in ONNX Mul op

* Replaced node

modules/dnn/src/onnx/onnx_importer.cpp
modules/dnn/test/test_onnx_importer.cpp

index 318c2cc290e518888744173b4753cd8d60da66a8..58e5cf75f54a145cb03d68fe2f45938b88e7e579 100644 (file)
@@ -1051,6 +1051,16 @@ void ONNXImporter::populateNet(Net dstNet)
             }
             else
             {
+                // Scale layer allocate output with the first input shape
+                if (total(outShapes[node_proto.input(0)]) < total(outShapes[node_proto.input(1)]))
+                {
+                    opencv_onnx::NodeProto proto;
+                    proto.add_input(node_proto.input(1));
+                    proto.add_input(node_proto.input(0));
+                    proto.add_output(layerParams.name);
+                    node_proto = proto;
+                }
+
                 if (isDiv)
                 {
                     LayerParams powerParams;
index 4234fa8d8b6d43dd79d7196dbcfb55bec0cc6a06..993ba56be412ff7d1334e5043af37eeace0dd73a 100644 (file)
@@ -267,6 +267,13 @@ TEST_P(Test_ONNX_layers, ReduceMaxGlobal)
     testONNXModels("reduce_max");
 }
 
+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");
+}
+
 TEST_P(Test_ONNX_layers, ReduceMean3D)
 {
     if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)