Skip to content

Commit f0e1e64

Browse files
Completely remove makePattern() (#32180)
Completely remove makePattern() and previous symbols-related functionality from the gen_pattern namespace. Also, additional cleaning of makePattern() leftovers Tickets: - [CVS-172489](https://jira.devtools.intel.com/browse/CVS-172489) Signed-off-by: Andrii Staikov <[email protected]>
1 parent 80e587b commit f0e1e64

File tree

11 files changed

+30
-1151
lines changed

11 files changed

+30
-1151
lines changed

src/common/transformations/include/transformations/utils/gen_pattern.hpp

Lines changed: 10 additions & 1032 deletions
Large diffs are not rendered by default.

src/common/transformations/src/transformations/common_optimizations/sdpa_fusion.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "openvino/op/concat.hpp"
1515
#include "openvino/op/constant.hpp"
1616
#include "openvino/op/matmul.hpp"
17+
#include "openvino/op/multiply.hpp"
1718
#include "openvino/op/reduce_max.hpp"
1819
#include "openvino/op/reshape.hpp"
1920
#include "openvino/op/scaled_dot_product_attention.hpp"
@@ -29,7 +30,6 @@
2930
#include "openvino/pass/pattern/op/wrap_type.hpp"
3031
#include "openvino/util/pp.hpp"
3132
#include "transformations/symbolic_transformations/symbolic_optimizations.hpp"
32-
#include "transformations/utils/gen_pattern.hpp"
3333
#include "transformations/utils/utils.hpp"
3434

3535
namespace {
@@ -379,19 +379,19 @@ SDPAFusionMatcher::SDPAFusionMatcher() {
379379

380380
ov::OutputVector vec = {q_node, k_node, v_node};
381381
// 3 is the min supported rank according to the SDPA spec
382-
int64_t supported_rank = std::max(mask_input.get_partial_shape().rank().get_length(), static_cast<int64_t>(3));
382+
size_t supported_rank = std::max(mask_input.get_partial_shape().rank().get_length(), static_cast<int64_t>(3));
383383
for (size_t i = 0; i < vec.size(); ++i) {
384384
auto pshape = vec[i].get_partial_shape();
385385
if (pshape.rank().is_dynamic()) {
386386
return false;
387387
}
388388
// align all inputs
389-
supported_rank = std::max(static_cast<int64_t>(pshape.size()), supported_rank);
389+
supported_rank = std::max(pshape.size(), supported_rank);
390390
}
391391

392392
for (size_t i = 0; i < vec.size(); ++i) {
393393
auto pshape = vec[i].get_partial_shape();
394-
int diff = supported_rank - static_cast<int>(pshape.size());
394+
int diff = static_cast<int>(supported_rank - pshape.size());
395395
if (diff > 0) {
396396
std::vector<size_t> axes(diff, 0);
397397
std::iota(axes.begin(), axes.end(), 0);
@@ -564,19 +564,19 @@ SDPAFusionMatcherSinks::SDPAFusionMatcherSinks() {
564564

565565
ov::OutputVector vec = {q_node, k_node, v_node};
566566
// 3 is the min supported rank according to the SDPA spec
567-
int64_t supported_rank = std::max(mask_input.get_partial_shape().rank().get_length(), static_cast<int64_t>(3));
567+
size_t supported_rank = std::max(mask_input.get_partial_shape().rank().get_length(), static_cast<int64_t>(3));
568568
for (size_t i = 0; i < vec.size(); ++i) {
569569
auto pshape = vec[i].get_partial_shape();
570570
if (pshape.rank().is_dynamic()) {
571571
return false;
572572
}
573573
// align all inputs
574-
supported_rank = std::max(static_cast<int64_t>(pshape.size()), supported_rank);
574+
supported_rank = std::max(pshape.size(), supported_rank);
575575
}
576576

577577
for (size_t i = 0; i < vec.size(); ++i) {
578578
auto pshape = vec[i].get_partial_shape();
579-
int diff = supported_rank - static_cast<int>(pshape.size());
579+
int diff = static_cast<int>(supported_rank - pshape.size());
580580
if (diff > 0) {
581581
std::vector<size_t> axes(diff, 0);
582582
std::iota(axes.begin(), axes.end(), 0);

src/common/transformations/src/transformations/fp16_compression/mark_floatpoint_range.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "openvino/op/unsqueeze.hpp"
1717
#include "openvino/pass/pattern/op/wrap_type.hpp"
1818
#include "transformations/rt_info/disable_fp16_compression.hpp"
19-
#include "transformations/utils/gen_pattern.hpp"
2019
#include "transformations/utils/utils.hpp"
2120

2221
void ov::pass::mark_range_path(const std::shared_ptr<Node>& node) {
@@ -35,7 +34,6 @@ void ov::pass::erase_range_path(const std::shared_ptr<Node>& node) {
3534
ov::pass::MarkFloatingPointRange::MarkFloatingPointRange() {
3635
MATCHER_SCOPE(MarkFloatingPointRange);
3736
using namespace ov::pass::pattern;
38-
using namespace ov::gen_pattern;
3937
// through these nodes
4038
const auto range_propagating_nodes = pattern::wrap_type<ov::op::v0::Convert,
4139
ov::op::v1::Greater,

src/common/transformations/tests/common_optimizations/fuse_rotary_positional_embeddings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
#include "openvino/op/reshape.hpp"
1717
#include "openvino/op/scatter_update.hpp"
1818
#include "openvino/op/shape_of.hpp"
19+
#include "openvino/op/slice.hpp"
1920
#include "openvino/op/split.hpp"
2021
#include "openvino/op/squeeze.hpp"
22+
#include "openvino/op/strided_slice.hpp"
2123
#include "openvino/op/transpose.hpp"
2224
#include "openvino/op/unsqueeze.hpp"
2325
#include "openvino/op/variadic_split.hpp"

src/common/transformations/tests/op_conversions/einsum_decomposition_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "openvino/op/reshape.hpp"
2222
#include "openvino/op/shape_of.hpp"
2323
#include "openvino/op/squeeze.hpp"
24+
#include "openvino/op/strided_slice.hpp"
2425
#include "openvino/op/subtract.hpp"
2526
#include "openvino/op/transpose.hpp"
2627
#include "openvino/op/unsqueeze.hpp"

src/common/transformations/tests/op_conversions/sdpa_to_paged_attention_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "openvino/op/select.hpp"
3838
#include "openvino/op/shape_of.hpp"
3939
#include "openvino/op/sin.hpp"
40+
#include "openvino/op/slice.hpp"
4041
#include "openvino/op/split.hpp"
4142
#include "openvino/op/sqrt.hpp"
4243
#include "openvino/op/squeeze.hpp"

src/core/dev_api/openvino/core/log_util.hpp

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -86,69 +86,6 @@ bool is_verbose_logging();
8686
// there's a set of macro for avoiding the additional clutter
8787
// of the matching code.
8888

89-
// transformations/utils/gen_pattern.hpp
90-
# define OPENVINO_LOG_GENPATTERN1(matcher, pattern_value, graph_value) \
91-
do { \
92-
OPENVINO_LOG_MATCHING(matcher, \
93-
ov::util::LevelString::get(), \
94-
OPENVINO_BLOCK_END, \
95-
OPENVINO_RED, \
96-
" OUTPUT INDICES DIDN'T MATCH. EXPECTED: ", \
97-
pattern_value.get_index(), \
98-
". OBSERVED: ", \
99-
graph_value.get_index()); \
100-
} while (0)
101-
102-
# define OPENVINO_LOG_GENPATTERN2(matcher, pattern_value, graph_value) \
103-
do { \
104-
OPENVINO_LOG_MATCHING(matcher, \
105-
ov::util::LevelString::get(), \
106-
OPENVINO_BLOCK_END, \
107-
OPENVINO_RED, \
108-
" NODES' TYPE DIDN'T MATCH. EXPECTED: ", \
109-
ov::util::node_version_type_str(*pattern_value.get_node_shared_ptr()), \
110-
". OBSERVED: ", \
111-
ov::util::node_version_type_str(*graph_value.get_node_shared_ptr())); \
112-
} while (0)
113-
114-
# define OPENVINO_LOG_GENPATTERN3(matcher) \
115-
do { \
116-
OPENVINO_LOG_MATCHING(matcher, \
117-
ov::util::LevelString::get(), \
118-
OPENVINO_BLOCK_END, \
119-
OPENVINO_RED, \
120-
" PREDICATE DIDN'T MATCH."); \
121-
} while (0)
122-
123-
# define OPENVINO_LOG_GENPATTERN4(matcher) \
124-
do { \
125-
OPENVINO_LOG_MATCHING(matcher, \
126-
ov::util::LevelString::get(), \
127-
OPENVINO_BLOCK_END, \
128-
OPENVINO_RED, \
129-
" ATTRIBUTES DIDN'T MATCH."); \
130-
} while (0)
131-
132-
# define OPENVINO_LOG_GENPATTERN5(matcher) \
133-
do { \
134-
OPENVINO_LOG_MATCHING(matcher, \
135-
ov::util::LevelString::get(), \
136-
OPENVINO_BLOCK_BODY_RIGHT, \
137-
" TYPE MATCHED. CHECKING PATTERN ARGUMENTS"); \
138-
} while (0)
139-
140-
# define OPENVINO_LOG_GENPATTERN6(matcher, status) \
141-
do { \
142-
OPENVINO_LOG_MATCHING(matcher, \
143-
ov::util::LevelString::get(), \
144-
OPENVINO_BLOCK_BODY, \
145-
'\n', \
146-
ov::util::LevelString::get(), \
147-
OPENVINO_BLOCK_END, \
148-
(status ? OPENVINO_GREEN : OPENVINO_RED), \
149-
(status ? " ALL ARGUMENTS MATCHED" : " ARGUMENTS DIDN'T MATCH")); \
150-
} while (0)
151-
15289
// core/src/node.cpp
15390
# define OPENVINO_LOG_NODE1(matcher, pattern_value, graph_value) \
15491
do { \
@@ -709,25 +646,6 @@ bool is_verbose_logging();
709646

710647
#else // ENABLE_OPENVINO_DEBUG
711648

712-
# define OPENVINO_LOG_GENPATTERN1(...) \
713-
do { \
714-
} while (0)
715-
# define OPENVINO_LOG_GENPATTERN2(...) \
716-
do { \
717-
} while (0)
718-
# define OPENVINO_LOG_GENPATTERN3(...) \
719-
do { \
720-
} while (0)
721-
# define OPENVINO_LOG_GENPATTERN4(...) \
722-
do { \
723-
} while (0)
724-
# define OPENVINO_LOG_GENPATTERN5(...) \
725-
do { \
726-
} while (0)
727-
# define OPENVINO_LOG_GENPATTERN6(...) \
728-
do { \
729-
} while (0)
730-
731649
# define OPENVINO_LOG_NODE1(...) \
732650
do { \
733651
} while (0)

src/core/src/log_util.cpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "openvino/pass/pattern/op/true.hpp"
99
#include "openvino/pass/pattern/op/wrap_type.hpp"
1010
#include "openvino/util/env_util.hpp"
11-
#include "transformations/utils/gen_pattern.hpp"
1211

1312
namespace ov {
1413
namespace util {
@@ -18,17 +17,6 @@ namespace util {
1817
static const bool verbose = ov::util::getenv_bool("OV_VERBOSE_LOGGING");
1918

2019
// These functions are used for printing nodes in a pretty way for matching logging
21-
static std::string wrapped_type_str(const ov::gen_pattern::detail::GenericPattern& gp, bool verbose) {
22-
auto wrapped_type_info = gp.get_wrapped_type();
23-
auto version = wrapped_type_info.version_id;
24-
std::string res = "<";
25-
if (verbose && version)
26-
res += version + std::string("::");
27-
28-
res += wrapped_type_info.name + std::string(">");
29-
return res;
30-
}
31-
3220
static std::string wrapped_type_str(const ov::pass::pattern::op::WrapType& wt, bool verbose) {
3321
bool first = true;
3422
std::string res = "<";
@@ -111,11 +99,8 @@ std::string node_version_type_str(const ov::Node& node) {
11199

112100
res += node.get_type_info().name;
113101

114-
if (auto wrap_type = ov::as_type<const ov::pass::pattern::op::WrapType>(&node)) {
102+
if (auto wrap_type = ov::as_type<const ov::pass::pattern::op::WrapType>(&node))
115103
res += wrapped_type_str(*wrap_type, verbose);
116-
} else if (auto generic_pattern = ov::as_type<const ov::gen_pattern::detail::GenericPattern>(&node)) {
117-
res += wrapped_type_str(*generic_pattern, verbose);
118-
}
119104

120105
return res;
121106
}
@@ -133,11 +118,8 @@ std::string node_with_arguments(const ov::Node& node) {
133118

134119
res += node.get_type_info().name;
135120

136-
if (auto wrap_type = ov::as_type<const ov::pass::pattern::op::WrapType>(&node)) {
121+
if (auto wrap_type = ov::as_type<const ov::pass::pattern::op::WrapType>(&node))
137122
res += wrapped_type_str(*wrap_type, verbose);
138-
} else if (auto generic_pattern = ov::as_type<const ov::gen_pattern::detail::GenericPattern>(&node)) {
139-
res += wrapped_type_str(*generic_pattern, verbose);
140-
}
141123

142124
if (verbose)
143125
res += " " + node.get_friendly_name();

src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/causal_mask_preprocess.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "openvino/op/scatter_nd_update.hpp"
3030
#include "openvino/op/scatter_update.hpp"
3131
#include "openvino/op/select.hpp"
32+
#include "openvino/op/strided_slice.hpp"
3233
#include "openvino/op/shape_of.hpp"
3334
#include "openvino/op/tile.hpp"
3435
#include "openvino/op/unsqueeze.hpp"

src/plugins/intel_npu/src/plugin/npuw/partitioning/patterns/pre_compute.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515
namespace opp = ov::pass::pattern;
1616

1717
namespace {
18-
template <typename T>
19-
std::shared_ptr<ov::Node> makeConst(const ov::element::Type& type,
20-
const ov::Shape& shape,
21-
const std::vector<T>& values) {
22-
return std::make_shared<ov::op::v0::Constant>(type, shape, values);
23-
}
2418
// TODO: copied from common tests
2519
static ov::OutputVector makeCosSinCache(const size_t max_position_embeddings,
2620
const std::shared_ptr<ov::Node> inverse_frequencies) {
@@ -48,8 +42,10 @@ static ov::OutputVector makeCosSinCache(const size_t max_position_embeddings,
4842
psin[k + rotary_ndims / 2] = psin[k];
4943
}
5044
}
51-
auto Cos = makeConst(ov::element::f16, ov::Shape({1, max_position_embeddings, rotary_ndims}), lut_cos);
52-
auto Sin = makeConst(ov::element::f16, ov::Shape({1, max_position_embeddings, rotary_ndims}), lut_sin);
45+
auto Cos =
46+
ov::op::v0::Constant::create(ov::element::f16, ov::Shape({1, max_position_embeddings, rotary_ndims}), lut_cos);
47+
auto Sin =
48+
ov::op::v0::Constant::create(ov::element::f16, ov::Shape({1, max_position_embeddings, rotary_ndims}), lut_sin);
5349

5450
return {Cos, Sin};
5551
}

0 commit comments

Comments
 (0)