diff --git a/docs/template_plugin/src/CMakeLists.txt b/docs/template_plugin/src/CMakeLists.txt index 9a24bc6c32a0f9..799a2c76c48ed3 100644 --- a/docs/template_plugin/src/CMakeLists.txt +++ b/docs/template_plugin/src/CMakeLists.txt @@ -15,6 +15,8 @@ ie_add_plugin(NAME ${TARGET_NAME} SKIP_INSTALL # ATTENTION: uncomment to install component VERSION_DEFINES_FOR template_plugin.cpp ADD_CLANG_FORMAT) +# Enable support of CC for the plugin +ie_mark_target_as_cc(${TARGET_NAME}) target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" diff --git a/docs/template_plugin/src/transformations/template_function_transformation.cpp b/docs/template_plugin/src/transformations/template_function_transformation.cpp index 410993d680b556..2470f1d23d6875 100644 --- a/docs/template_plugin/src/transformations/template_function_transformation.cpp +++ b/docs/template_plugin/src/transformations/template_function_transformation.cpp @@ -4,6 +4,8 @@ #include "template_function_transformation.hpp" +#include + using namespace ngraph; // ! [function_pass:template_transformation_cpp] @@ -11,6 +13,7 @@ using namespace ngraph; NGRAPH_RTTI_DEFINITION(ngraph::pass::MyFunctionTransformation, "MyFunctionTransformation", 0); bool pass::MyFunctionTransformation::run_on_function(std::shared_ptr f) { + RUN_ON_FUNCTION_SCOPE(MyFunctionTransformation); // Example transformation code NodeVector nodes; diff --git a/docs/template_plugin/src/transformations/template_pattern_transformation.cpp b/docs/template_plugin/src/transformations/template_pattern_transformation.cpp index 063f52ad736dc2..010db33d465c70 100644 --- a/docs/template_plugin/src/transformations/template_pattern_transformation.cpp +++ b/docs/template_plugin/src/transformations/template_pattern_transformation.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "transformations/template_function_transformation.hpp" @@ -18,6 +19,7 @@ using namespace ngraph; NGRAPH_RTTI_DEFINITION(ngraph::pass::DecomposeDivideMatcher, "DecomposeDivideMatcher", 0); ngraph::pass::DecomposeDivideMatcher::DecomposeDivideMatcher() { + MATCHER_SCOPE(DecomposeDivideMatcher); // Pattern example auto input0 = pattern::any_input(); auto input1 = pattern::any_input(); @@ -59,6 +61,7 @@ ngraph::pass::DecomposeDivideMatcher::DecomposeDivideMatcher() { NGRAPH_RTTI_DEFINITION(ngraph::pass::ReluReluFusionMatcher, "ReluReluFusionMatcher", 0); ngraph::pass::ReluReluFusionMatcher::ReluReluFusionMatcher() { + MATCHER_SCOPE(ReluReluFusionMatcher); auto m_relu1 = ngraph::pattern::wrap_type(pattern::consumers_count(1)); auto m_relu2 = ngraph::pattern::wrap_type({m_relu1}); diff --git a/inference-engine/src/snippets/src/itt.hpp b/inference-engine/src/snippets/src/itt.hpp index f7d06b2b6f081d..cc4589a9008b86 100644 --- a/inference-engine/src/snippets/src/itt.hpp +++ b/inference-engine/src/snippets/src/itt.hpp @@ -9,8 +9,7 @@ #pragma once -#include -#include +#include namespace ngraph { namespace pass { @@ -22,7 +21,6 @@ namespace domains { } // namespace pass } // namespace ngraph -OV_CC_DOMAINS(ngraph_pass); OV_CC_DOMAINS(internal_op); /* @@ -31,29 +29,15 @@ OV_CC_DOMAINS(internal_op); * INTERNAL_OP_SCOPE macro allows to disable parts of internal nGraph operations if they are not used */ #if defined(SELECTIVE_BUILD_ANALYZER) -#define RUN_ON_FUNCTION_SCOPE(region) OV_SCOPE(ngraph_pass, OV_PP_CAT(region, _run_on_function)) -#define MATCHER_SCOPE(region) \ - const std::string matcher_name(OV_PP_TOSTRING(region)) #define INTERNAL_OP_SCOPE(region) OV_SCOPE(internal_op, region) #elif defined(SELECTIVE_BUILD) -#define MATCHER_SCOPE_(scope, region) \ - if (OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT3(scope, _, region)) == 0) \ - throw ngraph::ngraph_error(std::string(OV_PP_TOSTRING(OV_PP_CAT3(scope, _, region))) + \ - " is disabled!") - -#define MATCHER_SCOPE(region) \ - const std::string matcher_name(OV_PP_TOSTRING(region)); \ - if (OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT3(ngraph_pass, _, region)) == 0) \ - return #define INTERNAL_OP_SCOPE(region) MATCHER_SCOPE_(internal_op, region) -#define RUN_ON_FUNCTION_SCOPE(region) MATCHER_SCOPE_(ngraph_pass, OV_PP_CAT(region, _run_on_function)) #else -#define MATCHER_SCOPE(region) \ - const std::string matcher_name(OV_PP_TOSTRING(region)) + #define INTERNAL_OP_SCOPE(region) -#define RUN_ON_FUNCTION_SCOPE(region) + #endif diff --git a/inference-engine/src/transformations/src/itt.hpp b/inference-engine/src/transformations/src/itt.hpp index f7d06b2b6f081d..a23f7713a74fdf 100644 --- a/inference-engine/src/transformations/src/itt.hpp +++ b/inference-engine/src/transformations/src/itt.hpp @@ -11,6 +11,7 @@ #include #include +#include namespace ngraph { namespace pass { @@ -22,7 +23,6 @@ namespace domains { } // namespace pass } // namespace ngraph -OV_CC_DOMAINS(ngraph_pass); OV_CC_DOMAINS(internal_op); /* @@ -31,29 +31,15 @@ OV_CC_DOMAINS(internal_op); * INTERNAL_OP_SCOPE macro allows to disable parts of internal nGraph operations if they are not used */ #if defined(SELECTIVE_BUILD_ANALYZER) -#define RUN_ON_FUNCTION_SCOPE(region) OV_SCOPE(ngraph_pass, OV_PP_CAT(region, _run_on_function)) -#define MATCHER_SCOPE(region) \ - const std::string matcher_name(OV_PP_TOSTRING(region)) #define INTERNAL_OP_SCOPE(region) OV_SCOPE(internal_op, region) #elif defined(SELECTIVE_BUILD) -#define MATCHER_SCOPE_(scope, region) \ - if (OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT3(scope, _, region)) == 0) \ - throw ngraph::ngraph_error(std::string(OV_PP_TOSTRING(OV_PP_CAT3(scope, _, region))) + \ - " is disabled!") - -#define MATCHER_SCOPE(region) \ - const std::string matcher_name(OV_PP_TOSTRING(region)); \ - if (OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT3(ngraph_pass, _, region)) == 0) \ - return #define INTERNAL_OP_SCOPE(region) MATCHER_SCOPE_(internal_op, region) -#define RUN_ON_FUNCTION_SCOPE(region) MATCHER_SCOPE_(ngraph_pass, OV_PP_CAT(region, _run_on_function)) #else -#define MATCHER_SCOPE(region) \ - const std::string matcher_name(OV_PP_TOSTRING(region)) + #define INTERNAL_OP_SCOPE(region) -#define RUN_ON_FUNCTION_SCOPE(region) + #endif diff --git a/openvino/conditional_compilation/CMakeLists.txt b/openvino/conditional_compilation/CMakeLists.txt index d2772cf36beff2..fbcacc4951a9a2 100644 --- a/openvino/conditional_compilation/CMakeLists.txt +++ b/openvino/conditional_compilation/CMakeLists.txt @@ -49,5 +49,5 @@ elseif(SELECTIVE_BUILD STREQUAL "ON") ov_force_include(${TARGET_NAME} INTERFACE ${GENERATED_HEADER}) endif() -file(GLOB_RECURSE hdrs "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h") +file(GLOB_RECURSE hdrs ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) add_cpplint_target(${TARGET_NAME}_cpplint FOR_SOURCES ${hdrs}) diff --git a/openvino/conditional_compilation/include/openvino/cc/ngraph/itt.hpp b/openvino/conditional_compilation/include/openvino/cc/ngraph/itt.hpp new file mode 100644 index 00000000000000..30aa8c66fa12a2 --- /dev/null +++ b/openvino/conditional_compilation/include/openvino/cc/ngraph/itt.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +OV_CC_DOMAINS(ngraph_pass); + +/* + * RUN_ON_FUNCTION_SCOPE macro allows to disable the run_on_function pass + * MATCHER_SCOPE macro allows to disable the MatcherPass if matcher isn't applied + */ +#if defined(SELECTIVE_BUILD_ANALYZER) + +#define RUN_ON_FUNCTION_SCOPE(region) OV_SCOPE(ngraph_pass, OV_PP_CAT(region, _run_on_function)) +#define MATCHER_SCOPE(region) const std::string matcher_name(OV_PP_TOSTRING(region)) + +#elif defined(SELECTIVE_BUILD) + +#define MATCHER_SCOPE_(scope, region) \ + if (OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT3(scope, _, region)) == 0) \ + throw ngraph::ngraph_error(std::string(OV_PP_TOSTRING(OV_PP_CAT3(scope, _, region))) + \ + " is disabled!") + +#define MATCHER_SCOPE(region) \ + const std::string matcher_name(OV_PP_TOSTRING(region)); \ + if (OV_CC_SCOPE_IS_ENABLED(OV_PP_CAT3(ngraph_pass, _, region)) == 0) \ + return +#define RUN_ON_FUNCTION_SCOPE(region) \ + MATCHER_SCOPE_(ngraph_pass, OV_PP_CAT(region, _run_on_function)) + +#else + +#define MATCHER_SCOPE(region) const std::string matcher_name(OV_PP_TOSTRING(region)) +#define RUN_ON_FUNCTION_SCOPE(region) +#endif