diff --git a/inference-engine/tests/functional/inference_engine/conditional_compilation/selective_build.cpp b/inference-engine/tests/functional/inference_engine/conditional_compilation/selective_build.cpp index 386d74794811f0..84d698a3545cf7 100644 --- a/inference-engine/tests/functional/inference_engine/conditional_compilation/selective_build.cpp +++ b/inference-engine/tests/functional/inference_engine/conditional_compilation/selective_build.cpp @@ -76,6 +76,24 @@ TEST(ConditionalCompilationTests, SimpleScope) { #undef CCTests_Scope0 } +TEST(ConditionalCompilationTests, SimpleSectionDefine) { +#define CCTests_Section1 1 + + int n = 0; +#if OV_SCOPE_DEFINE(CCTests, Section1) + OV_SCOPE_TASK(CCTests, Section1); + n = 42; +#endif + EXPECT_EQ(n, 42); + +#if OV_SCOPE_DEFINE(CCTests, Section2) + n = 43; +#endif + EXPECT_EQ(n, 42); + +#undef CCTests_Section1 +} + TEST(ConditionalCompilationTests, SwitchCase) { // Cases 0 and 2 are enabled #define CCTests_TestTemplateClass 1 diff --git a/inference-engine/tests/functional/inference_engine/conditional_compilation/selective_build_analyzer.cpp b/inference-engine/tests/functional/inference_engine/conditional_compilation/selective_build_analyzer.cpp index 888978c8442341..d19eb886f93aec 100644 --- a/inference-engine/tests/functional/inference_engine/conditional_compilation/selective_build_analyzer.cpp +++ b/inference-engine/tests/functional/inference_engine/conditional_compilation/selective_build_analyzer.cpp @@ -60,6 +60,21 @@ struct TestNode : public TestNodeBase { } // namespace +TEST(ConditionalCompilationTests, SimpleSectionDefineAnalysys) { + int n = 0; + +#if OV_SCOPE_DEFINE(CCTests, Section1) + OV_SCOPE_TASK(CCTests, Section1); + n = 42; +#endif + EXPECT_EQ(n, 42); + +#if OV_SCOPE_DEFINE(CCTests, Section2) + n = 43; +#endif + EXPECT_EQ(n, 43); +} + TEST(ConditionalCompilationTests, SimpleScopeAnalysys) { int n = 0; diff --git a/ngraph/core/include/ngraph/op/topk.hpp b/ngraph/core/include/ngraph/op/topk.hpp index 731cf1708fb2a2..8a6b13da13de96 100644 --- a/ngraph/core/include/ngraph/op/topk.hpp +++ b/ngraph/core/include/ngraph/op/topk.hpp @@ -115,10 +115,6 @@ namespace ngraph const PartialShape input_partial_shape, const int64_t k) const; void set_axis(const Rank input_rank, const int64_t axis); - - private: - bool evaluate_topk(const HostTensorVector& outputs, - const HostTensorVector& inputs) const; }; } // namespace v1 diff --git a/ngraph/core/src/itt.hpp b/ngraph/core/src/itt.hpp index 5b09bf9048a08a..90505e6170012c 100644 --- a/ngraph/core/src/itt.hpp +++ b/ngraph/core/src/itt.hpp @@ -63,3 +63,7 @@ namespace ngraph rc = copy_tensor(__VA_ARGS__)); \ } \ break; + +#define NGRAPH_OP_SCOPE_DEFILE(region) OV_SCOPE_DEFINE(ngraph_op, region) + +#define NGRAPH_OP_SCOPE_TASK(region) OV_SCOPE_TASK(ngraph_op, region) diff --git a/ngraph/core/src/op/topk.cpp b/ngraph/core/src/op/topk.cpp index 97163edca93c94..cdb6dc71236f14 100644 --- a/ngraph/core/src/op/topk.cpp +++ b/ngraph/core/src/op/topk.cpp @@ -449,9 +449,10 @@ void op::v1::TopK::set_k(size_t k) op::Constant::create(element::i64, Shape{}, {k})->output(0)); } -bool op::v1::TopK::evaluate_topk(const HostTensorVector& outputs, - const HostTensorVector& inputs) const +bool op::v1::TopK::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +#if NGRAPH_OP_SCOPE_DEFILE(v1_TopK_evaluate) + NGRAPH_OP_SCOPE_TASK(v1_TopK_evaluate); Shape arg_shape = inputs[0]->get_shape(); // 1. get axis, mode ( max/min), sort_type size_t axis = ngraph::normalize_axis(this, m_axis, arg_shape.size()); @@ -490,11 +491,7 @@ bool op::v1::TopK::evaluate_topk(const HostTensorVector& outputs, compute_max, sort_type, get_index_element_type()); -} - -bool op::v1::TopK::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const -{ - NGRAPH_OP_SCOPE(v1_TopK_evaluate, return evaluate_topk(outputs, inputs)); +#endif return false; } diff --git a/openvino/conditional_compilation/include/openvino/cc/selective_build.h b/openvino/conditional_compilation/include/openvino/cc/selective_build.h index 0994a86419c789..ac07958142211e 100644 --- a/openvino/conditional_compilation/include/openvino/cc/selective_build.h +++ b/openvino/conditional_compilation/include/openvino/cc/selective_build.h @@ -191,6 +191,10 @@ bool match(char const *region, Ctx && ctx, T && val, Case && cs, Cases&&... case OV_ITT_SCOPED_TASK(OV_CC_CAT(SIMPLE_, Module), OV_CC_TOSTRING(region)); \ __VA_ARGS__ +#define OV_SCOPE_DEFINE(Module, region) 1 +#define OV_SCOPE_TASK(Module, region) \ + OV_ITT_SCOPED_TASK(OV_CC_CAT(SIMPLE_, Module), OV_CC_TOSTRING(region)) + #define OV_SWITCH(Module, fn, ctx, val, ...) \ openvino::cc::internal::match \ (OV_CC_TOSTRING(fn), ctx, val, __VA_ARGS__); @@ -233,9 +237,16 @@ bool match(char const *region, Ctx && ctx, T && val, Case && cs, Cases&&... case // Scope is enabled #define OV_CC_SCOPE_1(...) __VA_ARGS__ +#define OV_CC_DEFINE_0() 0 +#define OV_CC_DEFINE_1() 1 + #define OV_SCOPE(Module, region, ...) \ OV_CC_EXPAND(OV_CC_CAT(OV_CC_SCOPE_, OV_CC_SCOPE_IS_ENABLED(OV_CC_CAT3(Module, _, region)))(__VA_ARGS__)) +#define OV_SCOPE_DEFINE(Module, region) \ + OV_CC_CAT(OV_CC_DEFINE_, OV_CC_SCOPE_IS_ENABLED(OV_CC_CAT3(Module, _, region)))() +#define OV_SCOPE_TASK(Module, region) + // Switch is disabled #define OV_CC_SWITCH_0(Module, fn, ctx, val) @@ -255,6 +266,9 @@ bool match(char const *region, Ctx && ctx, T && val, Case && cs, Cases&&... case #define OV_SCOPE(Module, region, ...) __VA_ARGS__ +#define OV_SCOPE_DEFINE(Module, region) 1 +#define OV_SCOPE_TASK(Module, region) + #define OV_SWITCH(Module, fn, ctx, val, ...) \ openvino::cc::internal::match(ctx, val, __VA_ARGS__);