Added ngraph::op::v6::MVN
authorLiubov Batanina <piccione-mail@yandex.ru>
Fri, 12 Mar 2021 13:33:16 +0000 (16:33 +0300)
committerLiubov Batanina <piccione-mail@yandex.ru>
Fri, 12 Mar 2021 18:02:03 +0000 (21:02 +0300)
modules/dnn/src/layers/mvn_layer.cpp
modules/dnn/src/layers/resize_layer.cpp

index 386446e18f8f60adcc4ab4aafd7dc7706bf31719..8f06216df1e44d487fa42fba5f0ebce55ac5bdbf 100644 (file)
@@ -394,7 +394,15 @@ public:
                                         const std::vector<Ptr<BackendNode> >& nodes) CV_OVERRIDE
     {
         auto& ieInpNode = nodes[0].dynamicCast<InfEngineNgraphNode>()->node;
+#if INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2021_2)
         auto mvn = std::make_shared<ngraph::op::MVN>(ieInpNode, acrossChannels, normVariance, eps);
+#else
+        int64_t start_axis = acrossChannels ? 1 : 2;
+        std::vector<int64_t> axes_v(ieInpNode->get_shape().size() - start_axis);
+        std::iota(axes_v.begin(), axes_v.end(), start_axis);
+        auto axes = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{axes_v.size()}, axes_v.data());
+        auto mvn = std::make_shared<ngraph::op::v6::MVN>(ieInpNode, axes, normVariance, eps, ngraph::op::MVNEpsMode::INSIDE_SQRT);
+#endif
         return Ptr<BackendNode>(new InfEngineNgraphNode(mvn));
     }
 #endif  // HAVE_DNN_NGRAPH
index 2527ad1190798821945ec1090f65e1c50f021bde..40c7351984e015d6b07b2d02ca6db89b2ba06240 100644 (file)
@@ -286,7 +286,7 @@ public:
             attrs.mode = ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx;
             attrs.coordinate_transformation_mode = ngraph::op::v4::Interpolate::CoordinateTransformMode::asymmetric;
         } else {
-            CV_Error(Error::StsNotImplemented, "Unsupported interpolation: " + interpolation);
+            CV_Error(Error::StsNotImplemented, format("Unsupported interpolation: %s", interpolation.c_str()));
         }
         attrs.shape_calculation_mode = ngraph::op::v4::Interpolate::ShapeCalcMode::sizes;
 
@@ -300,7 +300,8 @@ public:
         auto out_shape = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, shape.data());
 
         auto& input_shape = ieInpNode->get_shape();
-        std::vector<float> scales = {static_cast<float>(outHeight) / input_shape[2], static_cast<float>(outHeight) / input_shape[2]};
+        CV_Assert_N(input_shape[2] != 0, input_shape[3] != 0);
+        std::vector<float> scales = {static_cast<float>(outHeight) / input_shape[2], static_cast<float>(outWidth) / input_shape[3]};
         auto scales_shape = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, ngraph::Shape{2}, scales.data());
 
         auto axes = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{2, 3});