From 76e75aabbd9814fecf7dc91f9ee0c29e74676cd3 Mon Sep 17 00:00:00 2001 From: Georgy Krivoruchko Date: Tue, 23 Jan 2024 13:37:22 -0800 Subject: [PATCH] [ONNX] Frontend refactoring: operations (#22351) * Refactoring operations M-P * Fixed code style --- src/frontends/onnx/frontend/src/op/matmul.hpp | 11 ++-- src/frontends/onnx/frontend/src/op/max.hpp | 7 +-- .../onnx/frontend/src/op/max_pool.cpp | 4 +- .../onnx/frontend/src/op/max_pool.hpp | 9 ++- .../onnx/frontend/src/op/max_roi_pool.cpp | 20 +++---- .../onnx/frontend/src/op/max_roi_pool.hpp | 1 - src/frontends/onnx/frontend/src/op/mean.cpp | 12 ++-- src/frontends/onnx/frontend/src/op/mean.hpp | 1 - .../src/op/mean_variance_normalization.cpp | 19 +++---- .../src/op/mean_variance_normalization.hpp | 1 - src/frontends/onnx/frontend/src/op/min.hpp | 8 +-- src/frontends/onnx/frontend/src/op/mod.cpp | 17 +++--- src/frontends/onnx/frontend/src/op/mod.hpp | 1 - src/frontends/onnx/frontend/src/op/mul.hpp | 9 +-- src/frontends/onnx/frontend/src/op/neg.hpp | 1 - .../onnx/frontend/src/op/nms_rotated.hpp | 13 ++--- .../frontend/src/op/non_max_suppression.cpp | 39 +++++++------ .../frontend/src/op/non_max_suppression.hpp | 1 - .../onnx/frontend/src/op/non_zero.cpp | 6 +- .../onnx/frontend/src/op/non_zero.hpp | 5 +- src/frontends/onnx/frontend/src/op/not.hpp | 7 +-- src/frontends/onnx/frontend/src/op/onehot.cpp | 20 ++++--- src/frontends/onnx/frontend/src/op/onehot.hpp | 1 - src/frontends/onnx/frontend/src/op/or.hpp | 7 +-- .../detection_output.hpp | 2 - .../generate_proposals.hpp | 1 - .../src/op/org.openvinotoolkit/swish.hpp | 2 - src/frontends/onnx/frontend/src/op/pad.cpp | 55 +++++++++---------- src/frontends/onnx/frontend/src/op/pad.hpp | 1 - src/frontends/onnx/frontend/src/op/pow.cpp | 18 +++--- src/frontends/onnx/frontend/src/op/prelu.cpp | 6 +- src/frontends/onnx/frontend/src/op/prelu.hpp | 1 - 32 files changed, 135 insertions(+), 171 deletions(-) diff --git a/src/frontends/onnx/frontend/src/op/matmul.hpp b/src/frontends/onnx/frontend/src/op/matmul.hpp index d4930005bfc54c..96a9dad986ad7d 100644 --- a/src/frontends/onnx/frontend/src/op/matmul.hpp +++ b/src/frontends/onnx/frontend/src/op/matmul.hpp @@ -7,23 +7,20 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include - -#include "default_opset.hpp" -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" +#include "openvino/op/matmul.hpp" namespace ngraph { namespace onnx_import { namespace op { namespace detail { -inline OutputVector matmul(const Output& a, const Output& b) { - return {std::make_shared(a, b)}; +inline OutputVector matmul(const Output& a, const Output& b) { + return {std::make_shared(a, b)}; } } // namespace detail namespace set_1 { inline OutputVector matmul(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; + return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; } } // namespace set_1 } // namespace op diff --git a/src/frontends/onnx/frontend/src/op/max.hpp b/src/frontends/onnx/frontend/src/op/max.hpp index 6ae77fb49a15b4..87ae7f5f966c2d 100644 --- a/src/frontends/onnx/frontend/src/op/max.hpp +++ b/src/frontends/onnx/frontend/src/op/max.hpp @@ -7,9 +7,8 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "default_opset.hpp" -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" +#include "openvino/op/maximum.hpp" #include "utils/variadic.hpp" namespace ngraph { @@ -17,14 +16,14 @@ namespace onnx_import { namespace op { namespace set_1 { inline OutputVector max(const Node& node) { - return variadic::make_ng_variadic_op(node, ngraph::op::AutoBroadcastType::NONE); + return variadic::make_ng_variadic_op(node, ov::op::AutoBroadcastType::NONE); } } // namespace set_1 namespace set_8 { inline OutputVector max(const Node& node) { - return variadic::make_ng_variadic_op(node); + return variadic::make_ng_variadic_op(node); } } // namespace set_8 diff --git a/src/frontends/onnx/frontend/src/op/max_pool.cpp b/src/frontends/onnx/frontend/src/op/max_pool.cpp index f95435791f1b19..9bd24802fec4c3 100644 --- a/src/frontends/onnx/frontend/src/op/max_pool.cpp +++ b/src/frontends/onnx/frontend/src/op/max_pool.cpp @@ -4,12 +4,12 @@ #include "op/max_pool.hpp" -#include - #include "onnx_import/core/null_node.hpp" #include "openvino/util/log.hpp" #include "utils/pooling_factory.hpp" +using namespace ov::op; + OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { namespace onnx_import { diff --git a/src/frontends/onnx/frontend/src/op/max_pool.hpp b/src/frontends/onnx/frontend/src/op/max_pool.hpp index f9b266feb6b463..3de07fe00a18a1 100644 --- a/src/frontends/onnx/frontend/src/op/max_pool.hpp +++ b/src/frontends/onnx/frontend/src/op/max_pool.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph { @@ -15,11 +14,11 @@ namespace onnx_import { namespace op { namespace set_1 { /// -/// \brief Convert ONNX MaxPool operation to an nGraph node. +/// \brief Convert ONNX MaxPool operation to an OV node. /// /// \param node The ONNX node object representing this operation. /// -/// \return The vector containing Ngraph nodes producing output of ONNX MaxPool +/// \return The vector containing OV nodes producing output of ONNX MaxPool /// operation. /// OutputVector max_pool(const Node& node); @@ -28,11 +27,11 @@ OutputVector max_pool(const Node& node); namespace set_8 { /// -/// \brief Convert ONNX MaxPool operation to an nGraph node. +/// \brief Convert ONNX MaxPool operation to an OV node. /// /// \param node The ONNX node object representing this operation. /// -/// \return The vector containing Ngraph nodes producing output of ONNX MaxPool +/// \return The vector containing OV nodes producing output of ONNX MaxPool /// operation. /// OutputVector max_pool(const Node& node); diff --git a/src/frontends/onnx/frontend/src/op/max_roi_pool.cpp b/src/frontends/onnx/frontend/src/op/max_roi_pool.cpp index cc5b5092ff003d..86d1284d5f0db4 100644 --- a/src/frontends/onnx/frontend/src/op/max_roi_pool.cpp +++ b/src/frontends/onnx/frontend/src/op/max_roi_pool.cpp @@ -4,16 +4,12 @@ #include "op/max_roi_pool.hpp" -#include -#include -#include +#include "openvino/frontend/exception.hpp" +#include "openvino/op/roi_pooling.hpp" -#include "ngraph/check.hpp" -#include "ngraph/type/element_type.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "default_opset.hpp" +using namespace ov::op; +OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { namespace onnx_import { namespace op { @@ -23,14 +19,14 @@ OutputVector max_roi_pool(const Node& node) { const auto X = inputs.at(0); const auto rois = inputs.at(1); - OPENVINO_ASSERT(X.get_element_type() == element::f16 || X.get_element_type() == element::f32 || - X.get_element_type() == element::f64, - "MaxRoiPool operator only supports float16, float32 and float64 datatypes."); + FRONT_END_GENERAL_CHECK(X.get_element_type() == element::f16 || X.get_element_type() == element::f32 || + X.get_element_type() == element::f64, + "MaxRoiPool operator only supports float16, float32 and float64 datatypes."); const auto pooled_shape = node.get_attribute_value>("pooled_shape"); const auto spatial_scale = node.get_attribute_value("spatial_scale", 1.0); - return {std::make_shared(X, rois, Shape(pooled_shape), spatial_scale, "max")}; + return {std::make_shared(X, rois, Shape(pooled_shape), spatial_scale, "max")}; } } // namespace set_1 } // namespace op diff --git a/src/frontends/onnx/frontend/src/op/max_roi_pool.hpp b/src/frontends/onnx/frontend/src/op/max_roi_pool.hpp index 7152d9c9b10718..9badbc7788d81b 100644 --- a/src/frontends/onnx/frontend/src/op/max_roi_pool.hpp +++ b/src/frontends/onnx/frontend/src/op/max_roi_pool.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph { diff --git a/src/frontends/onnx/frontend/src/op/mean.cpp b/src/frontends/onnx/frontend/src/op/mean.cpp index 31d9e94ea7f3b3..95e57949d7ccb2 100644 --- a/src/frontends/onnx/frontend/src/op/mean.cpp +++ b/src/frontends/onnx/frontend/src/op/mean.cpp @@ -4,19 +4,23 @@ #include "op/mean.hpp" -#include "default_opset.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/divide.hpp" #include "utils/variadic.hpp" +using namespace ov::op; + OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { namespace onnx_import { namespace op { namespace set_1 { OutputVector mean(const Node& node) { - auto sum = variadic::make_ng_variadic_op(node).front(); - auto count = default_opset::Constant::create(sum.get_element_type(), Shape{}, {node.get_ng_inputs().size()}); + auto sum = variadic::make_ng_variadic_op(node).front(); + auto count = v0::Constant::create(sum.get_element_type(), Shape{}, {node.get_ng_inputs().size()}); - return {std::make_shared(sum, count)}; + return {std::make_shared(sum, count)}; } } // namespace set_1 diff --git a/src/frontends/onnx/frontend/src/op/mean.hpp b/src/frontends/onnx/frontend/src/op/mean.hpp index 178cf1e5b766d9..81930245600f0b 100644 --- a/src/frontends/onnx/frontend/src/op/mean.hpp +++ b/src/frontends/onnx/frontend/src/op/mean.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph { diff --git a/src/frontends/onnx/frontend/src/op/mean_variance_normalization.cpp b/src/frontends/onnx/frontend/src/op/mean_variance_normalization.cpp index 1c30edb27bac07..a8992a65d8d4a2 100644 --- a/src/frontends/onnx/frontend/src/op/mean_variance_normalization.cpp +++ b/src/frontends/onnx/frontend/src/op/mean_variance_normalization.cpp @@ -4,14 +4,11 @@ #include "op/mean_variance_normalization.hpp" -#include -#include - -#include "default_opset.hpp" -#include "ngraph/axis_set.hpp" -#include "ngraph/validation_util.hpp" +#include "openvino/core/validation_util.hpp" +#include "openvino/op/constant.hpp" #include "openvino/op/mvn.hpp" -#include "openvino/opsets/opset5.hpp" + +using namespace ov::op; OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { @@ -23,7 +20,7 @@ OutputVector mean_variance_normalization(const Node& node) { bool across_channels = node.get_attribute_value("across_channels", 0); bool normalize_variance = node.get_attribute_value("normalize_variance", 1); - return {std::make_shared(data, across_channels, normalize_variance)}; + return {std::make_shared(data, across_channels, normalize_variance)}; } } // namespace set_1 @@ -34,10 +31,10 @@ OutputVector mean_variance_normalization(const Node& node) { auto axes = node.get_attribute_value>("axes", {0, 2, 3}); OPENVINO_SUPPRESS_DEPRECATED_START const std::vector normalized_axes = - ngraph::normalize_axes(node.get_description(), axes, data.get_partial_shape().rank()); + ov::normalize_axes(node.get_description(), axes, data.get_partial_shape().rank()); OPENVINO_SUPPRESS_DEPRECATED_END - auto const_axes = default_opset::Constant::create(element::i64, Shape{normalized_axes.size()}, normalized_axes); - return {std::make_shared(data, const_axes, true, 1e-09f, ov::op::MVNEpsMode::OUTSIDE_SQRT)}; + auto const_axes = v0::Constant::create(element::i64, Shape{normalized_axes.size()}, normalized_axes); + return {std::make_shared(data, const_axes, true, 1e-09f, ov::op::MVNEpsMode::OUTSIDE_SQRT)}; } } // namespace set_9 diff --git a/src/frontends/onnx/frontend/src/op/mean_variance_normalization.hpp b/src/frontends/onnx/frontend/src/op/mean_variance_normalization.hpp index 736559b103c062..82879f97d884ee 100644 --- a/src/frontends/onnx/frontend/src/op/mean_variance_normalization.hpp +++ b/src/frontends/onnx/frontend/src/op/mean_variance_normalization.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph { diff --git a/src/frontends/onnx/frontend/src/op/min.hpp b/src/frontends/onnx/frontend/src/op/min.hpp index 6ffe0fa4612379..50848cab82c1ea 100644 --- a/src/frontends/onnx/frontend/src/op/min.hpp +++ b/src/frontends/onnx/frontend/src/op/min.hpp @@ -7,24 +7,22 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "default_opset.hpp" -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" -#include "utils/variadic.hpp" +#include "openvino/op/minimum.hpp" namespace ngraph { namespace onnx_import { namespace op { namespace set_1 { inline OutputVector min(const Node& node) { - return variadic::make_ng_variadic_op(node, ngraph::op::AutoBroadcastType::NONE); + return variadic::make_ng_variadic_op(node, ov::op::AutoBroadcastType::NONE); } } // namespace set_1 namespace set_8 { inline OutputVector min(const Node& node) { - return variadic::make_ng_variadic_op(node); + return variadic::make_ng_variadic_op(node); } } // namespace set_8 diff --git a/src/frontends/onnx/frontend/src/op/mod.cpp b/src/frontends/onnx/frontend/src/op/mod.cpp index 755bd28ff08547..2d167252ef54b3 100644 --- a/src/frontends/onnx/frontend/src/op/mod.cpp +++ b/src/frontends/onnx/frontend/src/op/mod.cpp @@ -4,13 +4,12 @@ #include "op/mod.hpp" -#include - -#include "default_opset.hpp" #include "exceptions.hpp" -#include "ngraph/op/util/attr_types.hpp" #include "openvino/frontend/exception.hpp" -#include "openvino/op/abs.hpp" +#include "openvino/op/floor_mod.hpp" +#include "openvino/op/mod.hpp" + +using namespace ov::op; OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { @@ -18,18 +17,18 @@ namespace onnx_import { namespace op { namespace set_1 { OutputVector mod(const Node& node) { - Output dividend{node.get_ng_inputs().at(0)}; - Output divisor{node.get_ng_inputs().at(1)}; + Output dividend{node.get_ng_inputs().at(0)}; + Output divisor{node.get_ng_inputs().at(1)}; std::int64_t fmod = node.get_attribute_value("fmod", 0); OutputVector output; if (fmod == 1) { - output = {std::make_shared(dividend, divisor)}; + output = {std::make_shared(dividend, divisor)}; } else if (fmod == 0) { FRONT_END_GENERAL_CHECK(dividend.get_element_type().is_integral() && divisor.get_element_type().is_integral(), "If the input type is floating point, then `fmod` attribute " "must be set to 1."); - output = {std::make_shared(dividend, divisor)}; + output = {std::make_shared(dividend, divisor)}; } else { OPENVINO_THROW("Unsupported value of 'fmod' attribute (should be: 0 or 1)"); } diff --git a/src/frontends/onnx/frontend/src/op/mod.hpp b/src/frontends/onnx/frontend/src/op/mod.hpp index 02856e909d1064..5806c954be806b 100644 --- a/src/frontends/onnx/frontend/src/op/mod.hpp +++ b/src/frontends/onnx/frontend/src/op/mod.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph { diff --git a/src/frontends/onnx/frontend/src/op/mul.hpp b/src/frontends/onnx/frontend/src/op/mul.hpp index 6ad8680e19eed8..204aa8e2123498 100644 --- a/src/frontends/onnx/frontend/src/op/mul.hpp +++ b/src/frontends/onnx/frontend/src/op/mul.hpp @@ -7,25 +7,22 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include - -#include "default_opset.hpp" -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" +#include "openvino/op/multiply.hpp" namespace ngraph { namespace onnx_import { namespace op { namespace set_1 { inline OutputVector mul(const Node& node) { - return common::handle_opset6_binary_op(node); + return common::handle_opset6_binary_op(node); } } // namespace set_1 namespace set_7 { inline OutputVector mul(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; + return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; } } // namespace set_7 diff --git a/src/frontends/onnx/frontend/src/op/neg.hpp b/src/frontends/onnx/frontend/src/op/neg.hpp index 0ae61f23e64a1d..135094435d91e6 100644 --- a/src/frontends/onnx/frontend/src/op/neg.hpp +++ b/src/frontends/onnx/frontend/src/op/neg.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" #include "openvino/op/negative.hpp" diff --git a/src/frontends/onnx/frontend/src/op/nms_rotated.hpp b/src/frontends/onnx/frontend/src/op/nms_rotated.hpp index b41d203474408c..160cbb30cf4386 100644 --- a/src/frontends/onnx/frontend/src/op/nms_rotated.hpp +++ b/src/frontends/onnx/frontend/src/op/nms_rotated.hpp @@ -9,10 +9,9 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "default_opset.hpp" #include "onnx_import/core/node.hpp" -#include "openvino/core/node_vector.hpp" -#include "openvino/opsets/opset13.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/nms_rotated.hpp" namespace ngraph { namespace onnx_import { @@ -22,11 +21,11 @@ inline OutputVector nms_rotated(const Node& node) { auto iou_threshold = node.get_attribute_value("iou_threshold"); auto score_threshold = node.get_attribute_value("score_threshold"); auto max_output_boxes_per_class = - default_opset::Constant::create(element::i64, Shape{1}, {std::numeric_limits::max()}); - auto iou_threshold_const = default_opset::Constant::create(element::f32, Shape{}, {iou_threshold}); - auto score_threshold_const = default_opset::Constant::create(element::f32, Shape{}, {score_threshold}); + ov::op::v0::Constant::create(element::i64, Shape{1}, {std::numeric_limits::max()}); + auto iou_threshold_const = ov::op::v0::Constant::create(element::f32, Shape{}, {iou_threshold}); + auto score_threshold_const = ov::op::v0::Constant::create(element::f32, Shape{}, {score_threshold}); - auto nms = std::make_shared(node.get_ng_inputs().at(0), + auto nms = std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1), max_output_boxes_per_class, iou_threshold_const, diff --git a/src/frontends/onnx/frontend/src/op/non_max_suppression.cpp b/src/frontends/onnx/frontend/src/op/non_max_suppression.cpp index cd6044489de204..ee18f5981f66ca 100644 --- a/src/frontends/onnx/frontend/src/op/non_max_suppression.cpp +++ b/src/frontends/onnx/frontend/src/op/non_max_suppression.cpp @@ -2,16 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "op/non_max_suppression.hpp" +#include "openvino/op/non_max_suppression.hpp" -#include - -#include "default_opset.hpp" #include "exceptions.hpp" -#include "ngraph/op/util/attr_types.hpp" #include "onnx_import/core/null_node.hpp" +#include "openvino/op/constant.hpp" #include "utils/reshape.hpp" +using namespace ov::op; + OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { namespace onnx_import { @@ -23,28 +22,28 @@ OutputVector non_max_suppression(const Node& node) { // a reference implementation is added const auto ng_inputs = node.get_ng_inputs(); - const Output boxes = ng_inputs.at(0); - const Output scores = ng_inputs.at(1); + const Output boxes = ng_inputs.at(0); + const Output scores = ng_inputs.at(1); - Output max_output_boxes_per_class; + Output max_output_boxes_per_class; if (ng_inputs.size() > 2 && !is_null(ng_inputs.at(2))) { max_output_boxes_per_class = ngraph::onnx_import::reshape::interpret_as_scalar(ng_inputs.at(2)); } else { - max_output_boxes_per_class = default_opset::Constant::create(element::i64, Shape{}, {0}); + max_output_boxes_per_class = v0::Constant::create(element::i64, Shape{}, {0}); } - Output iou_threshold; + Output iou_threshold; if (ng_inputs.size() > 3 && !is_null(ng_inputs.at(3))) { iou_threshold = ngraph::onnx_import::reshape::interpret_as_scalar(ng_inputs.at(3)); } else { - iou_threshold = default_opset::Constant::create(element::f32, Shape{}, {.0f}); + iou_threshold = v0::Constant::create(element::f32, Shape{}, {.0f}); } - Output score_threshold; + Output score_threshold; if (ng_inputs.size() > 4 && !is_null(ng_inputs.at(4))) { score_threshold = ngraph::onnx_import::reshape::interpret_as_scalar(ng_inputs.at(4)); } else { - score_threshold = default_opset::Constant::create(element::f32, Shape{}, {-std::numeric_limits::max()}); + score_threshold = v0::Constant::create(element::f32, Shape{}, {-std::numeric_limits::max()}); } const auto center_point_box = node.get_attribute_value("center_point_box", 0); @@ -56,13 +55,13 @@ OutputVector non_max_suppression(const Node& node) { const auto box_encoding = center_point_box == 0 ? ov::op::v9::NonMaxSuppression::BoxEncodingType::CORNER : ov::op::v9::NonMaxSuppression::BoxEncodingType::CENTER; - return {std::make_shared(boxes, - scores, - max_output_boxes_per_class, - iou_threshold, - score_threshold, - box_encoding, - false)}; + return {std::make_shared(boxes, + scores, + max_output_boxes_per_class, + iou_threshold, + score_threshold, + box_encoding, + false)}; } } // namespace set_1 diff --git a/src/frontends/onnx/frontend/src/op/non_max_suppression.hpp b/src/frontends/onnx/frontend/src/op/non_max_suppression.hpp index 371654842ca86a..667faf79f83d9f 100644 --- a/src/frontends/onnx/frontend/src/op/non_max_suppression.hpp +++ b/src/frontends/onnx/frontend/src/op/non_max_suppression.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph { diff --git a/src/frontends/onnx/frontend/src/op/non_zero.cpp b/src/frontends/onnx/frontend/src/op/non_zero.cpp index 84bb07122aab30..2c00062c443f4e 100644 --- a/src/frontends/onnx/frontend/src/op/non_zero.cpp +++ b/src/frontends/onnx/frontend/src/op/non_zero.cpp @@ -4,9 +4,9 @@ #include "op/non_zero.hpp" -#include +#include "openvino/op/non_zero.hpp" -#include "default_opset.hpp" +using namespace ov::op; OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { @@ -15,7 +15,7 @@ namespace op { namespace set_1 { OutputVector non_zero(const Node& node) { auto data = node.get_ng_inputs().at(0); - return {std::make_shared(data, element::i64)}; + return {std::make_shared(data, element::i64)}; } } // namespace set_1 diff --git a/src/frontends/onnx/frontend/src/op/non_zero.hpp b/src/frontends/onnx/frontend/src/op/non_zero.hpp index d5758e6507840c..461f292ebcd960 100644 --- a/src/frontends/onnx/frontend/src/op/non_zero.hpp +++ b/src/frontends/onnx/frontend/src/op/non_zero.hpp @@ -7,18 +7,17 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph { namespace onnx_import { namespace op { namespace set_1 { -/// \brief Convert ONNX NonZero operation to an nGraph node. +/// \brief Convert ONNX NonZero operation to an OV node. /// /// \param node The ONNX node object representing this operation. /// -/// \return The vector containing nGraph nodes producing output of ONNX NonZero +/// \return The vector containing OV nodes producing output of ONNX NonZero /// operation. OutputVector non_zero(const Node& node); diff --git a/src/frontends/onnx/frontend/src/op/not.hpp b/src/frontends/onnx/frontend/src/op/not.hpp index b498cee9ae3ec3..ac2dbd6cc58f19 100644 --- a/src/frontends/onnx/frontend/src/op/not.hpp +++ b/src/frontends/onnx/frontend/src/op/not.hpp @@ -7,18 +7,15 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include - -#include "default_opset.hpp" -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" +#include "openvino/op/logical_not.hpp" namespace ngraph { namespace onnx_import { namespace op { namespace set_1 { inline OutputVector logical_not(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; + return {std::make_shared(node.get_ng_inputs().at(0))}; } } // namespace set_1 diff --git a/src/frontends/onnx/frontend/src/op/onehot.cpp b/src/frontends/onnx/frontend/src/op/onehot.cpp index 42d40f1ebbd97a..748ab4498bc4e8 100644 --- a/src/frontends/onnx/frontend/src/op/onehot.cpp +++ b/src/frontends/onnx/frontend/src/op/onehot.cpp @@ -4,12 +4,14 @@ #include "op/onehot.hpp" -#include -#include - -#include "default_opset.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/one_hot.hpp" +#include "openvino/op/split.hpp" #include "utils/reshape.hpp" +using namespace ov::op; + OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { namespace onnx_import { @@ -17,18 +19,18 @@ namespace op { namespace set_1 { OutputVector onehot(const Node& node) { OutputVector inputs{node.get_ng_inputs()}; - auto indices = std::make_shared(inputs.at(0), element::i64); - auto depth = std::make_shared(reshape::interpret_as_scalar(inputs.at(1)), element::i64); + auto indices = std::make_shared(inputs.at(0), element::i64); + auto depth = std::make_shared(reshape::interpret_as_scalar(inputs.at(1)), element::i64); // Rank 1 tensor containing exactly two elements: [off_value, on_value] auto values = inputs.at(2); - auto split_axis = default_opset::Constant::create(element::i64, {}, {0}); - auto off_on_values = std::make_shared(values, split_axis, 2); + auto split_axis = v0::Constant::create(element::i64, {}, {0}); + auto off_on_values = std::make_shared(values, split_axis, 2); auto off_value = reshape::interpret_as_scalar(off_on_values->output(0)); auto on_value = reshape::interpret_as_scalar(off_on_values->output(1)); auto axis = node.get_attribute_value("axis", -1); - return {std::make_shared(indices, depth, on_value, off_value, axis)}; + return {std::make_shared(indices, depth, on_value, off_value, axis)}; } } // namespace set_1 diff --git a/src/frontends/onnx/frontend/src/op/onehot.hpp b/src/frontends/onnx/frontend/src/op/onehot.hpp index ab95ea7eeadb25..311b5fd1eb94a9 100644 --- a/src/frontends/onnx/frontend/src/op/onehot.hpp +++ b/src/frontends/onnx/frontend/src/op/onehot.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph { diff --git a/src/frontends/onnx/frontend/src/op/or.hpp b/src/frontends/onnx/frontend/src/op/or.hpp index ccf46f8c2f3c4b..50e3c1cf739687 100644 --- a/src/frontends/onnx/frontend/src/op/or.hpp +++ b/src/frontends/onnx/frontend/src/op/or.hpp @@ -7,18 +7,15 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include - -#include "default_opset.hpp" -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" +#include "openvino/op/logical_or.hpp" namespace ngraph { namespace onnx_import { namespace op { namespace set_1 { inline OutputVector logical_or(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; + return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; } } // namespace set_1 diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.hpp index 677e3208152710..609527a942c26a 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.hpp @@ -7,8 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include - #include "onnx_import/core/node.hpp" namespace ngraph { diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.hpp index eb9dc4e3e16a70..39152d88248720 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph { diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.hpp index 4288e8162032dc..c8f00efc587c49 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.hpp @@ -7,8 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include - #include "onnx_import/core/node.hpp" namespace ngraph { diff --git a/src/frontends/onnx/frontend/src/op/pad.cpp b/src/frontends/onnx/frontend/src/op/pad.cpp index e02b526a1c702e..476fc9b1642245 100644 --- a/src/frontends/onnx/frontend/src/op/pad.cpp +++ b/src/frontends/onnx/frontend/src/op/pad.cpp @@ -4,28 +4,25 @@ #include "op/pad.hpp" -#include - -#include "default_opset.hpp" #include "exceptions.hpp" -#include "ngraph/coordinate_diff.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "ngraph/shape.hpp" #include "onnx_import/core/null_node.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/pad.hpp" +#include "openvino/op/util/op_types.hpp" #include "ov_models/ov_builders/split.hpp" #include "utils/convpool.hpp" #include "utils/reshape.hpp" namespace { -ngraph::op::PadMode get_pad_mode(std::string mode) { - ngraph::op::PadMode pad_mode; +ov::op::PadMode get_pad_mode(std::string mode) { + ov::op::PadMode pad_mode; if (mode == "constant") { - pad_mode = ngraph::op::PadMode::CONSTANT; + pad_mode = ov::op::PadMode::CONSTANT; } else if (mode == "reflect") { - pad_mode = ngraph::op::PadMode::REFLECT; + pad_mode = ov::op::PadMode::REFLECT; } else if (mode == "edge") { - pad_mode = ngraph::op::PadMode::EDGE; + pad_mode = ov::op::PadMode::EDGE; } else { OPENVINO_THROW("Unsupported padding mode: [" + mode + "]"); } @@ -33,6 +30,8 @@ ngraph::op::PadMode get_pad_mode(std::string mode) { return pad_mode; } } // namespace +using namespace ov::op; + OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { namespace onnx_import { @@ -47,17 +46,17 @@ OutputVector pad(const Node& node) { double value = node.get_attribute_value("value", 0); const std::string mode = node.get_attribute_value("mode", "constant"); - ngraph::op::PadMode pad_mode = get_pad_mode(mode); + ov::op::PadMode pad_mode = get_pad_mode(mode); const auto paddings = convpool::get_pads(node, data_rank_value); - ngraph::CoordinateDiff padding_below = paddings.first; - ngraph::CoordinateDiff padding_above = paddings.second; + ov::CoordinateDiff padding_below = paddings.first; + ov::CoordinateDiff padding_above = paddings.second; - return {std::make_shared( + return {std::make_shared( data, - std::make_shared(element::i64, ngraph::Shape{padding_below.size()}, padding_below), - std::make_shared(element::i64, ngraph::Shape{padding_above.size()}, padding_above), - std::make_shared(data.get_element_type(), ngraph::Shape{}, std::vector{value}), + std::make_shared(element::i64, ov::Shape{padding_below.size()}, padding_below), + std::make_shared(element::i64, ov::Shape{padding_above.size()}, padding_above), + std::make_shared(data.get_element_type(), ov::Shape{}, std::vector{value}), pad_mode)}; } @@ -67,26 +66,26 @@ OutputVector pad(const Node& node) { const auto inputs = node.get_ng_inputs(); const auto& data = inputs[0]; const auto& pads = inputs[1]; - Output values; - Output padding_begin; - Output padding_end; + Output values; + Output padding_begin; + Output padding_end; if (inputs.size() == 3 && !ov::op::util::is_null(inputs[2])) { values = reshape::interpret_as_scalar(inputs[2]); } else { - values = default_opset::Constant::create(data.get_element_type(), ngraph::Shape{}, {0}); + values = v0::Constant::create(data.get_element_type(), ov::Shape{}, {0}); } - if (ngraph::op::is_constant(pads.get_node())) { + if (ov::op::util::is_constant(pads.get_node())) { std::vector pads_vector = - ov::as_type_ptr(pads.get_node_shared_ptr())->get_vector(); + ov::as_type_ptr(pads.get_node_shared_ptr())->get_vector(); std::size_t const half_size = pads_vector.size() / 2; std::vector padding_begin_values(pads_vector.begin(), pads_vector.begin() + half_size); std::vector padding_end_values(pads_vector.begin() + half_size, pads_vector.end()); - padding_begin = default_opset::Constant::create(element::i64, ngraph::Shape{half_size}, padding_begin_values); - padding_end = default_opset::Constant::create(element::i64, ngraph::Shape{half_size}, padding_end_values); + padding_begin = v0::Constant::create(element::i64, ov::Shape{half_size}, padding_begin_values); + padding_end = v0::Constant::create(element::i64, ov::Shape{half_size}, padding_end_values); } else { OutputVector padding = ov::op::util::split(pads, 2, 0); @@ -95,9 +94,9 @@ OutputVector pad(const Node& node) { } const std::string mode = node.get_attribute_value("mode", "constant"); - ngraph::op::PadMode pad_mode = get_pad_mode(mode); + ov::op::PadMode pad_mode = get_pad_mode(mode); - return {std::make_shared(data, padding_begin, padding_end, values, pad_mode)}; + return {std::make_shared(data, padding_begin, padding_end, values, pad_mode)}; } } // namespace set_11 diff --git a/src/frontends/onnx/frontend/src/op/pad.hpp b/src/frontends/onnx/frontend/src/op/pad.hpp index aa3539f47aadba..8ee5c929d64ade 100644 --- a/src/frontends/onnx/frontend/src/op/pad.hpp +++ b/src/frontends/onnx/frontend/src/op/pad.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph { diff --git a/src/frontends/onnx/frontend/src/op/pow.cpp b/src/frontends/onnx/frontend/src/op/pow.cpp index 66bbb084e89ee8..18d7e419eb25d7 100644 --- a/src/frontends/onnx/frontend/src/op/pow.cpp +++ b/src/frontends/onnx/frontend/src/op/pow.cpp @@ -4,11 +4,11 @@ #include "op/pow.hpp" -#include - -#include "default_opset.hpp" -#include "ngraph/node.hpp" #include "openvino/frontend/exception.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/power.hpp" + +using namespace ov::op; OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { @@ -25,14 +25,14 @@ OutputVector pow(const Node& node) { auto exponent_type = inputs[1].get_element_type(); if (exponent_type != base_type) { if (exponent_type.is_integral() || (base_type.is_real() && base_type.bitwidth() >= exponent_type.bitwidth())) { - exponent = std::make_shared(exponent, base_type); + exponent = std::make_shared(exponent, base_type); } else { - base = std::make_shared(base, exponent_type); - auto power = std::make_shared(base, exponent); - return {std::make_shared(power, base_type)}; + base = std::make_shared(base, exponent_type); + auto power = std::make_shared(base, exponent); + return {std::make_shared(power, base_type)}; } } - return {std::make_shared(base, exponent)}; + return {std::make_shared(base, exponent)}; } } // namespace set_1 diff --git a/src/frontends/onnx/frontend/src/op/prelu.cpp b/src/frontends/onnx/frontend/src/op/prelu.cpp index fa336eaa2b8c24..80dc1023f1ce68 100644 --- a/src/frontends/onnx/frontend/src/op/prelu.cpp +++ b/src/frontends/onnx/frontend/src/op/prelu.cpp @@ -4,9 +4,9 @@ #include "op/prelu.hpp" -#include +#include "openvino/op/prelu.hpp" -#include "default_opset.hpp" +using namespace ov::op; OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { @@ -17,7 +17,7 @@ OutputVector prelu(const Node& node) { OutputVector ng_inputs{node.get_ng_inputs()}; const auto& data = ng_inputs.at(0); const auto& slope = ng_inputs.at(1); - return {std::make_shared(data, slope)}; + return {std::make_shared(data, slope)}; } } // namespace set_1 diff --git a/src/frontends/onnx/frontend/src/op/prelu.hpp b/src/frontends/onnx/frontend/src/op/prelu.hpp index 3ceb9845c22877..cd2b7d1a0db8ba 100644 --- a/src/frontends/onnx/frontend/src/op/prelu.hpp +++ b/src/frontends/onnx/frontend/src/op/prelu.hpp @@ -7,7 +7,6 @@ #include "openvino/core/deprecated.hpp" OPENVINO_SUPPRESS_DEPRECATED_START -#include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" namespace ngraph {