6
6
7
7
#include " openvino/opsets/opset1.hpp"
8
8
#include " snippets/op/buffer.hpp"
9
+ #include " snippets/op/subgraph.hpp"
9
10
#include " snippets/lowered/linear_ir.hpp"
11
+ #include " snippets/pass/positioned_pass.hpp"
10
12
#include " snippets/lowered/pass/mark_loops.hpp"
11
13
#include " snippets/lowered/pass/init_loops.hpp"
12
14
#include " snippets/lowered/pass/insert_load_store.hpp"
@@ -25,12 +27,14 @@ namespace test {
25
27
namespace snippets {
26
28
27
29
std::string BufferAllocationTest::getTestCaseName (testing::TestParamInfo<ov::test::snippets::BufferAllocationParams> obj) {
30
+ std::vector<ov::PartialShape> shapes;
28
31
bool is_optimized, with_split_loops;
29
32
size_t expected_size, expected_reg_group_count, expected_cluster_count;
30
33
31
- std::tie (is_optimized, with_split_loops, expected_size, expected_reg_group_count, expected_cluster_count) = obj.param ;
34
+ std::tie (shapes, is_optimized, with_split_loops, expected_size, expected_reg_group_count, expected_cluster_count) = obj.param ;
32
35
33
36
std::ostringstream result;
37
+ result << " Shapes=" << ov::test::utils::partialShape2str (shapes) << " _" ;
34
38
result << " Opt=" << ov::test::utils::bool2str (is_optimized) << " _" ;
35
39
result << " Split=" << ov::test::utils::bool2str (with_split_loops) << " _" ;
36
40
result << " ExpBufferSize=" << expected_size << " _" ;
@@ -40,13 +44,12 @@ std::string BufferAllocationTest::getTestCaseName(testing::TestParamInfo<ov::tes
40
44
}
41
45
42
46
void BufferAllocationTest::SetUp () {
43
- std::tie (m_is_buffer_optimized, m_with_split_loops, m_expected_size, m_expected_reg_group_count, m_expected_cluster_count) = this ->GetParam ();
47
+ std::tie (m_shapes, m_is_buffer_optimized, m_with_split_loops, m_expected_size,
48
+ m_expected_reg_group_count, m_expected_cluster_count) = this ->GetParam ();
44
49
45
- const auto body = GetModel ();
46
- m_linear_ir = ov::snippets::lowered::LinearIR (body, std::make_shared<ov::snippets::IShapeInferSnippetsFactory> ());
50
+ const auto body = GetModel (m_shapes );
51
+ m_linear_ir = ov::snippets::lowered::LinearIR (body, GetShapeInferFactory ());
47
52
m_linear_ir.set_loop_depth (m_loop_depth);
48
- // When Subgraph::control_flow_transformations become public method,
49
- // please use this method instead of ApplyTransformations
50
53
ApplyTransformations (GetPassConfig ());
51
54
}
52
55
@@ -57,6 +60,10 @@ std::shared_ptr<ov::snippets::lowered::pass::PassConfig> BufferAllocationTest::G
57
60
return config;
58
61
}
59
62
63
+ std::shared_ptr<ov::snippets::IShapeInferSnippetsFactory> BufferAllocationTest::GetShapeInferFactory () const {
64
+ return std::make_shared<ov::snippets::IShapeInferSnippetsFactory>();
65
+ }
66
+
60
67
void BufferAllocationTest::MarkOp (const std::shared_ptr<ov::Node>& node, const std::vector<size_t >& subtensor) {
61
68
for (const auto & input : node->inputs ())
62
69
ov::snippets::lowered::PortDescriptorUtils::set_port_descriptor_ptr (
@@ -66,6 +73,23 @@ void BufferAllocationTest::MarkOp(const std::shared_ptr<ov::Node>& node, const s
66
73
output, std::make_shared<ov::snippets::lowered::PortDescriptor>(output, subtensor));
67
74
}
68
75
76
+ void BufferAllocationTest::MarkOp (const std::shared_ptr<ov::Node>& node,
77
+ const std::vector<std::vector<size_t >>& in_subtensors,
78
+ const std::vector<std::vector<size_t >>& out_subtensors) {
79
+ OPENVINO_ASSERT (in_subtensors.size () == node->inputs ().size (), " Incorrect count of input subtensors" );
80
+ OPENVINO_ASSERT (out_subtensors.size () == node->outputs ().size (), " Incorrect count of output subtensors" );
81
+ for (size_t i = 0 ; i < node->inputs ().size (); ++i) {
82
+ const auto & input = node->input (i);
83
+ ov::snippets::lowered::PortDescriptorUtils::set_port_descriptor_ptr (
84
+ input, std::make_shared<ov::snippets::lowered::PortDescriptor>(input, in_subtensors[i]));
85
+ }
86
+ for (size_t i = 0 ; i < node->outputs ().size (); ++i) {
87
+ const auto & output = node->output (i);
88
+ ov::snippets::lowered::PortDescriptorUtils::set_port_descriptor_ptr (
89
+ output, std::make_shared<ov::snippets::lowered::PortDescriptor>(output, out_subtensors[i]));
90
+ }
91
+ }
92
+
69
93
void BufferAllocationTest::ApplyTransformations (const std::shared_ptr<ov::snippets::lowered::pass::PassConfig>& pass_config) {
70
94
ov::snippets::lowered::pass::PassPipeline pipeline (pass_config);
71
95
pipeline.register_pass <ov::snippets::lowered::pass::MarkLoops>(m_vector_size);
@@ -77,8 +101,13 @@ void BufferAllocationTest::ApplyTransformations(const std::shared_ptr<ov::snippe
77
101
pipeline.register_pass <ov::snippets::lowered::pass::InitLoops>();
78
102
pipeline.register_pass <ov::snippets::lowered::pass::InsertLoops>();
79
103
pipeline.register_pass <ov::snippets::lowered::pass::AllocateBuffers>(m_is_buffer_optimized);
104
+ pipeline.register_positioned_passes (getBackendSpecificPasses ());
80
105
pipeline.run (m_linear_ir);
81
106
}
107
+ std::vector<ov::snippets::lowered::pass::PassPipeline::PositionedPassLowered>
108
+ BufferAllocationTest::getBackendSpecificPasses () {
109
+ return {};
110
+ }
82
111
83
112
void BufferAllocationTest::Validate () {
84
113
std::set<size_t > reg_groups, clusters;
@@ -91,12 +120,13 @@ void BufferAllocationTest::Validate() {
91
120
EXPECT_EQ (m_linear_ir.get_static_buffer_scratchpad_size (), m_expected_size);
92
121
}
93
122
94
- std::shared_ptr<ov::Model> EltwiseBufferAllocationTest::GetModel () const {
123
+ std::shared_ptr<ov::Model> EltwiseBufferAllocationTest::GetModel (const std::vector<ov::PartialShape>& shapes ) const {
95
124
const auto subtensor_eltwise = std::vector<size_t >{1 , m_vector_size};
96
125
const auto subtensor_buffer = std::vector<size_t >(2 , ov::snippets::utils::get_full_dim_value ());
97
126
98
- const auto parameter0 = std::make_shared<ov::op::v0::Parameter>(ov::element::f32 , ov::PartialShape ({1 , 3 , 100 , 100 }));
99
- const auto parameter1 = std::make_shared<ov::op::v0::Parameter>(ov::element::f32 , ov::PartialShape ({1 , 3 , 100 , 100 }));
127
+ const auto parameter0 = std::make_shared<ov::op::v0::Parameter>(ov::element::f32 , shapes[0 ]);
128
+ const auto parameter1 = std::make_shared<ov::op::v0::Parameter>(ov::element::f32 , shapes[0 ]);
129
+
100
130
const auto add = std::make_shared<ov::op::v1::Add>(parameter0, parameter1);
101
131
const auto buffer0 = std::make_shared<ov::snippets::op::Buffer>(add);
102
132
const auto relu = std::make_shared<ov::op::v0::Relu>(buffer0);
@@ -121,6 +151,7 @@ namespace BufferAllocationTest_Instances {
121
151
122
152
INSTANTIATE_TEST_SUITE_P (smoke_Snippets_BufferAllocation_EltwiseNotOptimized, EltwiseBufferAllocationTest,
123
153
::testing::Combine (
154
+ ::testing::Values (std::vector<ov::PartialShape>{{1 , 3 , 100 , 100 }}),
124
155
::testing::Values(false ),
125
156
::testing::Values(false ), // in this test it doesn't make sense
126
157
::testing::Values(80000 ), // Each Buffer has own allocated memory
@@ -130,6 +161,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_BufferAllocation_EltwiseNotOptimized, El
130
161
131
162
INSTANTIATE_TEST_SUITE_P (smoke_Snippets_BufferAllocation_EltwiseOptimized, EltwiseBufferAllocationTest,
132
163
::testing::Combine (
164
+ ::testing::Values (std::vector<ov::PartialShape>{{1 , 3 , 100 , 100 }}),
133
165
::testing::Values(true ),
134
166
::testing::Values(false ), // in this test it doesn't make sense
135
167
::testing::Values(40000 ), // Two Buffer reuse memory
0 commit comments