diff --git a/samples/cpp/build_samples.sh b/samples/cpp/build_samples.sh index 32695ee9d3fa13..fc171a27227858 100755 --- a/samples/cpp/build_samples.sh +++ b/samples/cpp/build_samples.sh @@ -18,11 +18,9 @@ usage() { } samples_type="$(basename "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")" -samples_build_dir=$HOME/openvino_${samples_type}_samples_build +samples_build_dir="$HOME/openvino_${samples_type}_samples_build" sample_install_dir="" -somebadthing - # parse command line options while [[ $# -gt 0 ]] do diff --git a/src/core/tests/pattern.cpp b/src/core/tests/pattern.cpp index 311bb0706b5143..097e3d07246b2c 100644 --- a/src/core/tests/pattern.cpp +++ b/src/core/tests/pattern.cpp @@ -26,8 +26,6 @@ #include "openvino/op/reduce_sum.hpp" #include "openvino/op/relu.hpp" #include "openvino/op/subtract.hpp" -#include "openvino/op/strided_slice.hpp" -#include "openvino/op/transpose.hpp" #include "openvino/op/util/op_types.hpp" #include "openvino/pass/graph_rewrite.hpp" #include "openvino/pass/manager.hpp" @@ -74,7 +72,7 @@ static std::shared_ptr construct_mean_graph() { return mean_label; } -class testGraphRewrite : public ov::pass::GraphRewrite { +class TestGraphRewrite : public ov::pass::GraphRewrite { public: void construct_multiply_by_one() { // pattern #1 : a * 1 = a @@ -193,7 +191,7 @@ class testGraphRewrite : public ov::pass::GraphRewrite { this->add_matcher(match_pass); } - testGraphRewrite() : GraphRewrite() { + TestGraphRewrite() : GraphRewrite() { construct_multiply_by_one(); construct_add_zero(); } @@ -209,7 +207,7 @@ static void run_passes(pass::Manager& pass_manager, TEST(pattern, graph_rewrite) { Shape shape{}; pass::Manager pass_manager; - pass_manager.register_pass(); + pass_manager.register_pass(); { auto a = make_shared(element::i32, shape); @@ -489,7 +487,7 @@ TEST(pattern, matcher) { } } -TEST(pattern, optional_single_in) { +TEST(pattern, matching_optional) { Shape shape{}; auto a = make_shared(element::i32, shape); auto b = make_shared(element::i32, shape); @@ -503,84 +501,94 @@ TEST(pattern, optional_single_in) { ASSERT_TRUE(n.match(ov::pass::pattern::optional(d), std::make_shared(c))); ASSERT_TRUE(n.match(ov::pass::pattern::optional(d), std::make_shared(c))); ASSERT_FALSE( - n.match(ov::pass::pattern::optional(d), std::make_shared(c))); - ASSERT_FALSE( - n.match(ov::pass::pattern::optional(d), std::make_shared(c))); + n.match(ov::pass::pattern::optional(d), std::make_shared(c))); const auto predicate = [](const Output& output) { return false; }; - ASSERT_FALSE(n.match(ov::pass::pattern::optional({d}, predicate), + ASSERT_FALSE(n.match(ov::pass::pattern::optional(d, predicate), std::make_shared(c))); } -TEST(pattern, optional_multi_in_cumulative_op) { +// Optional is not working properly yet CVS-136454 +TEST(pattern, DISABLED_optional_full_match) { Shape shape{}; - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, shape); - auto c = std::make_shared(a, b); + auto model_input = std::make_shared(element::i32, shape); + auto model_relu = std::make_shared(model_input); + auto model_relu1 = std::make_shared(model_relu->output(0)); - TestMatcher n; - ASSERT_TRUE(n.match(ov::pass::pattern::optional(ov::OutputVector{a,b}), c)); - ASSERT_TRUE(n.match(ov::pass::pattern::optional(ov::OutputVector{b, a}), c)); - ASSERT_FALSE(n.match(ov::pass::pattern::optional(ov::OutputVector{a}), c)); - ASSERT_FALSE(n.match(ov::pass::pattern::optional(ov::OutputVector{b}), c)); - ASSERT_TRUE(n.match(ov::pass::pattern::optional(ov::OutputVector{a,b}), a)); - ASSERT_TRUE(n.match(ov::pass::pattern::optional(ov::OutputVector{a,b}), b)); + auto pattern_relu = ov::pass::pattern::optional(); + auto pattern_relu1 = std::make_shared(pattern_relu->output(0)); + + TestMatcher tm; + + ASSERT_TRUE(tm.match(pattern_relu1, model_relu1)); } -TEST(pattern, optional_multi_in_order_important) { - Shape shape{2, 3, 4}; - auto a = make_shared(element::f32, shape); - auto b = make_shared(element::i32, ov::Shape{3}, std::vector{2, 0, 1}); - auto c = std::make_shared(a, b); +// Optional is not working properly yet CVS-136454 +TEST(pattern, DISABLED_optional_half_match) { + Shape shape{}; + auto model_input = std::make_shared(element::i32, shape); + auto model_relu = std::make_shared(model_input); + auto model_relu1 = std::make_shared(model_relu->output(0)); - TestMatcher n; - ASSERT_TRUE(n.match(ov::pass::pattern::optional(ov::OutputVector{a,b}), c)); - ASSERT_FALSE(n.match(ov::pass::pattern::optional(ov::OutputVector{b, a}), c)); - ASSERT_FALSE(n.match(ov::pass::pattern::optional(ov::OutputVector{a}), c)); - ASSERT_FALSE(n.match(ov::pass::pattern::optional(ov::OutputVector{b}), c)); - ASSERT_TRUE(n.match(ov::pass::pattern::optional(ov::OutputVector{a,b}), a)); - ASSERT_TRUE(n.match(ov::pass::pattern::optional(ov::OutputVector{a,b}), b)); + auto pattern_abs = ov::pass::pattern::optional(); + auto pattern_relu = std::make_shared(pattern_abs->output(0)); + + TestMatcher tm; + + ASSERT_TRUE(tm.match(pattern_relu, model_relu1)); } -TEST(pattern, optional_multi_in_pattern_matching) { +// Optional is not working properly yet CVS-136454 +TEST(pattern, DISABLED_optional_testing) { Shape shape{}; - auto model_input_0 = std::make_shared(element::i32, shape); - auto model_input_1 = std::make_shared(element::i32, shape); - auto model_add = std::make_shared(model_input_0, model_input_1); - auto model_add_reverse = std::make_shared(model_input_1, model_input_0); - auto model_relu_with_add = std::make_shared(model_add); - auto model_relu_with_add_reverse = std::make_shared(model_add_reverse); - auto model_relu_without_add_0 = std::make_shared(model_input_0); - auto model_relu_without_add_1 = std::make_shared(model_input_1); - - auto pattern_input_0 = ov::pass::pattern::any_input(); - auto pattern_input_1 = ov::pass::pattern::any_input(); - auto pattern_add = ov::pass::pattern::optional(ov::OutputVector{pattern_input_0, pattern_input_1}); - auto pattern_relu = std::make_shared(pattern_add->output(0)); + auto model_input1 = std::make_shared(element::i32, shape); + auto model_input2 = std::make_shared(element::i32, shape); + auto model_add = std::make_shared(model_input1->output(0), model_input2->output(0)); + auto model_relu = std::make_shared(model_add->output(0)); + auto model_abs = std::make_shared(model_add->output(0)); TestMatcher tm; - ASSERT_TRUE(tm.match(pattern_relu, model_relu_with_add)); - ASSERT_TRUE(tm.match(pattern_relu, model_relu_with_add_reverse)); - ASSERT_TRUE(tm.match(pattern_relu, model_relu_without_add_0)); - ASSERT_TRUE(tm.match(pattern_relu, model_relu_without_add_1)); + + ASSERT_TRUE(tm.match(ov::pass::pattern::optional(model_add), model_add)); + ASSERT_TRUE(tm.match(ov::pass::pattern::optional(model_add), model_add)); + ASSERT_TRUE(tm.match(ov::pass::pattern::optional(model_add), model_add)); + ASSERT_TRUE(tm.match(ov::pass::pattern::optional(model_add), model_add)); + + ASSERT_TRUE( + tm.match(ov::pass::pattern::optional(model_abs), std::make_shared(model_abs))); + ASSERT_FALSE( + tm.match(ov::pass::pattern::optional(model_abs), std::make_shared(model_abs))); + ASSERT_TRUE(tm.match(ov::pass::pattern::optional(model_abs), + std::make_shared(model_abs))); + + ASSERT_FALSE(tm.match(ov::pass::pattern::optional(model_add), model_abs)); + ASSERT_TRUE(tm.match(ov::pass::pattern::optional(model_add), model_abs)); + + ASSERT_TRUE(tm.match(ov::pass::pattern::optional(model_relu), + std::make_shared(std::make_shared(model_add)))); + + ASSERT_TRUE(tm.match(ov::pass::pattern::optional(model_relu), + std::make_shared(std::make_shared(model_add)))); } -TEST(pattern, optional_single_in_pattern_matching) { +// Optional is not working properly yet CVS-136454 +TEST(pattern, DISABLED_optional_one_node) { Shape shape{}; auto model_input = std::make_shared(element::i32, shape); auto model_relu = std::make_shared(model_input); - auto model_abs_with_relu = std::make_shared(model_relu); - auto model_abs_without_relu = std::make_shared(model_input); - - auto pattern_input = ov::pass::pattern::any_input(); - auto pattern_relu = ov::pass::pattern::optional(pattern_input); - auto pattern_abs = std::make_shared(pattern_relu); + auto model_abs = std::make_shared(model_input); TestMatcher tm; - ASSERT_TRUE(tm.match(pattern_abs, model_abs_with_relu)); - ASSERT_TRUE(tm.match(pattern_abs, model_abs_without_relu)); + + ASSERT_TRUE(tm.match(ov::pass::pattern::optional(), model_relu)); + ASSERT_FALSE(tm.match(ov::pass::pattern::optional(), model_relu)); + + ASSERT_FALSE(tm.match(ov::pass::pattern::optional(), model_abs)); + + ASSERT_TRUE(tm.match(ov::pass::pattern::optional(), model_input)); + ASSERT_FALSE(tm.match(ov::pass::pattern::optional(), model_input)); } TEST(pattern, mean) { diff --git a/src/frontends/tensorflow/src/translate_session.hpp b/src/frontends/tensorflow/src/translate_session.hpp index fbaadd0e094f9c..925948f9d56bd2 100644 --- a/src/frontends/tensorflow/src/translate_session.hpp +++ b/src/frontends/tensorflow/src/translate_session.hpp @@ -11,24 +11,24 @@ namespace ov { namespace frontend { namespace tensorflow { -struct cachedBodyModelSignature { +struct CachedBodyModelSignature { std::string body_name; std::vector input_shapes; std::vector input_types; - bool operator==(const cachedBodyModelSignature& other) const { + bool operator==(const CachedBodyModelSignature& other) const { return (body_name == other.body_name && input_shapes == other.input_shapes && input_types == other.input_types); } }; -struct cachedBodyModelSignatureHasher { - std::size_t operator()(const cachedBodyModelSignature& k) const { +struct CachedBodyModelSignatureHasher { + std::size_t operator()(const CachedBodyModelSignature& k) const { return std::hash()(k.body_name); } }; using CachedBodyModelsType = - std::unordered_map, cachedBodyModelSignatureHasher>; + std::unordered_map, CachedBodyModelSignatureHasher>; /// For one call of convert and decode method of Frontend, it creates one TranslateSession object to save data for the /// translation session: telemetry statistics, cache of convrted body graph models, operation translators (including @@ -63,7 +63,7 @@ class TranslateSession { // the same topology can be converted with different shapes and types so it will be cached separately std::shared_ptr m_cached_body_models; - void update_cached_body_models(const cachedBodyModelSignature& cached_body_model_signature, + void update_cached_body_models(const CachedBodyModelSignature& cached_body_model_signature, const std::shared_ptr& cached_body_model) { m_cached_body_models->insert(std::make_pair(cached_body_model_signature, cached_body_model)); }