Skip to content

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

[DEBUG CAPS][TRANSFORMATIONS] Added Block support in matcher logging feature (#34992)

Vladislav Golubeved9c4db8d24d
diff --git a/src/core/dev_api/openvino/core/log_util.hpp b/src/core/dev_api/openvino/core/log_util.hpp
index 7fdf816c4d6..a2adf277282 100644
--- a/src/core/dev_api/openvino/core/log_util.hpp
+++ b/src/core/dev_api/openvino/core/log_util.hpp
@@ -520,6 +520,41 @@ bool is_verbose_logging();
} \
} while (0);
+// pattern/op/block.cpp
+# define OPENVINO_LOG_BLOCK1(matcher, block_name) \
+ do { \
+ OPENVINO_LOG_MATCHING(matcher, \
+ ov::util::LevelString::get()++, \
+ OPENVINO_BLOCK_BODY_RIGHT, \
+ " ENTERING BLOCK \"", \
+ block_name, \
+ "\":"); \
+ } while (0);
+
+# define OPENVINO_LOG_BLOCK2(matcher, block_name) \
+ 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, \
+ " BLOCK \"", \
+ block_name, \
+ "\" MATCHED"); \
+ } while (0);
+
+# define OPENVINO_LOG_BLOCK3(matcher, block_name) \
+ 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, \
+ " BLOCK \"", \
+ block_name, \
+ "\" DIDN'T MATCH"); \
+ } while (0);
+
// pattern/op/wrap_type.cpp
# define OPENVINO_LOG_WRAPTYPE1(matcher, pattern_value, graph_value) \
do { \
@@ -742,6 +777,16 @@ bool is_verbose_logging();
do { \
} while (0)
+# define OPENVINO_LOG_BLOCK1(...) \
+ do { \
+ } while (0)
+# define OPENVINO_LOG_BLOCK2(...) \
+ do { \
+ } while (0)
+# define OPENVINO_LOG_BLOCK3(...) \
+ do { \
+ } while (0)
+
# define OPENVINO_LOG_OPTIONAL1(...) \
do { \
} while (0)
diff --git a/src/core/include/openvino/pass/pattern/op/block.hpp b/src/core/include/openvino/pass/pattern/op/block.hpp
index e39c842fd0c..b6e9121a1ca 100644
--- a/src/core/include/openvino/pass/pattern/op/block.hpp
+++ b/src/core/include/openvino/pass/pattern/op/block.hpp
@@ -1,3 +1,7 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
#pragma once
#include <optional>
diff --git a/src/core/include/openvino/pass/pattern/op/block_util.hpp b/src/core/include/openvino/pass/pattern/op/block_util.hpp
index 72787e9e9f0..dbf82c74fc3 100644
--- a/src/core/include/openvino/pass/pattern/op/block_util.hpp
+++ b/src/core/include/openvino/pass/pattern/op/block_util.hpp
@@ -1,3 +1,7 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
#pragma once
namespace {
diff --git a/src/core/src/pattern/op/block.cpp b/src/core/src/pattern/op/block.cpp
index a8945f64d69..78de6b1d1e2 100644
--- a/src/core/src/pattern/op/block.cpp
+++ b/src/core/src/pattern/op/block.cpp
@@ -1,7 +1,12 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
#include "openvino/pass/pattern/op/block.hpp"
+#include "openvino/core/log_util.hpp"
#include "openvino/core/rt_info.hpp"
+#include "openvino/util/log.hpp"
using namespace ov;
using namespace ov::pass::pattern;
@@ -19,8 +24,12 @@ bool Block::match_value(Matcher* matcher, const Output<Node>& pattern_value, con
const auto& block_pattern_root = m_outputs.front();
// Using a local matcher to match only those patterns that are encapsulated into the current Block.
- auto local_matcher = std::make_shared<Matcher>(block_pattern_root.get_node_shared_ptr(), "BlockMatcher");
+ // Inherit the parent matcher's name so that OV_MATCHERS_TO_LOG filtering applies inside the Block too.
+ auto local_matcher = std::make_shared<Matcher>(block_pattern_root.get_node_shared_ptr(), matcher->get_name());
+
+ OPENVINO_LOG_BLOCK1(matcher, get_friendly_name());
if (!local_matcher->match_value(block_pattern_root, graph_value)) {
+ OPENVINO_LOG_BLOCK3(matcher, get_friendly_name());
return false;
}
@@ -54,5 +63,7 @@ bool Block::match_value(Matcher* matcher, const Output<Node>& pattern_value, con
matcher->add_node(matched_node_out);
}
}
+
+ OPENVINO_LOG_BLOCK2(matcher, get_friendly_name());
return true;
}