diff --git a/.github/workflows/linux_arm64.yml b/.github/workflows/linux_arm64.yml index ad9a35170067ba..827e7882b4979f 100644 --- a/.github/workflows/linux_arm64.yml +++ b/.github/workflows/linux_arm64.yml @@ -277,7 +277,8 @@ jobs: ONNX_Runtime: name: ONNX Runtime Integration - if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_RT + if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_RT || + fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE needs: [ Build, Smart_CI ] uses: ./.github/workflows/job_onnx_runtime.yml with: diff --git a/src/frontends/onnx/frontend/include/onnx_import/core/node.hpp b/src/frontends/onnx/frontend/include/onnx_import/core/node.hpp index c51af034addf64..e46c37321820af 100644 --- a/src/frontends/onnx/frontend/include/onnx_import/core/node.hpp +++ b/src/frontends/onnx/frontend/include/onnx_import/core/node.hpp @@ -32,10 +32,10 @@ namespace ngraph { namespace onnx_import { namespace error { namespace node { -struct UnknownAttribute : ngraph_error { +struct UnknownAttribute : ov::Exception { OPENVINO_SUPPRESS_DEPRECATED_START explicit UnknownAttribute(const std::string& node, const std::string& name) - : ngraph_error{"Node (" + node + "): unknown attribute \'" + name + "\'"} {} + : ov::Exception{"Node (" + node + "): unknown attribute \'" + name + "\'"} {} OPENVINO_SUPPRESS_DEPRECATED_END }; diff --git a/src/frontends/onnx/frontend/include/onnx_import/core/null_node.hpp b/src/frontends/onnx/frontend/include/onnx_import/core/null_node.hpp index bab347933c4cf1..903dcc271b8bfe 100644 --- a/src/frontends/onnx/frontend/include/onnx_import/core/null_node.hpp +++ b/src/frontends/onnx/frontend/include/onnx_import/core/null_node.hpp @@ -16,16 +16,24 @@ #include -#include "ngraph/deprecated.hpp" #include "onnx_import/onnx_importer_visibility.hpp" +#include "openvino/core/deprecated.hpp" #include "openvino/op/op.hpp" -namespace ngraph { +namespace ov { namespace op { -NGRAPH_API_DEPRECATED ONNX_IMPORTER_API bool is_null(const ngraph::Node* node); -NGRAPH_API_DEPRECATED ONNX_IMPORTER_API bool is_null(const std::shared_ptr& node); -NGRAPH_API_DEPRECATED ONNX_IMPORTER_API bool is_null(const Output& output); +namespace util { +NGRAPH_API_DEPRECATED ONNX_IMPORTER_API bool is_null(const ov::Node* node); +NGRAPH_API_DEPRECATED ONNX_IMPORTER_API bool is_null(const std::shared_ptr& node); +NGRAPH_API_DEPRECATED ONNX_IMPORTER_API bool is_null(const Output& output); +} // namespace util } // namespace op +} // namespace ov +namespace ngraph { +namespace op { +using namespace ov::op::util; +} + namespace onnx_import { /// \brief Represents a missing optional input or output of an ONNX node /// diff --git a/src/frontends/onnx/frontend/src/core/attribute.cpp b/src/frontends/onnx/frontend/src/core/attribute.cpp index 932d1d1f8c7d92..0f3ff1736e9a0e 100644 --- a/src/frontends/onnx/frontend/src/core/attribute.cpp +++ b/src/frontends/onnx/frontend/src/core/attribute.cpp @@ -11,7 +11,7 @@ namespace ngraph { namespace onnx_import { Subgraph Attribute::get_subgraph(Graph* parent_graph) const { if (m_attribute_proto->type() != ONNX_NAMESPACE::AttributeProto_AttributeType_GRAPH) { - throw error::attribute::InvalidData{m_attribute_proto->type()}; + ONNX_INVALID_ATTR(m_attribute_proto->type(), "GRAPH"); } auto model_proto = std::make_shared(); diff --git a/src/frontends/onnx/frontend/src/core/attribute.hpp b/src/frontends/onnx/frontend/src/core/attribute.hpp index ac96d0d31e6f7b..4bd9756bccbbda 100644 --- a/src/frontends/onnx/frontend/src/core/attribute.hpp +++ b/src/frontends/onnx/frontend/src/core/attribute.hpp @@ -24,36 +24,19 @@ class Model; // of ONNX generated wrappers. using AttributeProto_AttributeType = decltype(ONNX_NAMESPACE::AttributeProto{}.type()); -namespace error { -namespace attribute { -namespace detail { -OPENVINO_SUPPRESS_DEPRECATED_START -struct Attribute : ngraph_error { - Attribute(const std::string& msg, AttributeProto_AttributeType type) : ngraph_error{msg} {} -}; -OPENVINO_SUPPRESS_DEPRECATED_END - -} // namespace detail - -struct InvalidData : detail::Attribute { - explicit InvalidData(AttributeProto_AttributeType type) : Attribute{"invalid attribute type", type} {} -}; - -struct UnsupportedType : detail::Attribute { - explicit UnsupportedType(AttributeProto_AttributeType type) : Attribute{"unsupported attribute type", type} {} -}; - -} // namespace attribute - -} // namespace error - namespace detail { namespace attribute { template inline T get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { - throw ngraph::onnx_import::error::attribute::UnsupportedType{attribute.type()}; + OPENVINO_THROW("Unsupported attribute type"); } +#define ONNX_INVALID_ATTR(attr, expected) \ + OPENVINO_THROW("Invalid attribute type ", \ + ONNX_NAMESPACE::AttributeProto_AttributeType_Name(attr), \ + " expected: ", \ + expected) + template <> inline float get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { switch (attribute.type()) { @@ -62,7 +45,7 @@ inline float get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { case ONNX_NAMESPACE::AttributeProto_AttributeType_FLOAT: return attribute.f(); default: - throw error::attribute::InvalidData{attribute.type()}; + ONNX_INVALID_ATTR(attribute.type(), "INT, FLOAT"); } } @@ -78,7 +61,7 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attrib case ONNX_NAMESPACE::AttributeProto_AttributeType_FLOATS: return {std::begin(attribute.floats()), std::end(attribute.floats())}; default: - throw error::attribute::InvalidData{attribute.type()}; + ONNX_INVALID_ATTR(attribute.type(), "INT, INTS, FLOAT, FLOATS"); } } @@ -90,7 +73,7 @@ inline double get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { case ONNX_NAMESPACE::AttributeProto_AttributeType_INT: return static_cast(attribute.i()); default: - throw error::attribute::InvalidData{attribute.type()}; + ONNX_INVALID_ATTR(attribute.type(), "INT, FLOAT"); } } @@ -110,7 +93,7 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attri case ONNX_NAMESPACE::AttributeProto_AttributeType_FLOATS: return {std::begin(attribute.floats()), std::end(attribute.floats())}; default: - throw error::attribute::InvalidData{attribute.type()}; + ONNX_INVALID_ATTR(attribute.type(), "INT, INTS, FLOAT, FLOATS"); } #if defined(_MSC_VER) # pragma warning(pop) @@ -120,7 +103,7 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attri template <> inline std::size_t get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { if (attribute.type() != ONNX_NAMESPACE::AttributeProto_AttributeType_INT) { - throw error::attribute::InvalidData{attribute.type()}; + ONNX_INVALID_ATTR(attribute.type(), "INT"); } return static_cast(attribute.i()); } @@ -133,14 +116,14 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& case ONNX_NAMESPACE::AttributeProto_AttributeType_INTS: return {std::begin(attribute.ints()), std::end(attribute.ints())}; default: - throw error::attribute::InvalidData{attribute.type()}; + ONNX_INVALID_ATTR(attribute.type(), "INT, INTS"); } } template <> inline int64_t get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { if (attribute.type() != ONNX_NAMESPACE::AttributeProto_AttributeType_INT) { - throw error::attribute::InvalidData{attribute.type()}; + ONNX_INVALID_ATTR(attribute.type(), "INT"); } return attribute.i(); } @@ -153,14 +136,14 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attr case ONNX_NAMESPACE::AttributeProto_AttributeType_INTS: return {std::begin(attribute.ints()), std::end(attribute.ints())}; default: - throw error::attribute::InvalidData{attribute.type()}; + ONNX_INVALID_ATTR(attribute.type(), "INT, INTS"); } } template <> inline std::string get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { if (attribute.type() != ONNX_NAMESPACE::AttributeProto_AttributeType_STRING) { - throw error::attribute::InvalidData{attribute.type()}; + ONNX_INVALID_ATTR(attribute.type(), "STRING"); } return attribute.s(); } @@ -173,7 +156,7 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& case ONNX_NAMESPACE::AttributeProto_AttributeType_STRINGS: return {std::begin(attribute.strings()), std::end(attribute.strings())}; default: - throw error::attribute::InvalidData{attribute.type()}; + ONNX_INVALID_ATTR(attribute.type(), "STRING, STRINGS"); } } @@ -320,7 +303,7 @@ class Attribute { if (is_tensor()) { return Tensor{m_attribute_proto->t(), m_model_dir, m_mmap_cache}; } - throw error::attribute::InvalidData{m_attribute_proto->type()}; + ONNX_INVALID_ATTR(m_attribute_proto->type(), "TENSOR"); } template >::value, bool>::type = true> @@ -330,7 +313,7 @@ class Attribute { } else if (is_tensor_array()) { return get_tensor_array(); } - throw error::attribute::InvalidData{m_attribute_proto->type()}; + ONNX_INVALID_ATTR(m_attribute_proto->type(), "TENSOR, TENSORS"); } template ::value, bool>::type = true> @@ -338,7 +321,7 @@ class Attribute { if (is_sparse_tensor()) { return SparseTensor{m_attribute_proto->sparse_tensor(), m_model_dir, m_mmap_cache}; } - throw error::attribute::InvalidData{m_attribute_proto->type()}; + ONNX_INVALID_ATTR(m_attribute_proto->type(), "SPARSE_TENSOR"); } template >::value, bool>::type = true> @@ -348,7 +331,7 @@ class Attribute { } else if (is_sparse_tensor_array()) { return get_sparse_tensor_array(); } - throw error::attribute::InvalidData{m_attribute_proto->type()}; + ONNX_INVALID_ATTR(m_attribute_proto->type(), "SPARSE_TENSOR, SPARSE_TENSORS"); } ov::Any get_any() const; diff --git a/src/frontends/onnx/frontend/src/core/graph.cpp b/src/frontends/onnx/frontend/src/core/graph.cpp index a30d9a95a2471f..5e2689f2eeed86 100644 --- a/src/frontends/onnx/frontend/src/core/graph.cpp +++ b/src/frontends/onnx/frontend/src/core/graph.cpp @@ -13,16 +13,18 @@ #include "core/value_info.hpp" #include "default_opset.hpp" #include "exceptions.hpp" -#include "ngraph/node.hpp" #include "onnx_framework_node.hpp" #include "onnx_import/core/node.hpp" #include "onnx_import/core/null_node.hpp" +#include "openvino/core/node.hpp" #include "openvino/frontend/onnx/extension/conversion.hpp" #include "openvino/frontend/onnx/node_context.hpp" #include "openvino/op/util/op_types.hpp" #include "utils/common.hpp" #include "utils/legacy_conversion_extension.hpp" +using namespace ov; + namespace ngraph { namespace onnx_import { namespace detail { @@ -145,20 +147,20 @@ Graph::Graph(const std::string& model_dir, for (const auto& initializer_tensor : m_model->get_graph().initializer()) { if (initializer_tensor.has_name()) { Tensor tensor = Tensor{initializer_tensor, m_model_dir, m_mmap_cache}; - std::shared_ptr ng_constant; + std::shared_ptr ov_constant; // For each initializer create a Constant node and store it in cache try { - ng_constant = tensor.get_ng_constant(); + ov_constant = tensor.get_ng_constant(); } catch (const error::invalid_external_data&) { // invalid external data makes initializers creation impossible throw; - } catch (const ngraph::ngraph_error&) { - ng_constant = ngraph::onnx_import::common::make_failsafe_constant(tensor.get_ng_type()); + } catch (const ov::Exception&) { + ov_constant = ngraph::onnx_import::common::make_failsafe_constant(tensor.get_ng_type()); } initializers.emplace(initializer_tensor.name(), tensor); - ng_constant->get_output_tensor(0).set_names({initializer_tensor.name()}); - m_cache->emplace_node(initializer_tensor.name(), std::move(ng_constant)); + ov_constant->get_output_tensor(0).set_names({initializer_tensor.name()}); + m_cache->emplace_node(initializer_tensor.name(), std::move(ov_constant)); } } @@ -170,13 +172,13 @@ Graph::Graph(const std::string& model_dir, } ValueInfo value_info{input}; - auto ng_node = value_info.get_ng_node(m_parameters, initializers); - m_cache->emplace_node(input.name(), std::move(ng_node)); + auto ov_node = value_info.get_ng_node(m_parameters, initializers); + m_cache->emplace_node(input.name(), std::move(ov_node)); } } OPENVINO_SUPPRESS_DEPRECATED_START -void Graph::convert_to_ngraph_nodes() { +void Graph::convert_to_ov_nodes() { const float total = static_cast(m_model->get_graph().node().size()); unsigned int completed = 0u; std::map op_statistics; @@ -197,7 +199,7 @@ void Graph::convert_to_ngraph_nodes() { subgraph->convert(); } } - OutputVector ng_nodes{make_ng_nodes(node)}; + OutputVector ov_nodes{make_ov_nodes(node)}; ++completed; m_extensions.progress_reporter->report_progress(completed / total, static_cast(total), completed); } @@ -247,7 +249,7 @@ void Graph::set_metadata(std::shared_ptr& model) const { } std::shared_ptr Graph::convert() { - convert_to_ngraph_nodes(); + convert_to_ov_nodes(); remove_dangling_parameters(); auto function = create_function(); set_metadata(function); @@ -266,7 +268,7 @@ OutputVector Graph::make_framework_nodes(const Node& onnx_node) { functions.push_back(subgraph->decode()); for (const auto& input : subgraph->get_inputs_from_parent()) { const auto& name = input.get_node()->get_friendly_name(); - if (std::find_if(inputs.begin(), inputs.end(), [&name](const Output& n) -> bool { + if (std::find_if(inputs.begin(), inputs.end(), [&name](const Output& n) -> bool { return name == n.get_node()->get_friendly_name(); }) == inputs.end()) { inputs.push_back(input); @@ -290,13 +292,13 @@ void Graph::decode_to_framework_nodes() { op_statistics[node_proto.op_type()]++; } const Node node{node_proto, this}; - OutputVector ng_nodes{make_framework_nodes(node)}; - set_friendly_names(node, ng_nodes); + OutputVector ov_nodes{make_framework_nodes(node)}; + set_friendly_names(node, ov_nodes); // Iterate over the number of outputs for given node in graph. // Some of them may be optional and trimmed. See: // https://github.com/onnx/onnx/blob/master/docs/IR.md#optional-inputs-and-outputs for (std::size_t i{0}; i < node.get_outputs_size(); ++i) { - m_cache->emplace_node(node.output(static_cast(i)), std::move(ng_nodes.at(i))); + m_cache->emplace_node(node.output(static_cast(i)), std::move(ov_nodes.at(i))); } ++completed; m_extensions.progress_reporter->report_progress(completed / total, static_cast(total), completed); @@ -310,7 +312,7 @@ void Graph::decode_to_framework_nodes() { OPENVINO_SUPPRESS_DEPRECATED_END std::shared_ptr Graph::create_function() { - auto function = std::make_shared(get_ng_outputs(), m_parameters, get_name()); + auto function = std::make_shared(get_ov_outputs(), m_parameters, get_name()); const auto& onnx_outputs = m_model->get_graph().output(); for (std::size_t i{0}; i < function->get_output_size(); ++i) { const auto& result_node = function->get_output_op(i); @@ -330,34 +332,34 @@ std::shared_ptr Graph::decode() { return function; } -bool Graph::is_ng_node_in_cache(const std::string& name) const { +bool Graph::is_ov_node_in_cache(const std::string& name) const { return m_cache->contains(name); } -Output Graph::get_ng_node_from_cache(const std::string& name) { +Output Graph::get_ov_node_from_cache(const std::string& name) { return m_cache->get_node(name); } OPENVINO_SUPPRESS_DEPRECATED_START -OutputVector Graph::get_ng_outputs() { +OutputVector Graph::get_ov_outputs() { OutputVector results; for (const auto& output : m_model->get_graph().output()) { - const auto& ng_output = get_ng_node_from_cache(output.name()); - if (!ngraph::op::is_null(ng_output)) // ignore optional outputs + const auto& ov_output = get_ov_node_from_cache(output.name()); + if (!ov::op::util::is_null(ov_output)) // ignore optional outputs { - results.emplace_back(ng_output); + results.emplace_back(ov_output); } } return results; } -OutputVector Graph::make_ng_nodes(const Node& onnx_node) { - OutputVector ng_subgraph_outputs; +OutputVector Graph::make_ov_nodes(const Node& onnx_node) { + OutputVector ov_subgraph_outputs; std::string error_message; if (m_model->is_operator_available(onnx_node.op_type(), onnx_node.domain())) { const auto ng_node_factory = m_model->get_operator(onnx_node.op_type(), onnx_node.domain()); try { - ng_subgraph_outputs = ng_node_factory(onnx_node); + ov_subgraph_outputs = ng_node_factory(onnx_node); } catch (const ::ngraph::onnx_import::error::OnnxNodeValidationFailure& e) { error_message = e.what(); } catch (const std::exception& exc) { @@ -370,17 +372,17 @@ OutputVector Graph::make_ng_nodes(const Node& onnx_node) { error_message += "Unhandled exception type. \n"; } } - if (ng_subgraph_outputs.empty()) { // translation not possible (not supported op or exception during processing) + if (ov_subgraph_outputs.empty()) { // translation not possible (not supported op or exception during processing) const auto not_supported_node = std::make_shared(onnx_node.get_ng_inputs(), onnx_node.get_outputs_size(), onnx_node.domain(), onnx_node.op_type(), error_message); - ng_subgraph_outputs = not_supported_node->outputs(); + ov_subgraph_outputs = not_supported_node->outputs(); } - const size_t outputs_size = std::accumulate(std::begin(ng_subgraph_outputs), - std::end(ng_subgraph_outputs), + const size_t outputs_size = std::accumulate(std::begin(ov_subgraph_outputs), + std::end(ov_subgraph_outputs), static_cast(0), [](const size_t lhs, const Output& rhs) { return lhs + rhs.get_node()->get_output_size(); @@ -394,29 +396,29 @@ OutputVector Graph::make_ng_nodes(const Node& onnx_node) { outputs_size, " outputs"); - set_friendly_names(onnx_node, ng_subgraph_outputs); + set_friendly_names(onnx_node, ov_subgraph_outputs); for (std::size_t i{0}; i < onnx_node.get_outputs_size(); ++i) { - auto ng_node_output = ng_subgraph_outputs.at(i); - m_cache->emplace_node(onnx_node.output(static_cast(i)), std::move(ng_node_output)); + auto ov_node_output = ov_subgraph_outputs.at(i); + m_cache->emplace_node(onnx_node.output(static_cast(i)), std::move(ov_node_output)); } - return ng_subgraph_outputs; + return ov_subgraph_outputs; } -void Graph::set_friendly_names(const Node& onnx_node, const OutputVector& ng_subgraph_outputs) const { - if (std::all_of(std::begin(ng_subgraph_outputs), std::end(ng_subgraph_outputs), common::is_optimized_out)) { - for (size_t i = 0; i < ng_subgraph_outputs.size(); ++i) { - ng_subgraph_outputs[i].get_tensor().add_names({onnx_node.output(static_cast(i))}); - ng_subgraph_outputs[i].get_node_shared_ptr()->set_friendly_name(onnx_node.output(static_cast(i))); +void Graph::set_friendly_names(const Node& onnx_node, const OutputVector& ov_subgraph_outputs) const { + if (std::all_of(std::begin(ov_subgraph_outputs), std::end(ov_subgraph_outputs), common::is_optimized_out)) { + for (size_t i = 0; i < ov_subgraph_outputs.size(); ++i) { + ov_subgraph_outputs[i].get_tensor().add_names({onnx_node.output(static_cast(i))}); + ov_subgraph_outputs[i].get_node_shared_ptr()->set_friendly_name(onnx_node.output(static_cast(i))); } return; } - const auto common_node = detail::common_node_for_all_outputs(ng_subgraph_outputs); + const auto common_node = detail::common_node_for_all_outputs(ov_subgraph_outputs); - const auto ng_subgraph_output_size = static_cast(ng_subgraph_outputs.size()); - for (int i = 0; i < ng_subgraph_output_size; ++i) { + const auto ov_subgraph_output_size = static_cast(ov_subgraph_outputs.size()); + for (int i = 0; i < ov_subgraph_output_size; ++i) { // Trailing optional outputs may not be specified in the ONNX model. // Other optional outputs should have name set to an empty string. if (i >= static_cast(onnx_node.get_outputs_size())) { @@ -427,21 +429,21 @@ void Graph::set_friendly_names(const Node& onnx_node, const OutputVector& ng_sub if (onnx_node_name.empty()) { // for multioutput nodes, their friendly name is always set to the last ONNX output's name // this is because this setter is called in a loop and the last call is ultimate for a given node - ng_subgraph_outputs[i].get_node()->set_friendly_name(onnx_node.output(i)); + ov_subgraph_outputs[i].get_node()->set_friendly_name(onnx_node.output(i)); } else { if (common_node) { - ng_subgraph_outputs[i].get_node()->set_friendly_name(onnx_node.get_name()); + ov_subgraph_outputs[i].get_node()->set_friendly_name(onnx_node.get_name()); } else { // if different outputs are produced by different nodes, then those nodes need to be given // unique friendly names - ng_subgraph_outputs[i].get_node()->set_friendly_name(onnx_node.get_name() + "_" + onnx_node.output(i)); + ov_subgraph_outputs[i].get_node()->set_friendly_name(onnx_node.get_name() + "_" + onnx_node.output(i)); } } // null node does not have tensor - if (!ngraph::op::is_null(ng_subgraph_outputs[i])) { - ng_subgraph_outputs[i].get_tensor().set_names({onnx_node.output(static_cast(i))}); - ov::descriptor::set_ov_tensor_legacy_name(ng_subgraph_outputs[i].get_tensor(), + if (!ov::op::util::is_null(ov_subgraph_outputs[i])) { + ov_subgraph_outputs[i].get_tensor().set_names({onnx_node.output(static_cast(i))}); + ov::descriptor::set_ov_tensor_legacy_name(ov_subgraph_outputs[i].get_tensor(), onnx_node.output(static_cast(i))); } } @@ -460,21 +462,21 @@ Subgraph::Subgraph(const std::shared_ptr& model_prot detail::subgraph_required_extensions(parent_graph->get_extensions())), m_parent_graph(parent_graph) {} -bool Subgraph::is_ng_node_in_cache(const std::string& name) const { +bool Subgraph::is_ov_node_in_cache(const std::string& name) const { if (m_cache->contains(name)) { return true; } - return m_parent_graph->is_ng_node_in_cache(name); + return m_parent_graph->is_ov_node_in_cache(name); } -Output Subgraph::get_ng_node_from_cache(const std::string& name) { +Output Subgraph::get_ov_node_from_cache(const std::string& name) { if (m_cache->contains(name)) { return m_cache->get_node(name); } - const auto from_parent_node = m_parent_graph->get_ng_node_from_cache(name); + const auto from_parent_node = m_parent_graph->get_ov_node_from_cache(name); if (ov::op::util::is_constant(from_parent_node.get_node())) return from_parent_node; - auto new_param = std::make_shared(from_parent_node.get_element_type(), + auto new_param = std::make_shared(from_parent_node.get_element_type(), from_parent_node.get_partial_shape()); m_parameter_to_parent_node_map.insert({new_param, name}); m_cache->emplace_node(name, new_param); @@ -484,21 +486,21 @@ Output Subgraph::get_ng_node_from_cache(const std::string& name) { } std::shared_ptr Subgraph::convert() { - convert_to_ngraph_nodes(); + convert_to_ov_nodes(); return create_function(); } -const std::vector> Subgraph::get_inputs_from_parent() const { +const std::vector> Subgraph::get_inputs_from_parent() const { OutputVector result; for (const auto& name : m_inputs_from_parent) { - result.push_back(m_parent_graph->get_ng_node_from_cache(name)); + result.push_back(m_parent_graph->get_ov_node_from_cache(name)); } return result; } void Subgraph::infer_inputs_from_parent() { for (auto& it : m_parameter_to_parent_node_map) { - const auto& node = m_parent_graph->get_ng_node_from_cache(it.second); + const auto& node = m_parent_graph->get_ov_node_from_cache(it.second); auto& parameter = it.first; parameter->set_element_type(node.get_element_type()); parameter->set_partial_shape(node.get_partial_shape()); diff --git a/src/frontends/onnx/frontend/src/core/graph.hpp b/src/frontends/onnx/frontend/src/core/graph.hpp index 69309318c3fbf5..bccde080ad1339 100644 --- a/src/frontends/onnx/frontend/src/core/graph.hpp +++ b/src/frontends/onnx/frontend/src/core/graph.hpp @@ -12,11 +12,10 @@ #include "core/graph_cache.hpp" #include "core/model.hpp" -#include "ngraph/function.hpp" -#include "ngraph/op/parameter.hpp" #include "onnx_import/core/operator_set.hpp" #include "openvino/core/deprecated.hpp" #include "openvino/frontend/extension/holder.hpp" +#include "openvino/op/parameter.hpp" #include "ops_bridge.hpp" #include "utils/tensor_external_data.hpp" @@ -37,7 +36,7 @@ class Graph : public std::enable_shared_from_this { Graph& operator=(Graph&&) = default; std::shared_ptr decode(); virtual std::shared_ptr convert(); - OutputVector get_ng_outputs(); + OutputVector get_ov_outputs(); const std::string& get_name() const { return m_model->get_graph().name(); } @@ -50,10 +49,10 @@ class Graph : public std::enable_shared_from_this { const ParameterVector& get_ng_parameters() const { return m_parameters; } - virtual bool is_ng_node_in_cache(const std::string& name) const; - virtual Output get_ng_node_from_cache(const std::string& name); + virtual bool is_ov_node_in_cache(const std::string& name) const; + virtual Output get_ov_node_from_cache(const std::string& name); OPENVINO_SUPPRESS_DEPRECATED_START - OutputVector make_ng_nodes(const Node& onnx_node); + OutputVector make_ov_nodes(const Node& onnx_node); OPENVINO_SUPPRESS_DEPRECATED_END const OpsetImports& get_opset_imports() const; virtual ~Graph() = default; @@ -78,7 +77,7 @@ class Graph : public std::enable_shared_from_this { OutputVector make_framework_nodes(const Node& onnx_node); OPENVINO_SUPPRESS_DEPRECATED_END void decode_to_framework_nodes(); - void convert_to_ngraph_nodes(); + void convert_to_ov_nodes(); void remove_dangling_parameters(); void set_metadata(std::shared_ptr& model) const; std::shared_ptr create_function(); @@ -110,7 +109,7 @@ class Subgraph : public Graph { /// \brief Return nodes which are on the edge the subgraph and the parent graph. /// \return Vector of edge nodes from parent scope. - const std::vector> get_inputs_from_parent() const; + const std::vector> get_inputs_from_parent() const; std::shared_ptr convert() override; @@ -122,14 +121,14 @@ class Subgraph : public Graph { Subgraph& operator=(const Subgraph&) = delete; Subgraph& operator=(Subgraph&&) = default; - bool is_ng_node_in_cache(const std::string& name) const override; - Output get_ng_node_from_cache(const std::string& name) override; + bool is_ov_node_in_cache(const std::string& name) const override; + Output get_ov_node_from_cache(const std::string& name) override; void infer_inputs_from_parent(); private: Graph* m_parent_graph; std::vector m_inputs_from_parent; - std::unordered_map, std::string> m_parameter_to_parent_node_map; + std::unordered_map, std::string> m_parameter_to_parent_node_map; }; inline std::ostream& operator<<(std::ostream& outs, const Graph& graph) { diff --git a/src/frontends/onnx/frontend/src/core/node.cpp b/src/frontends/onnx/frontend/src/core/node.cpp index 77cd0c403be53a..fe329d33e4303e 100644 --- a/src/frontends/onnx/frontend/src/core/node.cpp +++ b/src/frontends/onnx/frontend/src/core/node.cpp @@ -203,7 +203,7 @@ OutputVector Node::Impl::get_ng_inputs() const { OutputVector result; for (const auto& name : m_node_proto->input()) { if (!name.empty()) { - result.push_back(m_graph->get_ng_node_from_cache(name)); + result.push_back(m_graph->get_ov_node_from_cache(name)); } else { OPENVINO_SUPPRESS_DEPRECATED_START result.push_back(std::make_shared()->output(0)); diff --git a/src/frontends/onnx/frontend/src/core/null_node.cpp b/src/frontends/onnx/frontend/src/core/null_node.cpp index e5c26d70ddf1f3..78131c4f85e8b5 100644 --- a/src/frontends/onnx/frontend/src/core/null_node.cpp +++ b/src/frontends/onnx/frontend/src/core/null_node.cpp @@ -6,8 +6,8 @@ #include -#include "ngraph/node.hpp" #include "openvino/core/deprecated.hpp" +#include "openvino/core/node.hpp" OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { @@ -18,15 +18,15 @@ std::shared_ptr NullNode::clone_with_new_inputs(const ov::OutputVector } // namespace onnx_import } // namespace ngraph -bool ngraph::op::is_null(const ngraph::Node* node) { +bool ov::op::util::is_null(const ov::Node* node) { return dynamic_cast(node) != nullptr; } -bool ngraph::op::is_null(const std::shared_ptr& node) { +bool ov::op::util::is_null(const std::shared_ptr& node) { return is_null(node.get()); } -bool ngraph::op::is_null(const Output& output) { +bool ov::op::util::is_null(const Output& output) { return is_null(output.get_node()); } OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/frontends/onnx/frontend/src/onnx_framework_node.hpp b/src/frontends/onnx/frontend/src/onnx_framework_node.hpp index 54d821acddec81..e4f48fc1515c5e 100644 --- a/src/frontends/onnx/frontend/src/onnx_framework_node.hpp +++ b/src/frontends/onnx/frontend/src/onnx_framework_node.hpp @@ -51,7 +51,7 @@ class ONNXFrameworkNode : public ov::op::util::FrameworkNode { } OutputVector get_ng_nodes(const std::shared_ptr& graph) const { - OutputVector ng_nodes{graph->make_ng_nodes(m_node)}; + OutputVector ng_nodes{graph->make_ov_nodes(m_node)}; if (ng_nodes.size() > get_output_size()) { ng_nodes.resize(get_output_size()); } diff --git a/src/frontends/onnx/frontend/src/op/if.cpp b/src/frontends/onnx/frontend/src/op/if.cpp index 6de301589456ee..6efd0771136cf0 100644 --- a/src/frontends/onnx/frontend/src/op/if.cpp +++ b/src/frontends/onnx/frontend/src/op/if.cpp @@ -22,12 +22,12 @@ OutputVector if_op(const Node& node) { auto then_subgraph = subgraphs.at("then_branch"); const auto& then_params = then_subgraph->get_ng_parameters(); auto then_branch = - std::make_shared(then_subgraph->get_ng_outputs(), then_params, then_subgraph->get_name()); + std::make_shared(then_subgraph->get_ov_outputs(), then_params, then_subgraph->get_name()); NGRAPH_CHECK(subgraphs.count("else_branch") == 1, "Missing 'else_branch' attribute"); auto else_subgraph = subgraphs.at("else_branch"); const auto& else_params = else_subgraph->get_ng_parameters(); auto else_branch = - std::make_shared(else_subgraph->get_ng_outputs(), else_params, else_subgraph->get_name()); + std::make_shared(else_subgraph->get_ov_outputs(), else_params, else_subgraph->get_name()); auto if_node = std::make_shared(ng_inputs.at(0)); if_node->set_then_body(then_branch); diff --git a/src/frontends/onnx/frontend/src/op/loop.cpp b/src/frontends/onnx/frontend/src/op/loop.cpp index 1889113d5ccaf0..27e7afe8c77b69 100644 --- a/src/frontends/onnx/frontend/src/op/loop.cpp +++ b/src/frontends/onnx/frontend/src/op/loop.cpp @@ -45,7 +45,7 @@ OutputVector loop(const Node& node) { const auto& subgraphs = node.get_subgraphs(); auto body_graph = subgraphs.at("body"); - auto body_outputs = body_graph->get_ng_outputs(); + auto body_outputs = body_graph->get_ov_outputs(); const auto& body_inputs = body_graph->get_ng_parameters(); // Infer loop body inputs' element type based on carried dependencies diff --git a/src/frontends/onnx/frontend/src/op/scan.cpp b/src/frontends/onnx/frontend/src/op/scan.cpp index 6592de7b02f08c..567c2e3d9ab1e5 100644 --- a/src/frontends/onnx/frontend/src/op/scan.cpp +++ b/src/frontends/onnx/frontend/src/op/scan.cpp @@ -126,7 +126,7 @@ OutputVector import_onnx_scan(const Node& node, const auto& subgraphs = node.get_subgraphs(); auto body_graph = subgraphs.at("body"); - auto body_outputs = body_graph->get_ng_outputs(); + auto body_outputs = body_graph->get_ov_outputs(); auto body_inputs = body_graph->get_ng_parameters(); const int64_t num_scan_inputs = node.get_attribute_value("num_scan_inputs");