From e46f6ce573cda3433189b174584aea6f262b67cf Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Thu, 19 Aug 2021 13:28:45 +0300 Subject: [PATCH] Moved DEPRECATION macro and ITT domains to ov namespace (#7153) * Moved DEPRECATION macro and ITT domains to ov namespace * Fixed code style --- ngraph/core/include/ngraph/deprecated.hpp | 65 ++---------------- .../core/include/openvino/core/deprecated.hpp | 67 +++++++++++++++++++ ngraph/core/src/function.cpp | 14 ++-- ngraph/core/src/itt.hpp | 6 +- ngraph/core/src/node.cpp | 2 +- ngraph/core/src/op/convert_like.cpp | 2 +- ngraph/core/src/op/shape_of.cpp | 4 +- ngraph/core/src/pass/graph_rewrite.cpp | 4 +- ngraph/core/src/pass/manager.cpp | 4 +- ngraph/core/src/specialize_function.cpp | 2 +- 10 files changed, 91 insertions(+), 79 deletions(-) create mode 100644 ngraph/core/include/openvino/core/deprecated.hpp diff --git a/ngraph/core/include/ngraph/deprecated.hpp b/ngraph/core/include/ngraph/deprecated.hpp index 96345557edc..89c95eb7b81 100644 --- a/ngraph/core/include/ngraph/deprecated.hpp +++ b/ngraph/core/include/ngraph/deprecated.hpp @@ -4,64 +4,9 @@ #pragma once -// -// The NGRAPH_DEPRECATED macro can be used to deprecate a function declaration. For example: -// -// NGRAPH_DEPRECATED("replace with groxify"); -// void frobnicate() -// -// The macro will expand to a deprecation attribute supported by the compiler, -// so any use of `frobnicate` will produce a compiler warning. -// +#include "openvino/core/deprecated.hpp" -#if defined(_WIN32) -# define NGRAPH_DEPRECATED(msg) __declspec(deprecated(msg)) -# if __cplusplus >= 201402L -# define NGRAPH_ENUM_DEPRECATED(msg) [[deprecated(msg)]] -# else -# define NGRAPH_ENUM_DEPRECATED(msg) -# endif -#elif defined(__INTEL_COMPILER) -# define NGRAPH_DEPRECATED(msg) __attribute__((deprecated(msg))) -# define NGRAPH_ENUM_DEPRECATED(msg) NGRAPH_DEPRECATED(msg) -#elif defined(__GNUC__) -# define NGRAPH_DEPRECATED(msg) __attribute__((deprecated((msg)))) -# if __GNUC__ < 6 && !defined(__clang__) -# define NGRAPH_ENUM_DEPRECATED(msg) -# else -# define NGRAPH_ENUM_DEPRECATED(msg) NGRAPH_DEPRECATED(msg) -# endif -#else -# define NGRAPH_DEPRECATED(msg) -# define NGRAPH_ENUM_DEPRECATED(msg) -#endif - -// Suppress warning "-Wdeprecated-declarations" / C4996 -#if defined(_MSC_VER) -# define NGRAPH_DO_PRAGMA(x) __pragma(x) -#elif defined(__GNUC__) -# define NGRAPH_DO_PRAGMA(x) _Pragma(# x) -#else -# define NGRAPH_DO_PRAGMA(x) -#endif - -#if defined(_MSC_VER) && !defined(__clang__) -# define NGRAPH_SUPPRESS_DEPRECATED_START \ - NGRAPH_DO_PRAGMA(warning(push)) \ - NGRAPH_DO_PRAGMA(warning(disable : 4996)) -# define NGRAPH_SUPPRESS_DEPRECATED_END NGRAPH_DO_PRAGMA(warning(pop)) -#elif defined(__INTEL_COMPILER) -# define NGRAPH_SUPPRESS_DEPRECATED_START \ - NGRAPH_DO_PRAGMA(warning(push)) \ - NGRAPH_DO_PRAGMA(warning(disable : 1478)) -NGRAPH_DO_PRAGMA(warning(disable : 1786)) -# define NGRAPH_SUPPRESS_DEPRECATED_END NGRAPH_DO_PRAGMA(warning(pop)) -#elif defined(__clang__) || ((__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405)) -# define NGRAPH_SUPPRESS_DEPRECATED_START \ - NGRAPH_DO_PRAGMA(GCC diagnostic push) \ - NGRAPH_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") -# define NGRAPH_SUPPRESS_DEPRECATED_END NGRAPH_DO_PRAGMA(GCC diagnostic pop) -#else -# define NGRAPH_SUPPRESS_DEPRECATED_START -# define NGRAPH_SUPPRESS_DEPRECATED_END -#endif +#define NGRAPH_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) +#define NGRAPH_ENUM_DEPRECATED(msg) OPENVINO_ENUM_DEPRECATED(msg) +#define NGRAPH_SUPPRESS_DEPRECATED_START OPENVINO_SUPPRESS_DEPRECATED_START +#define NGRAPH_SUPPRESS_DEPRECATED_END OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/ngraph/core/include/openvino/core/deprecated.hpp b/ngraph/core/include/openvino/core/deprecated.hpp new file mode 100644 index 00000000000..2d885ba9439 --- /dev/null +++ b/ngraph/core/include/openvino/core/deprecated.hpp @@ -0,0 +1,67 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +// +// The OPENVINO_DEPRECATED macro can be used to deprecate a function declaration. For example: +// +// OPENVINO_DEPRECATED("replace with groxify"); +// void frobnicate() +// +// The macro will expand to a deprecation attribute supported by the compiler, +// so any use of `frobnicate` will produce a compiler warning. +// + +#if defined(_WIN32) +# define OPENVINO_DEPRECATED(msg) __declspec(deprecated(msg)) +# if __cplusplus >= 201402L +# define OPENVINO_ENUM_DEPRECATED(msg) [[deprecated(msg)]] +# else +# define OPENVINO_ENUM_DEPRECATED(msg) +# endif +#elif defined(__INTEL_COMPILER) +# define OPENVINO_DEPRECATED(msg) __attribute__((deprecated(msg))) +# define OPENVINO_ENUM_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) +#elif defined(__GNUC__) +# define OPENVINO_DEPRECATED(msg) __attribute__((deprecated((msg)))) +# if __GNUC__ < 6 && !defined(__clang__) +# define OPENVINO_ENUM_DEPRECATED(msg) +# else +# define OPENVINO_ENUM_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) +# endif +#else +# define OPENVINO_DEPRECATED(msg) +# define OPENVINO_ENUM_DEPRECATED(msg) +#endif + +// Suppress warning "-Wdeprecated-declarations" / C4996 +#if defined(_MSC_VER) +# define OPENVINO_DO_PRAGMA(x) __pragma(x) +#elif defined(__GNUC__) +# define OPENVINO_DO_PRAGMA(x) _Pragma(# x) +#else +# define OPENVINO_DO_PRAGMA(x) +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +# define OPENVINO_SUPPRESS_DEPRECATED_START \ + OPENVINO_DO_PRAGMA(warning(push)) \ + OPENVINO_DO_PRAGMA(warning(disable : 4996)) +# define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(warning(pop)) +#elif defined(__INTEL_COMPILER) +# define OPENVINO_SUPPRESS_DEPRECATED_START \ + OPENVINO_DO_PRAGMA(warning(push)) \ + OPENVINO_DO_PRAGMA(warning(disable : 1478)) +OPENVINO_DO_PRAGMA(warning(disable : 1786)) +# define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(warning(pop)) +#elif defined(__clang__) || ((__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405)) +# define OPENVINO_SUPPRESS_DEPRECATED_START \ + OPENVINO_DO_PRAGMA(GCC diagnostic push) \ + OPENVINO_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") +# define OPENVINO_SUPPRESS_DEPRECATED_END OPENVINO_DO_PRAGMA(GCC diagnostic pop) +#else +# define OPENVINO_SUPPRESS_DEPRECATED_START +# define OPENVINO_SUPPRESS_DEPRECATED_END +#endif diff --git a/ngraph/core/src/function.cpp b/ngraph/core/src/function.cpp index d52052c61ea..c3c3375b224 100644 --- a/ngraph/core/src/function.cpp +++ b/ngraph/core/src/function.cpp @@ -26,7 +26,7 @@ constexpr DiscreteTypeInfo Function::type_info; atomic Function::m_next_instance_id(0); void check_all_variables_registered(const std::vector>& ordered_ops, const VariableVector& variables) { - OV_ITT_SCOPED_TASK(ngraph::itt::domains::nGraphPass_LT, "Function::check_all_variables_registered"); + 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); @@ -40,7 +40,7 @@ void check_all_variables_registered(const std::vector>& ordered void check_all_parameters_registered(const std::vector>& ordered_ops, const ParameterVector& parameters) { - OV_ITT_SCOPED_TASK(ngraph::itt::domains::nGraph, "Function::check_all_parameters_registered"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::check_all_parameters_registered"); std::stringstream unregistered_parameters; for (auto& node : ordered_ops) { @@ -52,7 +52,7 @@ void check_all_parameters_registered(const std::vector>& ordere } VariableVector auto_detect_variables(const std::vector>& ordered_ops) { - OV_ITT_SCOPED_TASK(ngraph::itt::domains::nGraph, "Function::auto_detect_variables"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::auto_detect_variables"); unordered_set variables; for (const auto& op : ordered_ops) { if (const auto& variable_op = dynamic_pointer_cast(op)) { @@ -63,7 +63,7 @@ VariableVector auto_detect_variables(const std::vector>& o } ParameterVector auto_detect_parameters(const std::vector>& ordered_ops) { - OV_ITT_SCOPED_TASK(ngraph::itt::domains::nGraph, "Function::auto_detect_parameters"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::auto_detect_parameters"); ParameterVector parameter_vector; for (const auto& op : ordered_ops) { if (const auto& param = dynamic_pointer_cast(op)) { @@ -168,7 +168,7 @@ Function::Function(const OutputVector& results, const SinkVector& sinks, const s Function::Function(const OutputVector& results, const string& name) : Function(results, SinkVector{}, name) {} void Function::prerequirements(bool detect_variables, bool detect_parameters) { - OV_ITT_SCOPED_TASK(ngraph::itt::domains::nGraph, "Function::prerequirements"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::prerequirements"); const auto& ordered_ops = get_ordered_ops(); if (detect_parameters) @@ -183,7 +183,7 @@ void Function::prerequirements(bool detect_variables, bool detect_parameters) { } void Function::validate_nodes_and_infer_types() const { - OV_ITT_SCOPED_TASK(ngraph::itt::domains::nGraph, "Function::validate_nodes_and_infer_types"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::validate_nodes_and_infer_types"); struct Counter { int cnt_assign = 0; @@ -223,7 +223,7 @@ void Function::validate_nodes_and_infer_types() const { } std::vector> Function::get_ordered_ops() const { - OV_ITT_SCOPED_TASK(itt::domains::nGraph, "Function::get_ordered_ops"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Function::get_ordered_ops"); vector> nodes; for (auto& r : get_results()) { diff --git a/ngraph/core/src/itt.hpp b/ngraph/core/src/itt.hpp index 9d96091a247..1f602780957 100644 --- a/ngraph/core/src/itt.hpp +++ b/ngraph/core/src/itt.hpp @@ -14,7 +14,7 @@ #include -namespace ngraph { +namespace ov { namespace itt { namespace domains { OV_ITT_DOMAIN(nGraph); @@ -22,7 +22,7 @@ OV_ITT_DOMAIN(nGraphPass_LT); OV_ITT_DOMAIN(ngraph_op, "nGraph::Op"); } // namespace domains } // namespace itt -} // namespace ngraph +} // namespace ov OV_CC_DOMAINS(ngraph_op); OV_ITT_DOMAIN(SIMPLE_ngraph_pass); @@ -38,7 +38,7 @@ OV_ITT_DOMAIN(SIMPLE_ngraph_pass); throw ngraph::ngraph_error(std::string(OV_PP_TOSTRING(OV_PP_CAT3(ngraph_op, _, region))) + " is disabled!") # define NGRAPH_PASS_CALLBACK(matcher) #else -# define NGRAPH_OP_SCOPE(region) OV_ITT_SCOPED_TASK(ngraph::itt::domains::ngraph_op, OV_PP_TOSTRING(region)) +# define NGRAPH_OP_SCOPE(region) OV_ITT_SCOPED_TASK(ov::itt::domains::ngraph_op, OV_PP_TOSTRING(region)) # define NGRAPH_PASS_CALLBACK(matcher) #endif diff --git a/ngraph/core/src/node.cpp b/ngraph/core/src/node.cpp index 4ee13cb8464..cbc1c9611df 100644 --- a/ngraph/core/src/node.cpp +++ b/ngraph/core/src/node.cpp @@ -800,7 +800,7 @@ bool Node::evaluate_upper(const HostTensorVector& output_values) const { } bool Node::constant_fold(OutputVector& output_values, const OutputVector& input_values) { - OV_ITT_SCOPED_TASK(itt::domains::nGraph, "Node::constant_fold"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "Node::constant_fold"); if (m_rt_info.count("DISABLED_CONSTANT_FOLDING")) { return false; diff --git a/ngraph/core/src/op/convert_like.cpp b/ngraph/core/src/op/convert_like.cpp index 609ddb76993..b036e5e194a 100644 --- a/ngraph/core/src/op/convert_like.cpp +++ b/ngraph/core/src/op/convert_like.cpp @@ -36,7 +36,7 @@ shared_ptr op::v1::ConvertLike::clone_with_new_inputs(const OutputVector& } bool op::v1::ConvertLike::constant_fold(OutputVector& output_values, const OutputVector& input_values) { - OV_ITT_SCOPED_TASK(itt::domains::nGraph, "op::v1::ConvertLike::constant_fold"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "op::v1::ConvertLike::constant_fold"); if (auto data_const = std::dynamic_pointer_cast(input_values[0].get_node_shared_ptr())) { auto convert = make_shared(input_values[0], input_values[1].get_element_type()); convert->constant_fold(output_values, OutputVector{data_const}); diff --git a/ngraph/core/src/op/shape_of.cpp b/ngraph/core/src/op/shape_of.cpp index 3480ca5f0e3..69090af304a 100644 --- a/ngraph/core/src/op/shape_of.cpp +++ b/ngraph/core/src/op/shape_of.cpp @@ -173,7 +173,7 @@ bool op::v3::ShapeOf::evaluate_upper(const HostTensorVector& output_values) cons } bool op::v3::ShapeOf::constant_fold(OutputVector& output_values, const OutputVector& input_values) { - OV_ITT_SCOPED_TASK(itt::domains::nGraph, "op::v3::ShapeOf::constant_fold"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "op::v3::ShapeOf::constant_fold"); if (get_rt_info().count("DISABLED_CONSTANT_FOLDING")) return false; return shape_of::constant_fold_shape_of(this, output_values[0], input_values[0]); @@ -232,7 +232,7 @@ bool op::v0::ShapeOf::has_evaluate() const { } bool op::v0::ShapeOf::constant_fold(OutputVector& output_values, const OutputVector& input_values) { - OV_ITT_SCOPED_TASK(itt::domains::nGraph, "op::v0::ShapeOf::constant_fold"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "op::v0::ShapeOf::constant_fold"); if (get_rt_info().count("DISABLED_CONSTANT_FOLDING")) return false; return shape_of::constant_fold_shape_of(this, output_values[0], input_values[0]); diff --git a/ngraph/core/src/pass/graph_rewrite.cpp b/ngraph/core/src/pass/graph_rewrite.cpp index c56c8e1f937..07e8472ce47 100644 --- a/ngraph/core/src/pass/graph_rewrite.cpp +++ b/ngraph/core/src/pass/graph_rewrite.cpp @@ -89,7 +89,7 @@ bool pass::GraphRewrite::run_on_function(std::shared_ptr f) { } bool pass::GraphRewrite::apply_matcher_passes(shared_ptr f, deque> nodes_to_run) { - OV_ITT_SCOPED_TASK(itt::domains::nGraph, "pass::GraphRewrite::run_on_function"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "pass::GraphRewrite::run_on_function"); bool rewritten = false; const auto& pass_config = get_pass_config(); @@ -377,7 +377,7 @@ void ngraph::pass::MatcherPass::register_matcher(const std::shared_ptr node) { - OV_ITT_SCOPED_TASK(itt::domains::nGraph, pass::internal::perf_counters_graph_rewrite()[get_type_info()]); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, pass::internal::perf_counters_graph_rewrite()[get_type_info()]); m_new_nodes.clear(); if (m_handler) return m_handler(node); diff --git a/ngraph/core/src/pass/manager.cpp b/ngraph/core/src/pass/manager.cpp index 113e162ece5..5aeb9180670 100644 --- a/ngraph/core/src/pass/manager.cpp +++ b/ngraph/core/src/pass/manager.cpp @@ -46,7 +46,7 @@ pass::Manager::~Manager() {} pass::Manager::Manager(std::shared_ptr pass_config) : m_pass_config(std::move(pass_config)) {} void pass::Manager::run_passes(shared_ptr func) { - OV_ITT_SCOPED_TASK(itt::domains::nGraph, "pass::Manager::run_passes"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "pass::Manager::run_passes"); static bool profile_enabled = getenv_bool("NGRAPH_PROFILE_PASS_ENABLE"); @@ -62,7 +62,7 @@ void pass::Manager::run_passes(shared_ptr func) { } OV_ITT_SCOPE(FIRST_INFERENCE, - itt::domains::nGraphPass_LT, + ov::itt::domains::nGraphPass_LT, pass::internal::perf_counters()[pass->get_type_info()]); pass_timer.start(); diff --git a/ngraph/core/src/specialize_function.cpp b/ngraph/core/src/specialize_function.cpp index 232eaf6edd2..418b3434129 100644 --- a/ngraph/core/src/specialize_function.cpp +++ b/ngraph/core/src/specialize_function.cpp @@ -18,7 +18,7 @@ std::shared_ptr ngraph::specialize_function(std::shared_ptr const std::vector& parameter_values) { - OV_ITT_SCOPED_TASK(itt::domains::nGraph, "specialize_function"); + OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "specialize_function"); NGRAPH_CHECK(f->get_parameters().size() == parameter_shapes.size()); NGRAPH_CHECK(f->get_parameters().size() == parameter_element_types.size());