Moved CC macros to public API (#5929)
* Moved CC macros for transformations to public API (to reuse their in plugin transformations) * Added CC to template plugin * Moved itt.h from nGraph to openvino/cc * Fixed build
This commit is contained in:
@@ -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}"
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "template_function_transformation.hpp"
|
||||
|
||||
#include <openvino/cc/ngraph/itt.hpp>
|
||||
|
||||
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<ngraph::Function> f) {
|
||||
RUN_ON_FUNCTION_SCOPE(MyFunctionTransformation);
|
||||
// Example transformation code
|
||||
NodeVector nodes;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <ngraph/pass/manager.hpp>
|
||||
#include <ngraph/pattern/op/wrap_type.hpp>
|
||||
#include <ngraph/rt_info.hpp>
|
||||
#include <openvino/cc/ngraph/itt.hpp>
|
||||
|
||||
#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<ngraph::opset3::Relu>(pattern::consumers_count(1));
|
||||
auto m_relu2 = ngraph::pattern::wrap_type<ngraph::opset3::Relu>({m_relu1});
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <openvino/cc/selective_build.h>
|
||||
#include <openvino/itt.hpp>
|
||||
#include <openvino/cc/ngraph/itt.hpp>
|
||||
|
||||
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
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <openvino/cc/selective_build.h>
|
||||
#include <openvino/itt.hpp>
|
||||
#include <openvino/cc/ngraph/itt.hpp>
|
||||
|
||||
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
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <openvino/cc/selective_build.h>
|
||||
#include <openvino/itt.hpp>
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user