Merge pull request #14833 from l-bat:ocv_eltwise3d
authorLubov Batanina <piccione-mail@yandex.ru>
Sat, 22 Jun 2019 07:13:28 +0000 (10:13 +0300)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Sat, 22 Jun 2019 07:13:28 +0000 (10:13 +0300)
* Support Eltwise3d

* Refactoring

* Fix test

modules/dnn/src/layers/eltwise_layer.cpp
modules/dnn/test/test_onnx_importer.cpp

index f332c44..6b5db7c 100644 (file)
@@ -140,7 +140,7 @@ public:
                         const std::vector<float>& coeffs, EltwiseOp op,
                         const ActivationLayer* activ, int nstripes)
         {
-            CV_Check(dst.dims, 1 < dst.dims && dst.dims <= 4, ""); CV_CheckTypeEQ(dst.type(), CV_32FC1, ""); CV_Assert(dst.isContinuous());
+            CV_Check(dst.dims, 1 < dst.dims && dst.dims <= 5, ""); CV_CheckTypeEQ(dst.type(), CV_32FC1, ""); CV_Assert(dst.isContinuous());
             CV_Assert(coeffs.empty() || coeffs.size() == (size_t)nsrcs);
 
             for( int i = 0; i < nsrcs; i++ )
@@ -156,9 +156,9 @@ public:
             p.dst = &dst;
             p.op = op;
             p.nstripes = nstripes;
-            p.channels = (dst.dims == 4 ? dst.size[1] : 1);
-            p.planeSize = (dst.dims >= 3 ? dst.size[dst.dims - 1] * dst.size[dst.dims - 2] :
-                                           dst.size[dst.dims - 1]);
+            p.channels = (dst.dims >= 4 ? dst.size[1] : 1);
+
+            p.planeSize = dst.total(dst.dims >= 4 ? 2 : 1);
             CV_Assert(dst.total() == dst.size[0] * p.channels * p.planeSize);
 
             bool simpleCoeffs = true;
index e132bf6..f1e0c5e 100644 (file)
@@ -146,6 +146,16 @@ TEST_P(Test_ONNX_layers, Concatenation)
     testONNXModels("concatenation");
 }
 
+TEST_P(Test_ONNX_layers, Eltwise3D)
+{
+#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
+    throw SkipTestException("Test is enabled starts from 2019R1");
+#endif
+    if (backend == DNN_BACKEND_INFERENCE_ENGINE && target != DNN_TARGET_CPU)
+        throw SkipTestException("Only CPU on DLIE backend is supported");
+    testONNXModels("eltwise3d");
+}
+
 TEST_P(Test_ONNX_layers, AveragePooling)
 {
     testONNXModels("average_pooling");