Skip to content

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

[Snippets] Preserve all results in data flow dumps (#39049)

Arseniy Obolenskiy2cb2041c4c3c
diff --git a/src/common/snippets/src/lowered/pass/serialize_data_flow.cpp b/src/common/snippets/src/lowered/pass/serialize_data_flow.cpp
index 9ed16a585aa..3d39881c498 100644
--- a/src/common/snippets/src/lowered/pass/serialize_data_flow.cpp
+++ b/src/common/snippets/src/lowered/pass/serialize_data_flow.cpp
@@ -48,7 +48,7 @@ bool SerializeDataFlow::run(const LinearIR& linear_ir) {
ops_map[expr] = parameter;
parameters.push_back(parameter);
} else if (ov::is_type<ov::op::v0::Result>(node)) {
- const auto result = std::make_shared<ov::op::v0::Result>(inputs[0]);
+ const auto result = ov::as_type_ptr<ov::op::v0::Result>(node->clone_with_new_inputs(inputs));
ops_map[expr] = result;
results.push_back(result);
} else {
diff --git a/src/common/snippets/tests/sources.cmake b/src/common/snippets/tests/sources.cmake
index 92dcc4f6063..341d3a3d92e 100644
--- a/src/common/snippets/tests/sources.cmake
+++ b/src/common/snippets/tests/sources.cmake
@@ -16,6 +16,7 @@ set(SNIPPETS_TESTS_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/lowered/pass/loop.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/lowered/pass/move_scalar_to_consumer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/lowered/pass/optimize_domain.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/lowered/pass/serialize_data_flow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/lowered/pass/set_buffer_reg_group.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/lowered/pass/split_loops.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/lowering_utils.cpp
diff --git a/src/common/snippets/tests/src/lowered/linear_ir.cpp b/src/common/snippets/tests/src/lowered/linear_ir.cpp
index 845627f1695..0b08e199fab 100644
--- a/src/common/snippets/tests/src/lowered/linear_ir.cpp
+++ b/src/common/snippets/tests/src/lowered/linear_ir.cpp
@@ -2,21 +2,20 @@
// SPDX-License-Identifier: Apache-2.0
//
+#include "snippets/lowered/linear_ir.hpp"
+
#include <gtest/gtest.h>
-#include "openvino/op/result.hpp"
-#include "snippets/op/scalar.hpp"
-#include "snippets/op/reshape.hpp"
-#include "snippets/op/result.hpp"
-#include "snippets/op/online_softmax.hpp"
+#include "lir_test_utils.hpp"
#include "openvino/op/parameter.hpp"
-
-#include "snippets/lowered/linear_ir.hpp"
+#include "openvino/op/result.hpp"
#include "snippets/lowered/linear_ir_builder.hpp"
#include "snippets/lowered/port_descriptor.hpp"
#include "snippets/op/broadcastmove.hpp"
-
-#include "lir_test_utils.hpp"
+#include "snippets/op/online_softmax.hpp"
+#include "snippets/op/reshape.hpp"
+#include "snippets/op/result.hpp"
+#include "snippets/op/scalar.hpp"
namespace ov {
namespace test {
diff --git a/src/common/snippets/tests/src/lowered/pass/serialize_data_flow.cpp b/src/common/snippets/tests/src/lowered/pass/serialize_data_flow.cpp
new file mode 100644
index 00000000000..393b69134bc
--- /dev/null
+++ b/src/common/snippets/tests/src/lowered/pass/serialize_data_flow.cpp
@@ -0,0 +1,65 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "snippets/lowered/pass/serialize_data_flow.hpp"
+
+#include <gtest/gtest.h>
+
+#include <fstream>
+#include <iterator>
+#include <memory>
+#include <string>
+
+#include "common_test_utils/common_utils.hpp"
+#include "common_test_utils/file_utils.hpp"
+#include "openvino/op/parameter.hpp"
+#include "snippets/lowered/linear_ir.hpp"
+#include "snippets/op/result.hpp"
+#include "snippets/op/store.hpp"
+
+namespace ov {
+namespace test {
+namespace snippets {
+
+class LinearIRSerializeDataFlow : public testing::Test {
+protected:
+ std::string m_xml_path;
+ std::string m_bin_path;
+
+ void SetUp() override {
+ const auto file_prefix = ov::test::utils::generateTestFilePrefix();
+ m_xml_path = file_prefix + ".xml";
+ m_bin_path = file_prefix + ".bin";
+ }
+
+ void TearDown() override {
+ ov::test::utils::removeIRFiles(m_xml_path, m_bin_path);
+ }
+};
+
+TEST_F(LinearIRSerializeDataFlow, PreservesAllStoreBranches) {
+ const auto param_0 = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1, 6});
+ const auto param_1 = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1, 6});
+ const auto store_0 = std::make_shared<ov::snippets::op::Store>(param_0);
+ const auto store_1 = std::make_shared<ov::snippets::op::Store>(param_1);
+ store_0->set_friendly_name("store_0");
+ store_1->set_friendly_name("store_1");
+ const auto result = std::make_shared<ov::snippets::op::Result>(store_0, ov::OutputVector{store_1});
+ const auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param_0, param_1});
+
+ auto factory = std::make_shared<ov::snippets::IShapeInferSnippetsFactory>();
+ ov::snippets::lowered::LinearIR linear_ir(model, factory);
+
+ EXPECT_FALSE(ov::snippets::lowered::pass::SerializeDataFlow(m_xml_path).run(linear_ir));
+
+ std::ifstream xml_file(m_xml_path);
+ ASSERT_TRUE(xml_file.is_open());
+ const std::string xml(std::istreambuf_iterator<char>{xml_file}, std::istreambuf_iterator<char>{});
+ EXPECT_NE(xml.find("store_0"), std::string::npos);
+ EXPECT_NE(xml.find("store_1"), std::string::npos);
+}
+
+} // namespace snippets
+} // namespace test
+} // namespace ov