Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Improve matcher logging (#31239)

Andrii Staikov4c94c2147b7f
diff --git a/src/common/transformations/src/transformations/low_precision/mark_dequantization_subgraph.cpp b/src/common/transformations/src/transformations/low_precision/mark_dequantization_subgraph.cpp
index b0a0afd005a..3a7a8354054 100644
--- a/src/common/transformations/src/transformations/low_precision/mark_dequantization_subgraph.cpp
+++ b/src/common/transformations/src/transformations/low_precision/mark_dequantization_subgraph.cpp
@@ -24,6 +24,17 @@ using namespace ov;
using namespace ov::op;
using namespace ov::pass::pattern;
+static std::string write_precisions(const ov::element::TypeVector& precisions) {
+ std::stringstream sstream;
+#ifdef OPENVINO_DEBUG
+ sstream << "check_precision( ";
+ for (auto& p : precisions)
+ sstream << p.to_string() << " ";
+ sstream << ")";
+#endif /* OPENVINO_DEBUG */
+ return sstream.str();
+}
+
namespace {
ov::pass::pattern::op::Predicate check_precision(const ov::element::TypeVector& precisions) {
@@ -31,7 +42,7 @@ ov::pass::pattern::op::Predicate check_precision(const ov::element::TypeVector&
[=](const Output<Node>& output) -> bool {
return std::find(precisions.begin(), precisions.end(), output.get_element_type()) != precisions.end();
},
- "check_precision");
+ write_precisions(precisions));
}
using RTInfoSetter = std::function<void(const std::shared_ptr<ov::Node>& node)>;
diff --git a/src/common/util/include/openvino/util/log.hpp b/src/common/util/include/openvino/util/log.hpp
index eb4e5237440..ffc4a5e18bc 100644
--- a/src/common/util/include/openvino/util/log.hpp
+++ b/src/common/util/include/openvino/util/log.hpp
@@ -113,6 +113,14 @@ static inline bool is_terminal_output() {
} \
} \
} while (0)
+
+// we use this macro to log from the attribute visitor
+// that doesn't contain a reference or pointer to matcher
+# define OPENVINO_LOG_MATCHING_NO_MATCHER(...) \
+ do { \
+ ov::util::_write_all_to_stream(OPENVINO_LOG_STREAM(_LOG_TYPE_DEBUG_EMPTY), __VA_ARGS__, OPENVINO_RESET); \
+ } while (0)
+
#else
# define OPENVINO_ERR(...) \
do { \
@@ -129,6 +137,9 @@ static inline bool is_terminal_output() {
# define OPENVINO_LOG_MATCHING(matcher_ptr, ...) \
do { \
} while (0)
+# define OPENVINO_LOG_MATCHING_NO_MATCHER(...) \
+ do { \
+ } while (0)
#endif
} // namespace ov::util
diff --git a/src/core/dev_api/openvino/core/log_util.hpp b/src/core/dev_api/openvino/core/log_util.hpp
index 7485e7de3a2..3ea8fdb9f24 100644
--- a/src/core/dev_api/openvino/core/log_util.hpp
+++ b/src/core/dev_api/openvino/core/log_util.hpp
@@ -10,6 +10,8 @@
#include "openvino/core/core_visibility.hpp"
#include "openvino/core/node.hpp"
+#include "openvino/pass/pattern/op/label.hpp"
+#include "openvino/pass/pattern/op/true.hpp"
namespace ov::util {
@@ -75,6 +77,11 @@ OPENVINO_API std::string node_version_type_str(const ov::Node& node);
OPENVINO_API std::string node_version_type_name_str(const ov::Node& node);
OPENVINO_API std::string node_with_arguments(const ov::Node& node);
+bool is_label_with_any_input(const ov::Node& node);
+bool true_any_input(const Output<Node>& output);
+std::string attribute_str(const ov::Any& attribute);
+bool is_verbose_logging();
+
// For each file, that has the matcher logging functionality present,
// there's a set of macro for avoiding the additional clutter
// of the matching code.
@@ -162,12 +169,16 @@ OPENVINO_API std::string node_with_arguments(const ov::Node& node);
graph_value.get_partial_shape()); \
} while (0)
-# define OPENVINO_LOG_NODE2(matcher) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_BODY_RIGHT, \
- " TYPE MATCHED. CHECKING PATTERN ARGUMENTS"); \
+# define OPENVINO_LOG_NODE2(matcher, num_arguments) \
+ do { \
+ bool _non_empty_args = num_arguments != 0; \
+ OPENVINO_LOG_MATCHING( \
+ matcher, \
+ ov::util::LevelString::get(), \
+ (_non_empty_args != 0 ? OPENVINO_BLOCK_BODY_RIGHT : OPENVINO_BLOCK_END), \
+ OPENVINO_GREEN, \
+ " NODES' TYPE AND PREDICATE MATCHED.", \
+ (_non_empty_args != 0 ? " CHECKING " + std::to_string(num_arguments) + " PATTERN ARGUMENTS: " : "")); \
} while (0)
# define OPENVINO_LOG_NODE3(matcher) \
@@ -182,16 +193,18 @@ OPENVINO_API std::string node_with_arguments(const ov::Node& node);
" ALL ARGUMENTS MATCHED"); \
} while (0)
-# define OPENVINO_LOG_NODE4(matcher) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_BODY, \
- '\n', \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_END, \
- OPENVINO_RED, \
- " ARGUMENTS DIDN'T MATCH"); \
+# define OPENVINO_LOG_NODE4(matcher, num_arguments) \
+ do { \
+ if (num_arguments != 0) { \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_BODY, \
+ '\n', \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_END, \
+ OPENVINO_RED, \
+ " ARGUMENTS DIDN'T MATCH"); \
+ } \
} while (0)
# define OPENVINO_LOG_NODE5(matcher, pattern_value, graph_value) \
@@ -257,27 +270,46 @@ OPENVINO_API std::string node_with_arguments(const ov::Node& node);
"] END: PATTERN DIDN'T MATCH\n"); \
} while (0)
+// We avoid printing both Label and True pattern nodes explicitly in non-verbose mode,
+// if we encounter any_input(). Instead, the Label is printed as any_input and
+// the True node is skipped at all, such that the user knows there's any_input() present
+// in the pattern. The predicates loggging, if any predicates persent, is also preserved.
+//
+// The logic of printing any_input() is following:
+// 1. Encountered Label
+// 2. Check if this is any_input() (i.e. Label with a single True input)
+// 3. If above is true, print Label logs as any_input().
+// 4. Skip printing True node's logs at all.
+
// src/pattern/matcher.cpp
-# define OPENVINO_LOG_MATCHER1(matcher, pattern_value, graph_value) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, \
- ov::util::LevelString::get(), \
- '\n', \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_BEG, \
- " MATCHING PATTERN NODE: ", \
- ov::util::node_with_arguments(*pattern_value.get_node_shared_ptr()), \
- '\n', \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_BODY_RIGHT, \
- " AGAINST GRAPH NODE: ", \
- ov::util::node_with_arguments(*graph_value.get_node_shared_ptr())); \
- } while (0)
-
-# define OPENVINO_LOG_MATCHER2(matcher, idx) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, ++ov::util::LevelString::get()); \
- OPENVINO_LOG_MATCHING(matcher, ov::util::LevelString::get()++, OPENVINO_BLOCK_BEG, " ARGUMENT ", idx); \
+# define OPENVINO_LOG_MATCHER1(matcher, pattern_value, graph_value) \
+ do { \
+ if (ov::util::is_verbose_logging() || !ov::util::true_any_input(pattern_value)) { /*expl. above*/ \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ '\n', \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_BEG, \
+ " MATCHING PATTERN NODE: ", \
+ ov::util::node_with_arguments(*pattern_value.get_node_shared_ptr()), \
+ '\n', \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_BODY_RIGHT, \
+ " AGAINST GRAPH NODE: ", \
+ ov::util::node_with_arguments(*graph_value.get_node_shared_ptr())); \
+ } \
+ } while (0)
+
+# define OPENVINO_LOG_MATCHER2(matcher, idx, pattern_value) \
+ do { \
+ OPENVINO_LOG_MATCHING(matcher, ++ov::util::LevelString::get()); \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get()++, \
+ OPENVINO_BLOCK_BEG, \
+ " ARGUMENT ", \
+ idx, \
+ ": ", \
+ ov::util::node_version_type_str(*pattern_value.get_node_shared_ptr())); \
} while (0)
# define OPENVINO_LOG_MATCHER3(matcher, idx) \
@@ -373,43 +405,73 @@ OPENVINO_API std::string node_with_arguments(const ov::Node& node);
} while (0)
// pattern/op/label.cpp
-# define OPENVINO_LOG_LABEL1(matcher, label_name) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_END, \
- OPENVINO_GREEN, \
- " LABEL MATCHED: ", \
- label_name); \
+# define OPENVINO_LOG_LABEL1(matcher, label_name, pattern_value) \
+ do { \
+ if (ov::util::is_verbose_logging() || \
+ !ov::util::is_label_with_any_input(*pattern_value.get_node())) { /*expl. above*/ \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_END, \
+ OPENVINO_GREEN, \
+ " LABEL MATCHED: ", \
+ label_name); \
+ } else { \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_END, \
+ OPENVINO_GREEN, \
+ " ANY INPUT MATCHED"); \
+ } \
} while (0);
-# define OPENVINO_LOG_LABEL2(matcher, label_name) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, \
- ov::util::LevelString::get()++, \
- OPENVINO_BLOCK_BODY_RIGHT, \
- " CHECKING INSIDE LABEL: ", \
- label_name); \
+# define OPENVINO_LOG_LABEL2(matcher, label_name, pattern_value) \
+ do { \
+ if (ov::util::is_verbose_logging() || \
+ !ov::util::is_label_with_any_input(*pattern_value.get_node())) { /*expl. above*/ \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get()++, \
+ OPENVINO_BLOCK_BODY_RIGHT, \
+ " CHECKING INSIDE LABEL: ", \
+ label_name); \
+ } \
} while (0);
-# define OPENVINO_LOG_LABEL3(matcher) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, --ov::util::LevelString::get(), OPENVINO_BLOCK_BODY); \
- OPENVINO_LOG_MATCHING(matcher, \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_END, \
- OPENVINO_GREEN, \
- " LABEL MATCHED"); \
+# define OPENVINO_LOG_LABEL3(matcher, pattern_value) \
+ do { \
+ if (ov::util::is_verbose_logging() || \
+ !ov::util::is_label_with_any_input(*pattern_value.get_node())) { /*expl. above*/ \
+ OPENVINO_LOG_MATCHING(matcher, --ov::util::LevelString::get(), OPENVINO_BLOCK_BODY); \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_END, \
+ OPENVINO_GREEN, \
+ " LABEL MATCHED"); \
+ } else { \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_END, \
+ OPENVINO_GREEN, \
+ " ANY INPUT MATCHED"); \
+ } \
} while (0);
-# define OPENVINO_LOG_LABEL4(matcher) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, ov::util::LevelString::get(), OPENVINO_BLOCK_BODY); \
- OPENVINO_LOG_MATCHING(matcher, \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_END, \
- OPENVINO_RED, \
- " LABEL DIDN'T MATCH"); \
+# define OPENVINO_LOG_LABEL4(matcher) \
+ do { \
+ if (ov::util::is_verbose_logging() || \
+ !ov::util::is_label_with_any_input(*pattern_value.get_node())) { /*expl. above*/ \
+ OPENVINO_LOG_MATCHING(matcher, ov::util::LevelString::get(), OPENVINO_BLOCK_BODY); \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_END, \
+ OPENVINO_RED, \
+ " LABEL DIDN'T MATCH"); \
+ } else { \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_END, \
+ OPENVINO_RED, \
+ " ANY INPUT DID'T MATCH BECAUSE OF PREDICATE"); \
+ } \
} while (0);
// pattern/op/optional.cpp
@@ -510,13 +572,15 @@ OPENVINO_API std::string node_with_arguments(const ov::Node& node);
} while (0);
// pattern/op/true.cpp
-# define OPENVINO_LOG_TRUE1(matcher) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_END, \
- OPENVINO_GREEN, \
- " TRUE ALWAYS MATCHES"); \
+# define OPENVINO_LOG_TRUE1(matcher, pattern_value) \
+ do { \
+ if (ov::util::is_verbose_logging() || !ov::util::true_any_input(pattern_value)) { /*expl. above*/ \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_END, \
+ OPENVINO_GREEN, \
+ " ANY INPUT MATCHED"); \
+ } \
} while (0);
// pattern/op/wrap_type.cpp
@@ -541,27 +605,106 @@ OPENVINO_API std::string node_with_arguments(const ov::Node& node);
" NODES' TYPE MATCHED, but PREDICATE FAILED"); \
} while (0);
-# define OPENVINO_LOG_WRAPTYPE3(matcher, num_arguments) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_BODY_RIGHT, \
- OPENVINO_GREEN, \
- " NODES' TYPE and PREDICATE MATCHED. CHECKING ", \
- num_arguments, \
- " PATTERN ARGUMENTS: "); \
+# define OPENVINO_LOG_WRAPTYPE3(matcher, num_arguments) \
+ do { \
+ bool _non_empty_args = num_arguments != 0; \
+ OPENVINO_LOG_MATCHING( \
+ matcher, \
+ ov::util::LevelString::get(), \
+ (_non_empty_args ? OPENVINO_BLOCK_BODY_RIGHT : OPENVINO_BLOCK_END), \
+ OPENVINO_GREEN, \
+ " NODES' TYPE AND PREDICATE MATCHED.", \
+ (_non_empty_args ? " CHECKING " + std::to_string(num_arguments) + " PATTERN ARGUMENTS: " : "")); \
} while (0);
-# define OPENVINO_LOG_WRAPTYPE4(matcher, status) \
- do { \
- OPENVINO_LOG_MATCHING(matcher, \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_BODY, \
- '\n', \
- ov::util::LevelString::get(), \
- OPENVINO_BLOCK_END, \
- (status ? OPENVINO_GREEN : OPENVINO_RED), \
- (status ? " ALL ARGUMENTS MATCHED" : " ARGUMENTS DIDN'T MATCH")); \
+# define OPENVINO_LOG_WRAPTYPE4(matcher, status, num_arguments) \
+ do { \
+ if (num_arguments != 0) { \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_BODY, \
+ '\n', \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_END, \
+ (status ? OPENVINO_GREEN : OPENVINO_RED), \
+ (status ? " ALL ARGUMENTS MATCHED" : " ARGUMENTS DIDN'T MATCH")); \
+ } \
+ } while (0);
+
+// pattern/op/predicate.cpp
+# define OPENVINO_LOG_PREDICATE1(matcher, m_name, status) \
+ do { \
+ if (ov::util::is_verbose_logging() || m_name != "always_true") { \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_BODY_RIGHT, \
+ " PREDICATE `", \
+ m_name, \
+ "`", \
+ (status ? OPENVINO_GREEN : OPENVINO_RED), \
+ (status ? " PASSED" : " FAILED")); \
+ } \
+ } while (0);
+
+// pattern/op/pattern.cpp
+# define OPENVINO_LOG_PATTERN1(attr_name, real_attr_type, expected_attr_type) \
+ do { \
+ if (ov::util::is_verbose_logging()) { \
+ OPENVINO_LOG_MATCHING_NO_MATCHER(ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_BODY_RIGHT, \
+ " ATTRIBUTE'S `", \
+ attr_name, \
+ "` DATA TYPE MISMATCH. OBSERVED: ", \
+ real_attr_type, \
+ ". EXPECTED: ", \
+ expected_attr_type); \
+ } \
+ } while (0);
+
+# define OPENVINO_LOG_PATTERN2(status, attr_name, real_attr_value, expected_attr_value) \
+ do { \
+ if (ov::util::is_verbose_logging()) { \
+ if (status) { \
+ OPENVINO_LOG_MATCHING_NO_MATCHER(ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_BODY_RIGHT, \
+ " ATTRIBUTE `", \
+ attr_name, \
+ OPENVINO_GREEN, \
+ "` MATCHED."); \
+ } else { \
+ OPENVINO_LOG_MATCHING_NO_MATCHER(ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_BODY_RIGHT, \
+ " ATTRIBUTES MISMATCH: VALUE OF `", \
+ attr_name, \
+ "` IS `", \
+ ov::util::attribute_str(real_attr_value), \
+ "`. EXPECTED `", \
+ ov::util::attribute_str(expected_attr_value), \
+ "`"); \
+ } \
+ } \
+ } while (0);
+
+# define OPENVINO_LOG_PATTERN3(attr_name) \
+ do { \
+ if (ov::util::is_verbose_logging()) { \
+ OPENVINO_LOG_MATCHING_NO_MATCHER(ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_BODY_RIGHT, \
+ " ATTRIBUTE `", \
+ attr_name, \
+ "` MATCHING WENT WRONG"); \
+ } \
+ } while (0);
+
+# define OPENVINO_LOG_PATTERN4(attr_name) \
+ do { \
+ if (ov::util::is_verbose_logging()) { \
+ OPENVINO_LOG_MATCHING_NO_MATCHER(ov::util::LevelString::get(), \
+ OPENVINO_BLOCK_BODY_RIGHT, \
+ " ATTRIBUTE `", \
+ attr_name, \
+ "` IS NOT BEING COMPARED"); \
+ } \
} while (0);
#else // ENABLE_OPENVINO_DEBUG
@@ -704,5 +847,22 @@ OPENVINO_API std::string node_with_arguments(const ov::Node& node);
do { \
} while (0)
+# define OPENVINO_LOG_PREDICATE1(...) \
+ do { \
+ } while (0)
+
+# define OPENVINO_LOG_PATTERN1(...) \
+ do { \
+ } while (0)
+# define OPENVINO_LOG_PATTERN2(...) \
+ do { \
+ } while (0)
+# define OPENVINO_LOG_PATTERN3(...) \
+ do { \
+ } while (0)
+# define OPENVINO_LOG_PATTERN4(...) \
+ do { \
+ } while (0)
+
#endif // ENABLE_OPENVINO_DEBUG
} // namespace ov::util
diff --git a/src/core/include/openvino/pass/pattern/op/predicate.hpp b/src/core/include/openvino/pass/pattern/op/predicate.hpp
index 9f795e5e18f..bc1a5cb37ee 100644
--- a/src/core/include/openvino/pass/pattern/op/predicate.hpp
+++ b/src/core/include/openvino/pass/pattern/op/predicate.hpp
@@ -99,7 +99,7 @@ public:
m_name = std::move(name);
}
- bool operator()(PatternSymbolMap& m, const Output<Node>& output) const;
+ bool operator()(Matcher* m, const Output<Node>& output) const;
bool operator()(const std::shared_ptr<Node>& node) const;
bool operator()(const Output<Node>& output) const;
diff --git a/src/core/src/log_util.cpp b/src/core/src/log_util.cpp
index f7bcbb366cb..b1fb986f445 100644
--- a/src/core/src/log_util.cpp
+++ b/src/core/src/log_util.cpp
@@ -4,6 +4,8 @@
#include "openvino/core/log_util.hpp"
+#include "openvino/pass/pattern/op/label.hpp"
+#include "openvino/pass/pattern/op/true.hpp"
#include "openvino/pass/pattern/op/wrap_type.hpp"
#include "openvino/util/env_util.hpp"
#include "transformations/utils/gen_pattern.hpp"
@@ -43,16 +45,49 @@ static std::string wrapped_type_str(const ov::pass::pattern::op::WrapType& wt, b
return res;
}
+bool is_label_with_any_input(const ov::Node& node) {
+ if (auto label = ov::as_type<const ov::pass::pattern::op::Label>(&node)) {
+ if (label->get_input_size() == 1) {
+ if (ov::as_type<const ov::pass::pattern::op::True>(label->input_value(0).get_node())) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool true_any_input(const Output<Node>& output) {
+ if (ov::as_type_ptr<ov::pass::pattern::op::True>(output.get_node_shared_ptr())) {
+ if (output.get_target_inputs().size() == 1) {
+ auto consumer_node = output.get_target_inputs().begin()->get_node();
+ if (auto label = ov::as_type_ptr<ov::pass::pattern::op::Label>(consumer_node->shared_from_this())) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool is_verbose_logging() {
+ return verbose;
+}
+
static std::string arguments_str(const OutputVector& input_values, bool verbose) {
std::string sep = "";
std::stringstream stream;
stream << "(";
for (const auto& arg : input_values) {
- if (verbose)
+ if (verbose) {
stream << sep << arg;
- else
- stream << sep << arg.get_node_shared_ptr()->get_type_name();
+ } else {
+ if (is_label_with_any_input(*arg.get_node())) {
+ stream << sep << "any_input";
+ } else {
+ stream << sep << arg.get_node_shared_ptr()->get_type_name();
+ }
+ }
sep = ", ";
}
stream << ")";
@@ -65,8 +100,12 @@ std::string node_version_type_name_str(const ov::Node& node) {
}
std::string node_version_type_str(const ov::Node& node) {
- auto version = node.get_type_info().version_id;
std::string res;
+ if (!verbose && is_label_with_any_input(node)) {
+ return "any_input";
+ }
+
+ auto version = node.get_type_info().version_id;
if (verbose && version)
res = version + std::string("::");
@@ -83,6 +122,11 @@ std::string node_version_type_str(const ov::Node& node) {
std::string node_with_arguments(const ov::Node& node) {
std::string res;
+
+ if (!verbose && is_label_with_any_input(node)) {
+ return "any_input()";
+ }
+
auto version = node.get_type_info().version_id;
if (verbose && version)
res += version + std::string("::");
@@ -103,6 +147,12 @@ std::string node_with_arguments(const ov::Node& node) {
return res;
}
+std::string attribute_str(const ov::Any& attribute) {
+ std::stringstream ss;
+ attribute.print(ss);
+ return ss.str();
+}
+
#endif
} // namespace util
-} // namespace ov
\ No newline at end of file
+} // namespace ov
diff --git a/src/core/src/node.cpp b/src/core/src/node.cpp
index 9aa6bbbba39..eb6ef40ed9f 100644
--- a/src/core/src/node.cpp
+++ b/src/core/src/node.cpp
@@ -550,14 +550,14 @@ bool ov::Node::match_node(ov::pass::pattern::Matcher* matcher, const Output<Node
// patterns
// with sub-graph of descent nodes types.
if (graph_value.get_node_shared_ptr()->get_type_info().is_castable(get_type_info())) {
- OPENVINO_LOG_NODE2(matcher);
+ OPENVINO_LOG_NODE2(matcher, get_input_size());
if (matcher->match_arguments(this, graph_value.get_node_shared_ptr())) {
auto& pattern_map = matcher->get_pattern_value_map();
pattern_map[shared_from_this()] = graph_value;
OPENVINO_LOG_NODE3(matcher);
return true;
}
- OPENVINO_LOG_NODE4(matcher);
+ OPENVINO_LOG_NODE4(matcher, get_input_size());
} else {
OPENVINO_LOG_NODE5(matcher, shared_from_this(), graph_value);
}
diff --git a/src/core/src/pattern/matcher.cpp b/src/core/src/pattern/matcher.cpp
index 9984d5ec691..a93332580b1 100644
--- a/src/core/src/pattern/matcher.cpp
+++ b/src/core/src/pattern/matcher.cpp
@@ -137,7 +137,7 @@ bool Matcher::match_value(const ov::Output<Node>& pattern_value, const ov::Outpu
bool Matcher::match_permutation(const OutputVector& pattern_args, const OutputVector& args) {
for (size_t i = 0; i < args.size(); i++) {
- OPENVINO_LOG_MATCHER2(this, i);
+ OPENVINO_LOG_MATCHER2(this, i, pattern_args.at(i));
if (!match_value(pattern_args.at(i), args.at(i))) {
OPENVINO_LOG_MATCHER3(this, i);
return false;
diff --git a/src/core/src/pattern/op/any.cpp b/src/core/src/pattern/op/any.cpp
index 0b611b013fd..e5d0f9044aa 100644
--- a/src/core/src/pattern/op/any.cpp
+++ b/src/core/src/pattern/op/any.cpp
@@ -10,6 +10,6 @@ bool ov::pass::pattern::op::Any::match_value(Matcher* matcher,
const Output<Node>& pattern_value,
const Output<Node>& graph_value) {
matcher->add_node(graph_value);
- return m_predicate(matcher->get_symbols(), graph_value) &&
+ return m_predicate(matcher, graph_value) &&
matcher->match_arguments(pattern_value.get_node(), graph_value.get_node_shared_ptr());
}
diff --git a/src/core/src/pattern/op/any_of.cpp b/src/core/src/pattern/op/any_of.cpp
index b3738b1fb70..a2ed56d880c 100644
--- a/src/core/src/pattern/op/any_of.cpp
+++ b/src/core/src/pattern/op/any_of.cpp
@@ -10,7 +10,7 @@ bool ov::pass::pattern::op::AnyOf::match_value(Matcher* matcher,
const Output<Node>& pattern_value,
const Output<Node>& graph_value) {
matcher->add_node(graph_value);
- return m_predicate(matcher->get_symbols(), graph_value) && ([&]() {
+ return m_predicate(matcher, graph_value) && ([&]() {
for (const auto& arg : graph_value.get_node_shared_ptr()->input_values()) {
auto saved = matcher->start_match();
if (matcher->match_value(input_value(0), arg)) {
diff --git a/src/core/src/pattern/op/label.cpp b/src/core/src/pattern/op/label.cpp
index 6bb1bc02710..a987fe8b0af 100644
--- a/src/core/src/pattern/op/label.cpp
+++ b/src/core/src/pattern/op/label.cpp
@@ -35,18 +35,18 @@ ov::Output<ov::Node> ov::pass::pattern::op::Label::wrap_values(const ov::NodeVec
bool ov::pass::pattern::op::Label::match_value(ov::pass::pattern::Matcher* matcher,
const ov::Output<ov::Node>& pattern_value,
const ov::Output<ov::Node>& graph_value) {
- if (m_predicate(matcher->get_symbols(), graph_value)) {
+ if (m_predicate(matcher, graph_value)) {
auto& pattern_map = matcher->get_pattern_value_map();
auto saved = matcher->start_match();
matcher->add_node(graph_value);
if (pattern_map.count(shared_from_this())) {
- OPENVINO_LOG_LABEL1(matcher, get_name());
+ OPENVINO_LOG_LABEL1(matcher, get_name(), pattern_value);
return saved.finish(pattern_map[shared_from_this()] == graph_value);
} else {
pattern_map[shared_from_this()] = graph_value;
- OPENVINO_LOG_LABEL2(matcher, get_name());
+ OPENVINO_LOG_LABEL2(matcher, get_name(), pattern_value);
auto res = saved.finish(matcher->match_value(input_value(0), graph_value));
- OPENVINO_LOG_LABEL3(matcher);
+ OPENVINO_LOG_LABEL3(matcher, pattern_value);
return res;
}
}
diff --git a/src/core/src/pattern/op/pattern.cpp b/src/core/src/pattern/op/pattern.cpp
index a1afd6f6b15..bb25c50b47e 100644
--- a/src/core/src/pattern/op/pattern.cpp
+++ b/src/core/src/pattern/op/pattern.cpp
@@ -8,6 +8,7 @@
#include <optional>
#include <regex>
+#include "openvino/core/log_util.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/util/common_util.hpp"
#include "openvino/util/log.hpp"
@@ -250,28 +251,18 @@ public:
}
if (node_attribute.type_info() != expected_attribute.type_info())
- OPENVINO_DEBUG(" Attribute `",
- name,
- "` -- data type does not match. Node attribute type: ",
- node_attribute.type_info().name(),
- ". Expected attribute type: ",
- expected_attribute.type_info().name());
+ OPENVINO_LOG_PATTERN1(name,
+ node_attribute.type_info().name(),
+ expected_attribute.type_info().name());
bool status = node_attribute == expected_attribute;
- if (!status)
- OPENVINO_DEBUG(" Attribute `", name, "` -- value does not match. ", [&]() {
- std::stringstream ss;
- node_attribute.print(ss);
- ss << " vs ";
- expected_attribute.print(ss);
- return ss.str();
- }());
+ OPENVINO_LOG_PATTERN2(status, name, node_attribute, expected_attribute);
m_matched_attributes[name] = status;
} catch (...) {
- OPENVINO_DEBUG(" Attribute `", name, "` matching went wrong");
+ OPENVINO_LOG_PATTERN3(name);
m_matched_attributes[name] = false;
}
} else {
- OPENVINO_DEBUG(" Node attribute `", name, "` is not being compared");
+ OPENVINO_LOG_PATTERN4(name);
}
}
diff --git a/src/core/src/pattern/op/predicate.cpp b/src/core/src/pattern/op/predicate.cpp
index 7455a39733f..a08a8b30a52 100644
--- a/src/core/src/pattern/op/predicate.cpp
+++ b/src/core/src/pattern/op/predicate.cpp
@@ -4,6 +4,8 @@
#include "openvino/pass/pattern/op/predicate.hpp"
+#include "openvino/core/log_util.hpp"
+#include "openvino/pass/pattern/matcher.hpp"
#include "openvino/util/log.hpp"
namespace ov::pass::pattern {
@@ -87,9 +89,9 @@ constexpr bool symbol_true_predicate(pass::pattern::PatternSymbolMap&, const Out
Predicate::Predicate() : m_name("always_true"), m_pred(symbol_true_predicate) {}
Predicate::Predicate(std::nullptr_t) : Predicate() {}
-bool Predicate::operator()(pass::pattern::PatternSymbolMap& m, const Output<Node>& output) const {
- bool result = m_pred(m, output);
- OPENVINO_DEBUG("Predicate `", m_name, "` has ", (result ? "passed" : "failed"), ". Applied to ", output);
+bool Predicate::operator()(Matcher* m, const Output<Node>& output) const {
+ bool result = m_pred(m->get_symbols(), output);
+ OPENVINO_LOG_PREDICATE1(m, m_name, result);
return result;
}
diff --git a/src/core/src/pattern/op/true.cpp b/src/core/src/pattern/op/true.cpp
index 014cb242fd2..0b51746d697 100644
--- a/src/core/src/pattern/op/true.cpp
+++ b/src/core/src/pattern/op/true.cpp
@@ -11,6 +11,6 @@
bool ov::pass::pattern::op::True::match_value(Matcher* matcher,
const Output<Node>& pattern_value,
const Output<Node>& graph_value) {
- OPENVINO_LOG_TRUE1(matcher);
+ OPENVINO_LOG_TRUE1(matcher, pattern_value);
return true;
}
diff --git a/src/core/src/pattern/op/wrap_type.cpp b/src/core/src/pattern/op/wrap_type.cpp
index d35af84f238..bd1444cce87 100644
--- a/src/core/src/pattern/op/wrap_type.cpp
+++ b/src/core/src/pattern/op/wrap_type.cpp
@@ -19,7 +19,7 @@ bool ov::pass::pattern::op::WrapType::match_value(Matcher* matcher,
return false;
}
- if (!m_predicate(matcher->get_symbols(), graph_value)) {
+ if (!m_predicate(matcher, graph_value)) {
OPENVINO_LOG_WRAPTYPE2(matcher);
return false;
}
@@ -31,7 +31,7 @@ bool ov::pass::pattern::op::WrapType::match_value(Matcher* matcher,
auto res =
(get_input_size() == 0 ? true
: matcher->match_arguments(pattern_value.get_node(), graph_value.get_node_shared_ptr()));
- OPENVINO_LOG_WRAPTYPE4(matcher, res);
+ OPENVINO_LOG_WRAPTYPE4(matcher, res, get_input_size());
return res;
}
diff --git a/src/core/tests/pattern.cpp b/src/core/tests/pattern.cpp
index bcf1e80639a..8ac207cd065 100644
--- a/src/core/tests/pattern.cpp
+++ b/src/core/tests/pattern.cpp
@@ -1459,7 +1459,7 @@ TEST(pattern, pattern_symbol_predicate_and_operators) {
auto reshape = std::make_shared<ov::op::v1::Reshape>(input,
ov::op::v0::Constant::create(element::i64, {4}, {0, 0, 0, 20}),
true);
- pattern::PatternSymbolMap m;
+ ov::pass::pattern::Matcher m;
for (size_t i = 0; i < 10; ++i) {
predicate_and = predicate_and && pattern::consumers_count(i);
predicate_or = predicate_and || pattern::consumers_count(i);
@@ -1468,7 +1468,7 @@ TEST(pattern, pattern_symbol_predicate_and_operators) {
else
predicate_mixed = predicate_mixed || pattern::consumers_count(i);
- ASSERT_NO_THROW(predicate_and(m, input));
+ ASSERT_NO_THROW(predicate_and(&m, input));
}
}