diff --git a/ngraph/core/include/openvino/op/util/broadcast_base.hpp b/ngraph/core/include/openvino/op/util/broadcast_base.hpp index 10f436ccafb4dd..d06771b621221e 100644 --- a/ngraph/core/include/openvino/op/util/broadcast_base.hpp +++ b/ngraph/core/include/openvino/op/util/broadcast_base.hpp @@ -52,8 +52,8 @@ class OPENVINO_API BroadcastBase : public Op { bool evaluate_broadcast(const HostTensorPtr& arg0, const HostTensorPtr& out, - const std::pair pair_broadcast_axes, - const ngraph::Shape output_shape) const; + const std::pair& pair_broadcast_axes, + const ngraph::Shape& output_shape) const; bool evaluate_broadcast(const HostTensorPtr& arg0, const HostTensorPtr& out, const AxisSet& broadcast_axes) const; @@ -70,7 +70,7 @@ class OPENVINO_API BroadcastBase : public Op { const ngraph::Shape& result_shape, const op::BroadcastModeSpec& broadcast_spec); - static std::pair get_broadcast_axes_none(const AxisVector axes_mapping_val, + static std::pair get_broadcast_axes_none(const AxisVector& axes_mapping_val, const size_t target_shape); void validate_target_shape_none(const PartialShape& arg_shape, diff --git a/ngraph/core/include/openvino/op/util/variable.hpp b/ngraph/core/include/openvino/op/util/variable.hpp index b5faa267588d90..c9a54506545462 100644 --- a/ngraph/core/include/openvino/op/util/variable.hpp +++ b/ngraph/core/include/openvino/op/util/variable.hpp @@ -26,6 +26,7 @@ struct VariableInfo { class OPENVINO_API Variable { public: + using Ptr = std::shared_ptr; Variable() = default; explicit Variable(const VariableInfo& variable_info) : m_info(variable_info) {} @@ -40,8 +41,7 @@ class OPENVINO_API Variable { private: VariableInfo m_info; }; -using VariablePtr = std::shared_ptr; -using VariableVector = std::vector; +using VariableVector = std::vector; } // namespace util } // namespace op diff --git a/ngraph/core/include/openvino/op/util/variable_context.hpp b/ngraph/core/include/openvino/op/util/variable_context.hpp index 4f698c655863bd..0cfb29f28573e0 100644 --- a/ngraph/core/include/openvino/op/util/variable_context.hpp +++ b/ngraph/core/include/openvino/op/util/variable_context.hpp @@ -15,7 +15,7 @@ namespace ov { namespace op { namespace util { -using VariableMap = std::unordered_map; +using VariableMap = std::unordered_map; /// VariableContext stores and manages a evaluation context for Variables. class NGRAPH_API VariableContext { @@ -43,13 +43,13 @@ class NGRAPH_API VariableContext { /// \brief Changes/sets the values for Variable. /// \param variable New or stored Variable. /// \param variable_value The values associated with the variable. - void set_variable_value(const VariablePtr& variable, const VariableValue::Ptr& variable_value) { + void set_variable_value(const Variable::Ptr& variable, const VariableValue::Ptr& variable_value) { m_variable_values[variable] = variable_value; } /// \brief Removes context for a particular Variable. /// \param variable The variable for which the context will be cleared. - void remove_variable_value(const VariablePtr& variable) { + void remove_variable_value(const Variable::Ptr& variable) { m_variable_values.erase(variable); } @@ -59,7 +59,7 @@ class NGRAPH_API VariableContext { } /// \brief Returns the value for specified Variable. - VariableValue::Ptr get_variable_value(const VariablePtr& variable) const { + VariableValue::Ptr get_variable_value(const Variable::Ptr& variable) const { auto var_value = m_variable_values.find(variable); if (var_value != m_variable_values.end()) { return (*var_value).second; diff --git a/ngraph/core/src/function.cpp b/ngraph/core/src/function.cpp index 88de5c26743981..330747d2faa843 100644 --- a/ngraph/core/src/function.cpp +++ b/ngraph/core/src/function.cpp @@ -7,129 +7,133 @@ #include #include #include -#include #include "itt.hpp" #include "ngraph/graph_util.hpp" #include "ngraph/log.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "ngraph/op/util/variable_context.hpp" -#include "ngraph/op/util/variable_extension.hpp" +#include "ngraph/ops.hpp" #include "ngraph/opsets/opset7.hpp" #include "ngraph/validation_util.hpp" +#include "openvino/core/except.hpp" +#include "openvino/op/util/op_types.hpp" +#include "openvino/op/util/variable_context.hpp" +#include "openvino/op/util/variable_extension.hpp" using namespace std; -using namespace ngraph; -constexpr DiscreteTypeInfo Function::type_info; +constexpr ov::DiscreteTypeInfo ov::Function::type_info; -atomic Function::m_next_instance_id(0); +atomic ov::Function::m_next_instance_id(0); -void check_all_variables_registered(const std::vector>& ordered_ops, const VariableVector& variables) { +void check_all_variables_registered(const std::vector>& ordered_ops, + const ov::op::util::VariableVector& variables) { OV_ITT_SCOPED_TASK(ov::itt::domains::nGraphPass_LT, "Function::check_all_variables_registered"); std::stringstream unregistered_variables; for (auto& node : ordered_ops) { - const auto& variable_op = dynamic_pointer_cast(node); + const auto& variable_op = dynamic_pointer_cast(node); if (variable_op && std::find(variables.begin(), variables.end(), variable_op->get_variable()) == variables.end()) unregistered_variables << variable_op->get_variable_id() << std::endl; } if (!unregistered_variables.str().empty()) - throw ngraph_error("Function references undeclared variables: " + unregistered_variables.str()); + throw ov::Exception("Function references undeclared variables: " + unregistered_variables.str()); } -void check_all_parameters_registered(const std::vector>& ordered_ops, - const ParameterVector& parameters) { +void check_all_parameters_registered(const std::vector>& ordered_ops, + const ngraph::ParameterVector& parameters) { OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::check_all_parameters_registered"); std::stringstream unregistered_parameters; for (auto& node : ordered_ops) { - if (op::is_parameter(node) && std::find(parameters.begin(), parameters.end(), node) == parameters.end()) + if (ov::op::util::is_parameter(node) && + std::find(parameters.begin(), parameters.end(), node) == parameters.end()) unregistered_parameters << node << std::endl; } if (!unregistered_parameters.str().empty()) - throw ngraph_error("Function references undeclared parameters: " + unregistered_parameters.str()); + throw ov::Exception("Function references undeclared parameters: " + unregistered_parameters.str()); } -VariableVector auto_detect_variables(const std::vector>& ordered_ops) { +ov::op::util::VariableVector auto_detect_variables(const std::vector>& ordered_ops) { OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::auto_detect_variables"); - unordered_set variables; + unordered_set variables; for (const auto& op : ordered_ops) { - if (const auto& variable_op = dynamic_pointer_cast(op)) { + if (const auto& variable_op = dynamic_pointer_cast(op)) { variables.insert(variable_op->get_variable()); } } - return VariableVector(variables.begin(), variables.end()); + return ov::op::util::VariableVector(variables.begin(), variables.end()); } -ParameterVector auto_detect_parameters(const std::vector>& ordered_ops) { +ngraph::ParameterVector auto_detect_parameters(const std::vector>& ordered_ops) { OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::auto_detect_parameters"); - ParameterVector parameter_vector; + ngraph::ParameterVector parameter_vector; for (const auto& op : ordered_ops) { - if (const auto& param = dynamic_pointer_cast(op)) { + if (const auto& param = dynamic_pointer_cast(op)) { parameter_vector.push_back(param); } } return parameter_vector; } -Function::Function(const ResultVector& results, const ParameterVector& parameters, const std::string& name) +ov::Function::Function(const ResultVector& results, const ngraph::ParameterVector& parameters, const std::string& name) : m_name(name), m_unique_name("Function_" + to_string(m_next_instance_id.fetch_add(1))), - m_topological_sorter(topological_sort>>), + m_topological_sorter(ngraph::topological_sort>>), m_results(results), m_parameters(parameters) { prerequirements(true, false); } -Function::Function(const OutputVector& results, const ParameterVector& parameters, const std::string& name) +ov::Function::Function(const OutputVector& results, const ngraph::ParameterVector& parameters, const std::string& name) : m_name(name), m_unique_name("Function_" + to_string(m_next_instance_id.fetch_add(1))), - m_topological_sorter(topological_sort>>), + m_topological_sorter(ngraph::topological_sort>>), m_results(as_result_vector(results)), m_parameters(parameters) { prerequirements(true, false); } -Function::Function(const NodeVector& results, const ParameterVector& parameters, const std::string& name) +ov::Function::Function(const NodeVector& results, const ngraph::ParameterVector& parameters, const std::string& name) : m_name(name), m_unique_name("Function_" + to_string(m_next_instance_id.fetch_add(1))), - m_topological_sorter(topological_sort>>), + m_topological_sorter(ngraph::topological_sort>>), m_results(as_result_vector(as_output_vector(results))), m_parameters(parameters) { prerequirements(true, false); } -Function::Function(const std::shared_ptr& result, const ParameterVector& parameters, const std::string& name) +ov::Function::Function(const std::shared_ptr& result, + const ngraph::ParameterVector& parameters, + const std::string& name) : Function(result->outputs(), parameters, name) {} -Function::Function(const ResultVector& results, - const SinkVector& sinks, - const ParameterVector& parameters, - const std::string& name) +ov::Function::Function(const ngraph::ResultVector& results, + const ngraph::SinkVector& sinks, + const ngraph::ParameterVector& parameters, + const std::string& name) : m_name(name), m_unique_name("Function_" + to_string(m_next_instance_id.fetch_add(1))), - m_topological_sorter(topological_sort>>), + m_topological_sorter(ngraph::topological_sort>>), m_results(results), m_sinks(sinks), m_parameters(parameters) { prerequirements(true, false); } -Function::Function(const OutputVector& results, - const SinkVector& sinks, - const ParameterVector& parameters, - const std::string& name) +ov::Function::Function(const OutputVector& results, + const ngraph::SinkVector& sinks, + const ngraph::ParameterVector& parameters, + const std::string& name) : Function(as_result_vector(results), sinks, parameters, name) {} -Function::Function(const ResultVector& results, - const SinkVector& sinks, - const ParameterVector& parameters, - const VariableVector& variables, - const std::string& name) +ov::Function::Function(const ngraph::ResultVector& results, + const ngraph::SinkVector& sinks, + const ngraph::ParameterVector& parameters, + const ngraph::VariableVector& variables, + const std::string& name) : m_name(name), m_unique_name("Function_" + to_string(m_next_instance_id.fetch_add(1))), - m_topological_sorter(topological_sort>>), + m_topological_sorter(ngraph::topological_sort>>), m_results(results), m_sinks(sinks), m_parameters(parameters), @@ -137,37 +141,38 @@ Function::Function(const ResultVector& results, prerequirements(false, false); } -Function::Function(const OutputVector& results, - const SinkVector& sinks, - const ParameterVector& parameters, - const VariableVector& variables, - const std::string& name) +ov::Function::Function(const OutputVector& results, + const ngraph::SinkVector& sinks, + const ngraph::ParameterVector& parameters, + const ngraph::VariableVector& variables, + const std::string& name) : Function(as_result_vector(results), sinks, parameters, variables, name) {} -Function::Function(const OutputVector& results, - const ParameterVector& parameters, - const VariableVector& variables, - const std::string& name) +ov::Function::Function(const ngraph::OutputVector& results, + const ngraph::ParameterVector& parameters, + const ngraph::VariableVector& variables, + const std::string& name) : Function(as_result_vector(results), {}, parameters, variables, name) {} -Function::Function(const ResultVector& results, - const ParameterVector& parameters, - const VariableVector& variables, - const std::string& name) +ov::Function::Function(const ngraph::ResultVector& results, + const ngraph::ParameterVector& parameters, + const ngraph::VariableVector& variables, + const std::string& name) : Function(results, {}, parameters, variables, name) {} -Function::Function(const OutputVector& results, const SinkVector& sinks, const string& name) +ov::Function::Function(const ngraph::OutputVector& results, const ngraph::SinkVector& sinks, const string& name) : m_name(name), m_unique_name("Function_" + to_string(m_next_instance_id.fetch_add(1))), - m_topological_sorter(topological_sort>>), + m_topological_sorter(ngraph::topological_sort>>), m_results(as_result_vector(results)), m_sinks(sinks) { prerequirements(true, true); } -Function::Function(const OutputVector& results, const string& name) : Function(results, SinkVector{}, name) {} +ov::Function::Function(const OutputVector& results, const string& name) + : Function(results, ngraph::SinkVector{}, name) {} -void Function::prerequirements(bool detect_variables, bool detect_parameters) { +void ov::Function::prerequirements(bool detect_variables, bool detect_parameters) { OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::prerequirements"); const auto& ordered_ops = get_ordered_ops(); @@ -182,47 +187,48 @@ void Function::prerequirements(bool detect_variables, bool detect_parameters) { check_all_variables_registered(ordered_ops, m_variables); } -void Function::validate_nodes_and_infer_types() const { +void ov::Function::validate_nodes_and_infer_types() const { OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::validate_nodes_and_infer_types"); struct Counter { int cnt_assign = 0; int cnt_read_val = 0; }; - std::map pair_checker; + std::map pair_checker; std::stringstream unregistered_parameters; std::stringstream unregistered_variables; for (auto& node : get_ordered_ops()) { node->revalidate_and_infer_types(); - if (op::is_parameter(node) && std::find(m_parameters.begin(), m_parameters.end(), node) == m_parameters.end()) + if (op::util::is_parameter(node) && + std::find(m_parameters.begin(), m_parameters.end(), node) == m_parameters.end()) unregistered_parameters << node << std::endl; - const auto& variable_op = dynamic_pointer_cast(node); + const auto& variable_op = dynamic_pointer_cast(node); if (variable_op && std::find(m_variables.begin(), m_variables.end(), variable_op->get_variable()) == m_variables.end()) unregistered_variables << variable_op->get_variable_id() << std::endl; - if (const auto& assign = std::dynamic_pointer_cast(node)) { + if (const auto& assign = std::dynamic_pointer_cast(node)) { pair_checker[assign->get_variable().get()].cnt_assign++; - } else if (const auto& read_value = std::dynamic_pointer_cast(node)) { + } else if (const auto& read_value = std::dynamic_pointer_cast(node)) { pair_checker[read_value->get_variable().get()].cnt_read_val++; } } if (!unregistered_parameters.str().empty()) - throw ngraph_error("Function references undeclared parameters: " + unregistered_parameters.str()); + throw ov::Exception("Function references undeclared parameters: " + unregistered_parameters.str()); if (!unregistered_variables.str().empty()) - throw ngraph_error("Function references undeclared Variables: " + unregistered_variables.str()); + throw ov::Exception("Function references undeclared Variables: " + unregistered_variables.str()); bool only_pairs = - std::all_of(pair_checker.begin(), pair_checker.end(), [](const std::pair& val) { + std::all_of(pair_checker.begin(), pair_checker.end(), [](const std::pair& val) { return val.second.cnt_assign == 1 && val.second.cnt_read_val == 1; }); if (!only_pairs) - throw ngraph_error("Function is incorrect. Assign and ReadValue operations must be in pairs on the " - "network."); + throw ov::Exception("Function is incorrect. Assign and ReadValue operations must be in pairs on the " + "network."); } -std::vector> Function::get_ordered_ops() const { +std::vector> ov::Function::get_ordered_ops() const { OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::get_ordered_ops"); vector> nodes; @@ -239,7 +245,7 @@ std::vector> Function::get_ordered_ops() const { return m_topological_sorter(nodes); } -void Function::map_unordered_ops(std::function f) const { +void ov::Function::map_unordered_ops(std::function f) const { std::unordered_set unordered_ops; std::stack> remaining_ops; for (auto& r : get_results()) { @@ -267,75 +273,75 @@ void Function::map_unordered_ops(std::function f) const { } } -const std::string& Function::get_friendly_name() const { +const std::string& ov::Function::get_friendly_name() const { if (m_name.empty()) { return m_unique_name; } return m_name; } -const std::string& Function::get_name() const { +const std::string& ov::Function::get_name() const { return m_unique_name; } -void Function::set_friendly_name(const string& name) { +void ov::Function::set_friendly_name(const string& name) { m_name = name; } -std::ostream& operator<<(std::ostream& out, const Function& f) { +std::ostream& operator<<(std::ostream& out, const ov::Function& f) { out << "Function(" << f.get_name() << ")"; return out; } -size_t Function::get_output_size() const { +size_t ov::Function::get_output_size() const { return m_results.size(); } -const element::Type& Function::get_output_element_type(size_t i) const { +const ov::element::Type& ov::Function::get_output_element_type(size_t i) const { return m_results.at(i)->get_element_type(); } -const Shape& Function::get_output_shape(size_t i) const { +const ngraph::Shape& ov::Function::get_output_shape(size_t i) const { return m_results.at(i)->get_shape(); } -const PartialShape& Function::get_output_partial_shape(size_t i) const { +const ov::PartialShape& ov::Function::get_output_partial_shape(size_t i) const { return m_results.at(i)->get_output_partial_shape(0); } -shared_ptr Function::get_output_op(size_t i) const { +shared_ptr ov::Function::get_output_op(size_t i) const { return m_results.at(i); } -Output Function::output(size_t i) const { +ov::Output ov::Function::output(size_t i) const { return m_results.at(i); } -shared_ptr Function::get_result() const { +shared_ptr ov::Function::get_result() const { if (m_results.size() != 1) { - throw ngraph_error("get_result() must be called on a function with exactly one result."); + throw ov::Exception("get_result() must be called on a function with exactly one result."); } return m_results.at(0); } -std::vector> Function::get_ops() const { +std::vector> ov::Function::get_ops() const { std::vector> ops; - traverse_nodes(this, [&](shared_ptr node) { + ngraph::traverse_nodes(this, [&](shared_ptr node) { ops.push_back(node); }); return ops; } -void Function::replace_node(std::shared_ptr old, std::shared_ptr repl) { +void ov::Function::replace_node(std::shared_ptr old, std::shared_ptr repl) { ngraph::replace_node(old, repl); } -size_t Function::get_graph_size() const { +size_t ov::Function::get_graph_size() const { size_t total_size = 0; for (auto node : get_ops()) { total_size += sizeof(*node); if (node->description() == "Constant") { - const Shape& shape = node->get_output_shape(0); + const ngraph::Shape& shape = node->get_output_shape(0); size_t const_size = node->get_output_element_type(0).size(); if (shape.size() == 0) { total_size += const_size; @@ -347,10 +353,7 @@ size_t Function::get_graph_size() const { return total_size; } -// TODO(pthoreho) this will be expensive, since we will be traversing all the nodes in -// the graph, figure out if their is a way to cache the result and invalidate/update -// the result if the function is modified -bool Function::is_dynamic() const { +bool ov::Function::is_dynamic() const { auto list_of_nodes = this->get_ops(); for (auto& node : list_of_nodes) { if (node->get_output_partial_shape(0).is_dynamic()) { @@ -360,7 +363,7 @@ bool Function::is_dynamic() const { return false; } -void Function::replace_parameter(size_t parameter_index, const shared_ptr& parameter) { +void ov::Function::replace_parameter(size_t parameter_index, const shared_ptr& parameter) { NGRAPH_CHECK(parameter_index < m_parameters.size(), "replace_parameter(): Tried to replace parameter at index ", parameter_index, @@ -371,11 +374,11 @@ void Function::replace_parameter(size_t parameter_index, const shared_ptr& parameter) const { +int64_t ov::Function::get_parameter_index(const std::shared_ptr& parameter) const { int64_t pos = 0; for (auto p : get_parameters()) { if (p == parameter) { @@ -386,9 +389,9 @@ int64_t Function::get_parameter_index(const std::shared_ptr& para return -1; } -int64_t Function::get_result_index(const Output& value) const { +int64_t ov::Function::get_result_index(const Output& value) const { int64_t pos = 0; - if (ov::is_type(value.get_node_shared_ptr())) { + if (is_type(value.get_node_shared_ptr())) { auto result = value.get_node_shared_ptr(); for (auto r : get_results()) { if (r == result) { @@ -407,11 +410,12 @@ int64_t Function::get_result_index(const Output& value) const { return -1; } -bool Function::evaluate(const HostTensorVector& output_tensors, - const HostTensorVector& input_tensors, - EvaluationContext evaluation_context) const { +bool ov::Function::evaluate(const HostTensorVector& output_tensors, + const HostTensorVector& input_tensors, + EvaluationContext evaluation_context) const { if (evaluation_context.find("VariableContext") == evaluation_context.end()) - evaluation_context["VariableContext"] = std::make_shared>(VariableContext()); + evaluation_context["VariableContext"] = + std::make_shared>(ov::op::util::VariableContext()); std::map value_map; for (size_t i = 0; i < m_parameters.size(); ++i) { value_map[m_parameters.at(i)->output(0)] = input_tensors.at(i); @@ -426,20 +430,20 @@ bool Function::evaluate(const HostTensorVector& output_tensors, for (const auto& m_sink : m_sinks) { outputs.push_back(m_sink); } - evaluate_nodes(value_map, output_tensor_map, outputs, evaluation_context); + ngraph::evaluate_nodes(value_map, output_tensor_map, outputs, evaluation_context); return true; } -bool Function::visit_attributes(AttributeVisitor& visitor) { +bool ov::Function::visit_attributes(AttributeVisitor& visitor) { visitor.on_attribute("parameters", m_parameters); visitor.on_attribute("results", m_results); return true; } -void Function::add_sinks(const SinkVector& sinks) { +void ov::Function::add_sinks(const ngraph::SinkVector& sinks) { m_sinks.insert(m_sinks.end(), sinks.begin(), sinks.end()); for (const auto& sink : sinks) { - if (const auto& variable_op = dynamic_pointer_cast(sink)) { + if (const auto& variable_op = dynamic_pointer_cast(sink)) { if (find(m_variables.begin(), m_variables.end(), variable_op->get_variable()) == m_variables.end()) { m_variables.push_back(variable_op->get_variable()); } @@ -447,29 +451,29 @@ void Function::add_sinks(const SinkVector& sinks) { } } -void Function::remove_sink(const std::shared_ptr& sink) { +void ov::Function::remove_sink(const std::shared_ptr& sink) { m_sinks.erase(std::remove_if(m_sinks.begin(), m_sinks.end(), - [&sink](std::shared_ptr& s) { + [&sink](std::shared_ptr& s) { return s == sink; }), m_sinks.end()); } -void Function::add_results(const ResultVector& results) { +void ov::Function::add_results(const ResultVector& results) { m_results.insert(m_results.end(), results.begin(), results.end()); } -void Function::remove_result(const std::shared_ptr& result) { +void ov::Function::remove_result(const std::shared_ptr& result) { m_results.erase(std::remove_if(m_results.begin(), m_results.end(), - [&result](std::shared_ptr& r) { + [&result](std::shared_ptr& r) { return r == result; }), m_results.end()); } -void Function::add_parameters(const ParameterVector& params) { +void ov::Function::add_parameters(const ngraph::ParameterVector& params) { for (size_t i = 0; i < params.size(); i++) { for (size_t j = 0; j < m_parameters.size(); j++) { NGRAPH_CHECK(params[i] != m_parameters[j], @@ -482,36 +486,37 @@ void Function::add_parameters(const ParameterVector& params) { m_parameters.insert(m_parameters.end(), params.begin(), params.end()); } -void Function::remove_parameter(const std::shared_ptr& param) { +void ov::Function::remove_parameter(const std::shared_ptr& param) { m_parameters.erase(std::remove_if(m_parameters.begin(), m_parameters.end(), - [¶m](std::shared_ptr& r) { + [¶m](std::shared_ptr& r) { return r == param; }), m_parameters.end()); } -void Function::add_variables(const VariableVector& variables) { +void ov::Function::add_variables(const op::util::VariableVector& variables) { m_variables.insert(m_variables.end(), variables.begin(), variables.end()); } -void Function::remove_variable(const VariablePtr& variable) { +void ov::Function::remove_variable(const op::util::Variable::Ptr& variable) { m_variables.erase(std::remove_if(m_variables.begin(), m_variables.end(), - [&variable](VariablePtr& v) { + [&variable](op::util::Variable::Ptr& v) { return v == variable; }), m_variables.end()); } -VariablePtr Function::get_variable_by_id(const string& variable_id) const { - auto variable = std::find_if(m_variables.begin(), m_variables.end(), [&variable_id](const VariablePtr& cur) { - return cur->get_info().variable_id == variable_id; - }); +ov::op::util::Variable::Ptr ov::Function::get_variable_by_id(const string& variable_id) const { + auto variable = + std::find_if(m_variables.begin(), m_variables.end(), [&variable_id](const ov::op::util::Variable::Ptr& cur) { + return cur->get_info().variable_id == variable_id; + }); if (variable != m_variables.end()) return *variable; else - return VariablePtr(); + return ov::op::util::Variable::Ptr(); } -constexpr DiscreteTypeInfo AttributeAdapter>::type_info; +constexpr ov::DiscreteTypeInfo ov::AttributeAdapter>::type_info; diff --git a/ngraph/core/src/op/binary_convolution.cpp b/ngraph/core/src/op/binary_convolution.cpp index ff5c804e288365..f6439d3bd1a831 100644 --- a/ngraph/core/src/op/binary_convolution.cpp +++ b/ngraph/core/src/op/binary_convolution.cpp @@ -119,15 +119,15 @@ bool op::v1::BinaryConvolution::visit_attributes(AttributeVisitor& visitor) { namespace ov { template <> -NGRAPH_API EnumNames& -EnumNames::get() { - static auto enum_names = EnumNames( +NGRAPH_API EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::v1::BinaryConvolution::BinaryConvolutionMode", - {{"xnor-popcount", op::v1::BinaryConvolution::BinaryConvolutionMode::XNOR_POPCOUNT}}); + {{"xnor-popcount", ngraph::op::v1::BinaryConvolution::BinaryConvolutionMode::XNOR_POPCOUNT}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov std::ostream& operator<<(std::ostream& s, const op::v1::BinaryConvolution::BinaryConvolutionMode& type) { diff --git a/ngraph/core/src/op/depth_to_space.cpp b/ngraph/core/src/op/depth_to_space.cpp index 8b6eee758dd6b5..3fd9aff40973ee 100644 --- a/ngraph/core/src/op/depth_to_space.cpp +++ b/ngraph/core/src/op/depth_to_space.cpp @@ -119,13 +119,14 @@ std::ostream& ngraph::operator<<(std::ostream& s, const op::DepthToSpace::DepthT namespace ov { template <> -NGRAPH_API EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +NGRAPH_API EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::DepthToSpace::DepthToSpaceMode", - {{"blocks_first", op::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST}, - {"depth_first", op::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST}}); + {{"blocks_first", ngraph::op::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST}, + {"depth_first", ngraph::op::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov diff --git a/ngraph/core/src/op/gelu.cpp b/ngraph/core/src/op/gelu.cpp index 27152cedf2425e..76555869a89ac4 100644 --- a/ngraph/core/src/op/gelu.cpp +++ b/ngraph/core/src/op/gelu.cpp @@ -53,14 +53,14 @@ void op::v0::Gelu::validate_and_infer_types() { namespace ov { template <> -NGRAPH_API EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +NGRAPH_API EnumNames& EnumNames::get() { + static auto enum_names = EnumNames( "op::GeluApproximationMode", - {{"TANH", op::GeluApproximationMode::TANH}, {"ERF", op::GeluApproximationMode::ERF}}); + {{"TANH", ngraph::op::GeluApproximationMode::TANH}, {"ERF", ngraph::op::GeluApproximationMode::ERF}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov std::ostream& op::operator<<(std::ostream& s, const op::GeluApproximationMode& type) { return s << as_string(type); diff --git a/ngraph/core/src/op/interpolate.cpp b/ngraph/core/src/op/interpolate.cpp index 8aff95c9b8e56a..35a71268dd9a4f 100644 --- a/ngraph/core/src/op/interpolate.cpp +++ b/ngraph/core/src/op/interpolate.cpp @@ -75,17 +75,18 @@ std::ostream& ngraph::operator<<(std::ostream& s, const op::v0::Interpolate::Int namespace ov { template <> -EnumNames& EnumNames::get() { - static auto enum_names = - EnumNames("op::v0::Interpolate::InterpolateMode", - {{"nearest", op::v0::Interpolate::InterpolateMode::NEAREST}, - {"linear", op::v0::Interpolate::InterpolateMode::LINEAR}, - {"cubic", op::v0::Interpolate::InterpolateMode::CUBIC}, - {"area", op::v0::Interpolate::InterpolateMode::AREA}}); +EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( + "op::v0::Interpolate::InterpolateMode", + {{"nearest", ngraph::op::v0::Interpolate::InterpolateMode::NEAREST}, + {"linear", ngraph::op::v0::Interpolate::InterpolateMode::LINEAR}, + {"cubic", ngraph::op::v0::Interpolate::InterpolateMode::CUBIC}, + {"area", ngraph::op::v0::Interpolate::InterpolateMode::AREA}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov @@ -498,54 +499,58 @@ std::ostream& ngraph::operator<<(std::ostream& s, const op::v4::Interpolate::Nea namespace ov { template <> -NGRAPH_API EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +NGRAPH_API EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::v4::Interpolate::InterpolateMode", - {{"nearest", op::v4::Interpolate::InterpolateMode::NEAREST}, - {"linear", op::v4::Interpolate::InterpolateMode::LINEAR}, - {"linear_onnx", op::v4::Interpolate::InterpolateMode::LINEAR_ONNX}, - {"cubic", op::v4::Interpolate::InterpolateMode::CUBIC}}); + {{"nearest", ngraph::op::v4::Interpolate::InterpolateMode::NEAREST}, + {"linear", ngraph::op::v4::Interpolate::InterpolateMode::LINEAR}, + {"linear_onnx", ngraph::op::v4::Interpolate::InterpolateMode::LINEAR_ONNX}, + {"cubic", ngraph::op::v4::Interpolate::InterpolateMode::CUBIC}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; template <> -NGRAPH_API EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +NGRAPH_API EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::v4::Interpolate::ShapeCalcMode", - {{"sizes", op::v4::Interpolate::ShapeCalcMode::SIZES}, {"scales", op::v4::Interpolate::ShapeCalcMode::SCALES}}); + {{"sizes", ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES}, + {"scales", ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; template <> -NGRAPH_API EnumNames& -EnumNames::get() { - static auto enum_names = EnumNames( +NGRAPH_API EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::v4::Interpolate::CoordinateTransformMode", - {{"half_pixel", op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL}, - {"pytorch_half_pixel", op::v4::Interpolate::CoordinateTransformMode::PYTORCH_HALF_PIXEL}, - {"asymmetric", op::v4::Interpolate::CoordinateTransformMode::ASYMMETRIC}, - {"tf_half_pixel_for_nn", op::v4::Interpolate::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN}, - {"align_corners", op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS}}); + {{"half_pixel", ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL}, + {"pytorch_half_pixel", ngraph::op::v4::Interpolate::CoordinateTransformMode::PYTORCH_HALF_PIXEL}, + {"asymmetric", ngraph::op::v4::Interpolate::CoordinateTransformMode::ASYMMETRIC}, + {"tf_half_pixel_for_nn", ngraph::op::v4::Interpolate::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN}, + {"align_corners", ngraph::op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; template <> -NGRAPH_API EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +NGRAPH_API EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::v4::Interpolate::NearestMode", - {{"round_prefer_floor", op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR}, - {"round_prefer_ceil", op::v4::Interpolate::NearestMode::ROUND_PREFER_CEIL}, - {"floor", op::v4::Interpolate::NearestMode::FLOOR}, - {"ceil", op::v4::Interpolate::NearestMode::CEIL}, - {"simple", op::v4::Interpolate::NearestMode::SIMPLE}}); + {{"round_prefer_floor", ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR}, + {"round_prefer_ceil", ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_CEIL}, + {"floor", ngraph::op::v4::Interpolate::NearestMode::FLOOR}, + {"ceil", ngraph::op::v4::Interpolate::NearestMode::CEIL}, + {"simple", ngraph::op::v4::Interpolate::NearestMode::SIMPLE}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov diff --git a/ngraph/core/src/op/loop.cpp b/ngraph/core/src/op/loop.cpp index 3b1b1b2064d22d..8ab9675b86b109 100644 --- a/ngraph/core/src/op/loop.cpp +++ b/ngraph/core/src/op/loop.cpp @@ -307,5 +307,5 @@ op::v5::Loop::Loop(const op::v5::Loop& other) : SubGraphOp() { } namespace ov { -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } diff --git a/ngraph/core/src/op/lstm_cell.cpp b/ngraph/core/src/op/lstm_cell.cpp index 9dfd9b2a4e7ed1..aad2148fc6dfe6 100644 --- a/ngraph/core/src/op/lstm_cell.cpp +++ b/ngraph/core/src/op/lstm_cell.cpp @@ -335,17 +335,17 @@ shared_ptr op::v0::LSTMCell::clone_with_new_inputs(const OutputVector& new namespace ov { template <> -EnumNames& EnumNames::get() { - static auto enum_names = EnumNames("op::LSTMWeightsFormat", - {{"fico", op::LSTMWeightsFormat::FICO}, - {"icof", op::LSTMWeightsFormat::ICOF}, - {"ifco", op::LSTMWeightsFormat::IFCO}, - {"ifoc", op::LSTMWeightsFormat::IFOC}, - {"iofc", op::LSTMWeightsFormat::IOFC}}); +EnumNames& EnumNames::get() { + static auto enum_names = EnumNames("op::LSTMWeightsFormat", + {{"fico", ngraph::op::LSTMWeightsFormat::FICO}, + {"icof", ngraph::op::LSTMWeightsFormat::ICOF}, + {"ifco", ngraph::op::LSTMWeightsFormat::IFCO}, + {"ifoc", ngraph::op::LSTMWeightsFormat::IFOC}, + {"iofc", ngraph::op::LSTMWeightsFormat::IOFC}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov diff --git a/ngraph/core/src/op/matrix_nms.cpp b/ngraph/core/src/op/matrix_nms.cpp index 6a5af0f0d47492..a4f0879a1dbcd7 100644 --- a/ngraph/core/src/op/matrix_nms.cpp +++ b/ngraph/core/src/op/matrix_nms.cpp @@ -70,14 +70,15 @@ std::ostream& ngraph::operator<<(std::ostream& s, const op::v8::MatrixNms::Decay namespace ov { template <> -NGRAPH_API EnumNames& EnumNames::get() { - static auto enum_names = - EnumNames("op::v8::MatrixNms::DecayFunction", - {{"gaussian", op::v8::MatrixNms::DecayFunction::GAUSSIAN}, - {"linear", op::v8::MatrixNms::DecayFunction::LINEAR}}); +NGRAPH_API EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( + "op::v8::MatrixNms::DecayFunction", + {{"gaussian", ngraph::op::v8::MatrixNms::DecayFunction::GAUSSIAN}, + {"linear", ngraph::op::v8::MatrixNms::DecayFunction::LINEAR}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov diff --git a/ngraph/core/src/op/mvn.cpp b/ngraph/core/src/op/mvn.cpp index ed53701375dc71..0a6ae9a78d7c03 100644 --- a/ngraph/core/src/op/mvn.cpp +++ b/ngraph/core/src/op/mvn.cpp @@ -72,18 +72,18 @@ bool op::v0::MVN::visit_attributes(AttributeVisitor& visitor) { namespace ov { template <> -NGRAPH_API EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +NGRAPH_API EnumNames& EnumNames::get() { + static auto enum_names = EnumNames( "op::MVNEpsMode", - {{"OUTSIDE_SQRT", op::MVNEpsMode::OUTSIDE_SQRT}, {"INSIDE_SQRT", op::MVNEpsMode::INSIDE_SQRT}}); + {{"OUTSIDE_SQRT", ngraph::op::MVNEpsMode::OUTSIDE_SQRT}, {"INSIDE_SQRT", ngraph::op::MVNEpsMode::INSIDE_SQRT}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov -std::ostream& op::operator<<(std::ostream& s, const op::MVNEpsMode& type) { +std::ostream& op::operator<<(std::ostream& s, const ngraph::op::MVNEpsMode& type) { return s << as_string(type); } diff --git a/ngraph/core/src/op/non_max_suppression.cpp b/ngraph/core/src/op/non_max_suppression.cpp index 9a124547051622..9cdf6615ce3fcf 100644 --- a/ngraph/core/src/op/non_max_suppression.cpp +++ b/ngraph/core/src/op/non_max_suppression.cpp @@ -176,15 +176,16 @@ int64_t op::v1::NonMaxSuppression::max_boxes_output_from_input() const { namespace ov { template <> -EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::v1::NonMaxSuppression::BoxEncodingType", - {{"corner", op::v1::NonMaxSuppression::BoxEncodingType::CORNER}, - {"center", op::v1::NonMaxSuppression::BoxEncodingType::CENTER}}); + {{"corner", ngraph::op::v1::NonMaxSuppression::BoxEncodingType::CORNER}, + {"center", ngraph::op::v1::NonMaxSuppression::BoxEncodingType::CENTER}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov @@ -363,15 +364,16 @@ int64_t op::v3::NonMaxSuppression::max_boxes_output_from_input() const { namespace ov { template <> -EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::v3::NonMaxSuppression::BoxEncodingType", - {{"corner", op::v3::NonMaxSuppression::BoxEncodingType::CORNER}, - {"center", op::v3::NonMaxSuppression::BoxEncodingType::CENTER}}); + {{"corner", ngraph::op::v3::NonMaxSuppression::BoxEncodingType::CORNER}, + {"center", ngraph::op::v3::NonMaxSuppression::BoxEncodingType::CENTER}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov @@ -821,14 +823,15 @@ std::ostream& ngraph::operator<<(std::ostream& s, const op::v5::NonMaxSuppressio namespace ov { template <> -EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::v5::NonMaxSuppression::BoxEncodingType", - {{"corner", op::v5::NonMaxSuppression::BoxEncodingType::CORNER}, - {"center", op::v5::NonMaxSuppression::BoxEncodingType::CENTER}}); + {{"corner", ngraph::op::v5::NonMaxSuppression::BoxEncodingType::CORNER}, + {"center", ngraph::op::v5::NonMaxSuppression::BoxEncodingType::CENTER}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov diff --git a/ngraph/core/src/op/parameter.cpp b/ngraph/core/src/op/parameter.cpp index 5f8ee481704756..8a95f915fa394e 100644 --- a/ngraph/core/src/op/parameter.cpp +++ b/ngraph/core/src/op/parameter.cpp @@ -68,7 +68,7 @@ bool ov::AttributeAdapter::visit_attributes(AttributeVisitor& v } visitor.on_attribute(index.str(), id); if (!m_ref[i]) { - m_ref[i] = ov::as_type_ptr(visitor.get_registered_node(id)); + m_ref[i] = ov::as_type_ptr(visitor.get_registered_node(id)); } } return true; diff --git a/ngraph/core/src/op/result.cpp b/ngraph/core/src/op/result.cpp index 8111965cbc946d..237b65c79772ce 100644 --- a/ngraph/core/src/op/result.cpp +++ b/ngraph/core/src/op/result.cpp @@ -82,7 +82,7 @@ bool ov::AttributeAdapter::visit_attributes(AttributeVisitor& visi } visitor.on_attribute(index.str(), id); if (!m_ref[i]) { - m_ref[i] = ov::as_type_ptr(visitor.get_registered_node(id)); + m_ref[i] = ov::as_type_ptr(visitor.get_registered_node(id)); } } return true; diff --git a/ngraph/core/src/op/reverse.cpp b/ngraph/core/src/op/reverse.cpp index abb3f1e4bda096..9c7d72afe2c87b 100644 --- a/ngraph/core/src/op/reverse.cpp +++ b/ngraph/core/src/op/reverse.cpp @@ -203,12 +203,12 @@ std::ostream& ngraph::operator<<(std::ostream& s, const op::v1::Reverse::Mode& t namespace ov { template <> -EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +EnumNames& EnumNames::get() { + static auto enum_names = EnumNames( "op::v1::Reverse::Mode", - {{"index", op::v1::Reverse::Mode::INDEX}, {"mask", op::v1::Reverse::Mode::MASK}}); + {{"index", ngraph::op::v1::Reverse::Mode::INDEX}, {"mask", ngraph::op::v1::Reverse::Mode::MASK}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov diff --git a/ngraph/core/src/op/roi_align.cpp b/ngraph/core/src/op/roi_align.cpp index 34376a43997d2b..580b7b8ddd3917 100644 --- a/ngraph/core/src/op/roi_align.cpp +++ b/ngraph/core/src/op/roi_align.cpp @@ -162,13 +162,13 @@ shared_ptr op::v3::ROIAlign::clone_with_new_inputs(const OutputVector& new } namespace ov { -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; template <> -NGRAPH_API EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +NGRAPH_API EnumNames& EnumNames::get() { + static auto enum_names = EnumNames( "op::v3::ROIAlign::PoolingMode", - {{"avg", op::v3::ROIAlign::PoolingMode::AVG}, {"max", op::v3::ROIAlign::PoolingMode::MAX}}); + {{"avg", ngraph::op::v3::ROIAlign::PoolingMode::AVG}, {"max", ngraph::op::v3::ROIAlign::PoolingMode::MAX}}); return enum_names; } diff --git a/ngraph/core/src/op/round.cpp b/ngraph/core/src/op/round.cpp index 3323ec6596ac30..aa33f7ccc18ad9 100644 --- a/ngraph/core/src/op/round.cpp +++ b/ngraph/core/src/op/round.cpp @@ -119,13 +119,13 @@ std::ostream& ngraph::operator<<(std::ostream& s, const op::v5::Round::RoundMode namespace ov { template <> -EnumNames& EnumNames::get() { - static auto enum_names = - EnumNames("op::v5::Round::RoundMode", - {{"half_to_even", op::v5::Round::RoundMode::HALF_TO_EVEN}, - {"half_away_from_zero", op::v5::Round::RoundMode::HALF_AWAY_FROM_ZERO}}); +EnumNames& EnumNames::get() { + static auto enum_names = EnumNames( + "op::v5::Round::RoundMode", + {{"half_to_even", ngraph::op::v5::Round::RoundMode::HALF_TO_EVEN}, + {"half_away_from_zero", ngraph::op::v5::Round::RoundMode::HALF_AWAY_FROM_ZERO}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov diff --git a/ngraph/core/src/op/space_to_depth.cpp b/ngraph/core/src/op/space_to_depth.cpp index 102beee02ed99e..c9bd7a92b9e665 100644 --- a/ngraph/core/src/op/space_to_depth.cpp +++ b/ngraph/core/src/op/space_to_depth.cpp @@ -122,13 +122,14 @@ std::ostream& ngraph::operator<<(std::ostream& s, const op::v0::SpaceToDepth::Sp namespace ov { template <> -NGRAPH_API EnumNames& EnumNames::get() { - static auto enum_names = EnumNames( +NGRAPH_API EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::v0::SpaceToDepth::SpaceToDepthMode", - {{"blocks_first", op::v0::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST}, - {"depth_first", op::v0::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST}}); + {{"blocks_first", ngraph::op::v0::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST}, + {"depth_first", ngraph::op::v0::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST}}); return enum_names; } -constexpr DiscreteTypeInfo AttributeAdapter::type_info; +constexpr DiscreteTypeInfo AttributeAdapter::type_info; } // namespace ov diff --git a/ngraph/core/src/op/util/activation_functions.cpp b/ngraph/core/src/op/util/activation_functions.cpp index 64ef443178e54b..5c01f0039e1722 100644 --- a/ngraph/core/src/op/util/activation_functions.cpp +++ b/ngraph/core/src/op/util/activation_functions.cpp @@ -52,7 +52,7 @@ shared_ptr op::util::ActivationFunction::operator()(const shared_ptr return m_function(arg, m_alpha, m_beta); } -op::util::ActivationFunction op::util::get_activation_func_by_name(const string& func_name) { +op::util::ActivationFunction ov::op::util::get_activation_func_by_name(const string& func_name) { using ActivationFunctionMap = unordered_map; static ActivationFunctionMap func_map{ diff --git a/ngraph/core/src/op/util/arithmetic_reduction.cpp b/ngraph/core/src/op/util/arithmetic_reduction.cpp index 40b151039906da..5e6942b4432db5 100644 --- a/ngraph/core/src/op/util/arithmetic_reduction.cpp +++ b/ngraph/core/src/op/util/arithmetic_reduction.cpp @@ -13,13 +13,13 @@ using namespace ngraph; NGRAPH_RTTI_DEFINITION(op::util::ArithmeticReduction, "ArithmeticReduction", 0); -op::util::ArithmeticReduction::ArithmeticReduction() {} +op::util::ArithmeticReduction::ArithmeticReduction() = default; op::util::ArithmeticReduction::ArithmeticReduction(const Output& arg, const Output& reduction_axes) : ReductionBase(arg, reduction_axes) {} bool op::util::ArithmeticReduction::reduction_axes_constant() const { - return ov::is_type(input_value(1).get_node()); + return ov::is_type(input_value(1).get_node()); } const AxisSet op::util::ArithmeticReduction::get_reduction_axes() const { @@ -35,7 +35,8 @@ const AxisSet op::util::ArithmeticReduction::get_reduction_axes() const { void op::util::ArithmeticReduction::set_reduction_axes(const AxisSet& reduction_axes) { this->input(1).replace_source_output( - op::Constant::create(element::i64, Shape{reduction_axes.size()}, reduction_axes.to_vector())->output(0)); + ngraph::op::Constant::create(element::i64, Shape{reduction_axes.size()}, reduction_axes.to_vector()) + ->output(0)); } void op::util::ArithmeticReduction::validate_and_infer_types() { diff --git a/ngraph/core/src/op/util/attr_types.cpp b/ngraph/core/src/op/util/attr_types.cpp index 36814edc3217f1..c7bfd40ff819d0 100644 --- a/ngraph/core/src/op/util/attr_types.cpp +++ b/ngraph/core/src/op/util/attr_types.cpp @@ -140,44 +140,43 @@ NGRAPH_API EnumNames& EnumNames(input_value(1).get_node_shared_ptr())) { + if (auto concat = ov::as_type_ptr(input_value(1).get_node_shared_ptr())) { auto concat_inputs = concat->inputs(); if (!output_shape_defined && concat->get_output_partial_shape(0).is_static() && @@ -201,8 +201,8 @@ void op::util::BroadcastBase::validate_and_infer_types() { auto output_partial_shape = vector{}; for (const auto& concat_input : concat_inputs) { auto source_node_ptr = concat_input.get_source_output().get_node_shared_ptr(); - if (auto source_const_ptr = ov::as_type_ptr(source_node_ptr)) { - output_partial_shape.push_back(source_const_ptr->get_axis_vector_val()[0]); + if (auto source_const_ptr = ov::as_type_ptr(source_node_ptr)) { + output_partial_shape.emplace_back(source_const_ptr->get_axis_vector_val()[0]); } else { output_partial_shape.push_back(Dimension::dynamic()); } @@ -267,7 +267,7 @@ std::pair op::util::BroadcastBase::get_broadcast_axes_numpy_pdpd( return std::make_pair(axes_known, broadcast_axes); } -std::pair op::util::BroadcastBase::get_broadcast_axes_none(const AxisVector axes_mapping_val, +std::pair op::util::BroadcastBase::get_broadcast_axes_none(const AxisVector& axes_mapping_val, const size_t target_shape_size) { AxisSet broadcast_axes; bool axes_known = false; @@ -413,8 +413,8 @@ Shape get_target_shape_from_ht(const HostTensorPtr& input1) { bool op::util::BroadcastBase::evaluate_broadcast(const HostTensorPtr& arg0, const HostTensorPtr& out, - const std::pair pair_broadcast_axes, - const Shape output_shape) const { + const std::pair& pair_broadcast_axes, + const Shape& output_shape) const { if (!pair_broadcast_axes.first) { // broadcast_axes not known deterministically return false; @@ -428,7 +428,7 @@ bool op::util::BroadcastBase::evaluate_broadcast(const HostTensorPtr& arg0, Shape op::util::BroadcastBase::get_target_shape(const HostTensorPtr& input1) const { Shape target_shape; - const auto shape_constant = ov::as_type_ptr(input_value(1).get_node_shared_ptr()); + const auto shape_constant = ov::as_type_ptr(input_value(1).get_node_shared_ptr()); if (shape_constant) { target_shape = shape_constant->get_shape_val(); } else { @@ -450,7 +450,8 @@ bool op::util::BroadcastBase::evaluate(const HostTensorVector& outputs, const Ho if (m_mode.m_type == BroadcastType::NONE) { AxisVector axes_mapping_val; - const auto axes_mapping_constant = ov::as_type_ptr(input_value(2).get_node_shared_ptr()); + const auto axes_mapping_constant = + ov::as_type_ptr(input_value(2).get_node_shared_ptr()); if (axes_mapping_constant) { axes_mapping_val = axes_mapping_constant->get_axis_vector_val(); } else { diff --git a/ngraph/core/src/op/util/elementwise_args.cpp b/ngraph/core/src/op/util/elementwise_args.cpp index fecd9fedf2261d..9a290f7fb8a96f 100644 --- a/ngraph/core/src/op/util/elementwise_args.cpp +++ b/ngraph/core/src/op/util/elementwise_args.cpp @@ -6,9 +6,7 @@ #include "ngraph/op/util/binary_elementwise_arithmetic.hpp" -using namespace ngraph; - -std::tuple ngraph::op::util::validate_and_infer_elementwise_args( +std::tuple ov::op::util::validate_and_infer_elementwise_args( Node* node, const op::AutoBroadcastSpec& autob) { NGRAPH_CHECK(node != nullptr, "nGraph node is empty! Cannot validate eltwise arguments."); diff --git a/ngraph/core/src/op/util/fft_base.cpp b/ngraph/core/src/op/util/fft_base.cpp index e1cc47e8d01fe1..0e789fdda93a52 100644 --- a/ngraph/core/src/op/util/fft_base.cpp +++ b/ngraph/core/src/op/util/fft_base.cpp @@ -73,7 +73,7 @@ void op::util::FFTBase::validate() { axes_shape.to_shape()[0]); } - if (input_shape.rank().is_static() && ov::is_type(input_value(1).get_node())) { + if (input_shape.rank().is_static() && ov::is_type(input_value(1).get_node())) { const auto input_rank = input_shape.rank().get_length(); const auto& const_axes = get_constant_from_source(input_value(1)); auto axes = const_axes->cast_vector(); @@ -146,7 +146,7 @@ void op::util::FFTBase::validate_and_infer_types() { const auto input_rank = input_shape.rank().get_length(); - if (axes_shape.rank().is_dynamic() || !ov::is_type(input_value(1).get_node())) { + if (axes_shape.rank().is_dynamic() || !ov::is_type(input_value(1).get_node())) { for (int64_t i = 0; i < input_rank - 1; ++i) { output_shape[i] = Dimension::dynamic(); } @@ -179,7 +179,7 @@ void op::util::FFTBase::validate_and_infer_types() { } } - if (!ov::is_type(input_value(2).get_node())) { + if (!ov::is_type(input_value(2).get_node())) { for (int64_t axis : axes) { output_shape[axis] = Dimension::dynamic(); } diff --git a/ngraph/core/src/op/util/logical_reduction.cpp b/ngraph/core/src/op/util/logical_reduction.cpp index 1d116fcdb35f28..89f818c379a42d 100644 --- a/ngraph/core/src/op/util/logical_reduction.cpp +++ b/ngraph/core/src/op/util/logical_reduction.cpp @@ -9,16 +9,17 @@ #include "ngraph/validation_util.hpp" using namespace std; -using namespace ngraph; +using namespace ov; NGRAPH_RTTI_DEFINITION(op::util::LogicalReduction, "LogicalReduction", 1); -op::util::LogicalReduction::LogicalReduction() {} +op::util::LogicalReduction::LogicalReduction() = default; op::util::LogicalReduction::LogicalReduction(const Output& arg, const AxisSet& reduction_axes) : ReductionBase( arg, - op::Constant::create(element::i64, Shape{reduction_axes.size()}, reduction_axes.to_vector())->output(0)) { + ngraph::op::Constant::create(element::i64, ngraph::Shape{reduction_axes.size()}, reduction_axes.to_vector()) + ->output(0)) { add_provenance_group_member(input_value(1).get_node_shared_ptr()); } @@ -26,7 +27,7 @@ op::util::LogicalReduction::LogicalReduction(const Output& arg, const Outp : ReductionBase(arg, reduction_axes) {} bool op::util::LogicalReduction::reduction_axes_constant() const { - return has_and_set_equal_bounds(input_value(1)); + return ngraph::has_and_set_equal_bounds(input_value(1)); } const AxisSet op::util::LogicalReduction::get_reduction_axes() const { @@ -39,7 +40,8 @@ const AxisSet op::util::LogicalReduction::get_reduction_axes() const { void op::util::LogicalReduction::set_reduction_axes(const AxisSet& reduction_axes) { this->input(1).replace_source_output( - op::Constant::create(element::i64, Shape{reduction_axes.size()}, reduction_axes.to_vector())->output(0)); + ngraph::op::Constant::create(element::i64, ngraph::Shape{reduction_axes.size()}, reduction_axes.to_vector()) + ->output(0)); } void op::util::LogicalReduction::validate_and_infer_types() { diff --git a/ngraph/core/src/op/util/nms_base.cpp b/ngraph/core/src/op/util/nms_base.cpp index 22b848707ffad5..dd34ea1b0373e7 100644 --- a/ngraph/core/src/op/util/nms_base.cpp +++ b/ngraph/core/src/op/util/nms_base.cpp @@ -145,7 +145,7 @@ void op::util::NmsBase::validate_and_infer_types() { } } -std::ostream& ngraph::operator<<(std::ostream& s, const op::util::NmsBase::SortResultType& type) { +std::ostream& ov::operator<<(std::ostream& s, const op::util::NmsBase::SortResultType& type) { return s << as_string(type); } diff --git a/ngraph/core/src/op/util/op_types.cpp b/ngraph/core/src/op/util/op_types.cpp index ca5813bf117577..848c5c1af8120a 100644 --- a/ngraph/core/src/op/util/op_types.cpp +++ b/ngraph/core/src/op/util/op_types.cpp @@ -25,51 +25,51 @@ #include "ngraph/op/xor.hpp" #include "ngraph/type.hpp" -bool ngraph::op::is_unary_elementwise_arithmetic(const ngraph::Node* node) { - return dynamic_cast(node) != nullptr; +bool ov::op::util::is_unary_elementwise_arithmetic(const ov::Node* node) { + return dynamic_cast(node) != nullptr; } -bool ngraph::op::is_binary_elementwise_arithmetic(const ngraph::Node* node) { - return dynamic_cast(node) != nullptr; +bool ov::op::util::is_binary_elementwise_arithmetic(const ov::Node* node) { + return dynamic_cast(node) != nullptr; } -bool ngraph::op::is_binary_elementwise_comparison(const ngraph::Node* node) { - return dynamic_cast(node) != nullptr; +bool ov::op::util::is_binary_elementwise_comparison(const ov::Node* node) { + return dynamic_cast(node) != nullptr; } -bool ngraph::op::is_binary_elementwise_logical(const ngraph::Node* node) { - return dynamic_cast(node) != nullptr; +bool ov::op::util::is_binary_elementwise_logical(const ov::Node* node) { + return dynamic_cast(node) != nullptr; } -bool ngraph::op::supports_auto_broadcast(const ngraph::Node* node) { +bool ov::op::util::supports_auto_broadcast(const ov::Node* node) { return dynamic_cast(node) != nullptr || dynamic_cast(node) != nullptr || - dynamic_cast(node) != nullptr || - dynamic_cast(node) != nullptr || - dynamic_cast(node) != nullptr; + dynamic_cast(node) != nullptr || + dynamic_cast(node) != nullptr || + dynamic_cast(node) != nullptr; } -bool ngraph::op::is_op(const ngraph::Node* node) { - return dynamic_cast(node) != nullptr; +bool ov::op::util::is_op(const ov::Node* node) { + return dynamic_cast(node) != nullptr; } -bool ngraph::op::is_parameter(const ngraph::Node* node) { +bool ov::op::util::is_parameter(const ov::Node* node) { return dynamic_cast(node) != nullptr; } -bool ngraph::op::is_output(const ngraph::Node* node) { +bool ov::op::util::is_output(const ov::Node* node) { return dynamic_cast(node) != nullptr; } -bool ngraph::op::is_sink(const ngraph::Node* node) { +bool ov::op::util::is_sink(const ov::Node* node) { return dynamic_cast(node) != nullptr; } -bool ngraph::op::is_constant(const ngraph::Node* node) { +bool ov::op::util::is_constant(const ov::Node* node) { return dynamic_cast(node) != nullptr; } -bool ngraph::op::is_commutative(const ngraph::Node* node) { +bool ov::op::util::is_commutative(const ov::Node* node) { return dynamic_cast(node) != nullptr || dynamic_cast(node) != nullptr || dynamic_cast(node) != nullptr || @@ -82,38 +82,38 @@ bool ngraph::op::is_commutative(const ngraph::Node* node) { dynamic_cast(node) != nullptr; } -bool ngraph::op::is_unary_elementwise_arithmetic(const std::shared_ptr& node) { +bool ov::op::util::is_unary_elementwise_arithmetic(const std::shared_ptr& node) { return is_unary_elementwise_arithmetic(node.get()); } -bool ngraph::op::is_binary_elementwise_arithmetic(const std::shared_ptr& node) { +bool ov::op::util::is_binary_elementwise_arithmetic(const std::shared_ptr& node) { return is_binary_elementwise_arithmetic(node.get()); } -bool ngraph::op::is_binary_elementwise_comparison(const std::shared_ptr& node) { +bool ov::op::util::is_binary_elementwise_comparison(const std::shared_ptr& node) { return is_binary_elementwise_comparison(node.get()); } -bool ngraph::op::is_binary_elementwise_logical(const std::shared_ptr& node) { +bool ov::op::util::is_binary_elementwise_logical(const std::shared_ptr& node) { return is_binary_elementwise_logical(node.get()); } -bool ngraph::op::supports_auto_broadcast(const std::shared_ptr& node) { +bool ov::op::util::supports_auto_broadcast(const std::shared_ptr& node) { return supports_auto_broadcast(node.get()); } -bool ngraph::op::is_op(const std::shared_ptr& node) { +bool ov::op::util::is_op(const std::shared_ptr& node) { return is_op(node.get()); } -bool ngraph::op::is_parameter(const std::shared_ptr& node) { +bool ov::op::util::is_parameter(const std::shared_ptr& node) { return is_parameter(node.get()); } -bool ngraph::op::is_output(const std::shared_ptr& node) { +bool ov::op::util::is_output(const std::shared_ptr& node) { return is_output(node.get()); } -bool ngraph::op::is_sink(const std::shared_ptr& node) { +bool ov::op::util::is_sink(const std::shared_ptr& node) { return is_sink(node.get()); } -bool ngraph::op::is_constant(const std::shared_ptr& node) { +bool ov::op::util::is_constant(const std::shared_ptr& node) { return is_constant(node.get()); } -bool ngraph::op::is_commutative(const std::shared_ptr& node) { +bool ov::op::util::is_commutative(const std::shared_ptr& node) { return is_commutative(node.get()); } diff --git a/ngraph/core/src/op/util/rnn_cell_base.cpp b/ngraph/core/src/op/util/rnn_cell_base.cpp index 17cab3c1357bbd..019752196f2279 100644 --- a/ngraph/core/src/op/util/rnn_cell_base.cpp +++ b/ngraph/core/src/op/util/rnn_cell_base.cpp @@ -22,10 +22,10 @@ using namespace ngraph; NGRAPH_RTTI_DEFINITION(op::util::RNNCellBase, "RNNCellBase", 0); -std::shared_ptr ngraph::op::util::convert_lstm_node_format(const Output& node, - LSTMWeightsFormat from_format, - LSTMWeightsFormat to_format, - int64_t axis) { +std::shared_ptr ov::op::util::convert_lstm_node_format(const Output& node, + LSTMWeightsFormat from_format, + LSTMWeightsFormat to_format, + int64_t axis) { static const std::map> gate_order_map{ {op::util::LSTMWeightsFormat::FICO, {0, 1, 2, 3}}, {op::util::LSTMWeightsFormat::ICOF, {1, 2, 3, 0}}, @@ -141,15 +141,15 @@ op::util::ActivationFunction op::util::RNNCellBase::get_activation_function(size } shared_ptr op::util::RNNCellBase::add(const Output& lhs, const Output& rhs) { - return {make_shared(lhs, rhs)}; + return {make_shared(lhs, rhs)}; } shared_ptr op::util::RNNCellBase::sub(const Output& lhs, const Output& rhs) { - return {make_shared(lhs, rhs)}; + return {make_shared(lhs, rhs)}; } shared_ptr op::util::RNNCellBase::mul(const Output& lhs, const Output& rhs) { - return {make_shared(lhs, rhs)}; + return {make_shared(lhs, rhs)}; } shared_ptr op::util::RNNCellBase::clip(const Output& data) const { @@ -157,5 +157,5 @@ shared_ptr op::util::RNNCellBase::clip(const Output& data) const { return data.get_node_shared_ptr(); } - return make_shared(data, -m_clip, m_clip); + return make_shared(data, -m_clip, m_clip); } diff --git a/ngraph/core/src/op/util/sub_graph_base.cpp b/ngraph/core/src/op/util/sub_graph_base.cpp index 82b9aeb972e0eb..cd1b0643c40c63 100644 --- a/ngraph/core/src/op/util/sub_graph_base.cpp +++ b/ngraph/core/src/op/util/sub_graph_base.cpp @@ -15,24 +15,24 @@ op::util::SubGraphOp::SubGraphOp() : MultiSubGraphOp(1) {} op::util::SubGraphOp::SubGraphOp(const OutputVector& args) : MultiSubGraphOp(args, 1) {} -void op::util::SubGraphOp::set_merged_input(const std::shared_ptr& body_parameter, +void op::util::SubGraphOp::set_merged_input(const std::shared_ptr& body_parameter, const Output& initial_value, const Output& successive_value) { auto body = get_function(); m_input_descriptions[0].push_back( - std::make_shared(input_for_value(initial_value).get_index(), - body->get_parameter_index(body_parameter), - body->get_result_index(successive_value))); + std::make_shared(input_for_value(initial_value).get_index(), + body->get_parameter_index(body_parameter), + body->get_result_index(successive_value))); validate_and_infer_types(); } -void op::util::SubGraphOp::set_invariant_input(const std::shared_ptr& body_parameter, +void op::util::SubGraphOp::set_invariant_input(const std::shared_ptr& body_parameter, const Output& value) { auto body = get_function(); - m_input_descriptions[0].push_back( - std::make_shared(input_for_value(value).get_index(), - body->get_parameter_index(body_parameter))); + m_input_descriptions[0].push_back(std::make_shared( + input_for_value(value).get_index(), + body->get_parameter_index(body_parameter))); validate_and_infer_types(); } @@ -66,7 +66,7 @@ Output op::util::SubGraphOp::get_concatenated_slices(const Output& b return Output(shared_from_this(), output_index); } -void op::util::SubGraphOp::set_sliced_input(const std::shared_ptr& parameter, +void op::util::SubGraphOp::set_sliced_input(const std::shared_ptr& parameter, const Output& value, int64_t start, int64_t stride, @@ -87,5 +87,5 @@ void op::util::SubGraphOp::set_sliced_input(const std::shared_ptr& pa Input op::util::SubGraphOp::input_for_value(const Output& value) { auto input_index = get_input_size(); set_argument(input_index, value); - return Input(this, input_index); + return {this, input_index}; }