Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snippets] Fixed the pass ExtractLoopInvariants #26775

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ int64_t get_stride_after_move_outer(const LoopPort& loop_port) {
}
}

bool is_extraction_applicable(const ExpressionPtr& expr, const UnifiedLoopInfoPtr& inner_loop_info) {
bool is_extraction_applicable(const ExpressionPtr& expr, const UnifiedLoopInfoPtr& inner_loop_info, size_t loop_id) {
// Extraction is possible only from the innermost Loop!
// We cannot extract Expression from the outermost or any intermediate Loop with other Loops inside
const auto& loop_ids = expr->get_loop_ids();
OPENVINO_ASSERT(!loop_ids.empty(), "Expression must be in a Loop");
if (loop_ids.back() != loop_id)
return false;

const auto& expr_input_ports = expr->get_input_ports();
const auto& input_port_size = expr_input_ports.size();
if (input_port_size == 0)
Expand Down Expand Up @@ -162,7 +169,7 @@ bool extract_from_loop(const size_t& inner_loop_id, LinearIR& linear_ir) {
const auto& potential_extractable_exprs = get_loop_input_exprs(inner_loop_input_ports);
bool expr_extracted = false;
for (const auto& port_expr : potential_extractable_exprs) {
if (is_extraction_applicable(port_expr, inner_loop_info)) {
if (is_extraction_applicable(port_expr, inner_loop_info, inner_loop_id)) {
status = true;
LinearIR::constExprIt inner_loop_begin_pos, inner_loop_end_pos;
std::tie(inner_loop_begin_pos, inner_loop_end_pos) = loop_manager->get_loop_bounds(linear_ir, inner_loop_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,40 @@ TEST_F(ExtractLoopInvariantsTest, ExtractedLoopInvariantsFromInnermostToLoopOuts
}
}

TEST_F(ExtractLoopInvariantsTest, ExtractedLoopInvariantsImpossible) {
const auto input_precision = ov::element::f32;
const ov::Shape input_shape_0{32, 8, 1};
ov::snippets::VectorDims order{1, 2, 0};
ov::snippets::VectorDims layout{0, 1, 2};
ov::snippets::VectorDims subtensor{1, 1};
/*
* < Transpose decomposition >
*
* Param0(32,8,1)
* |
* LoadReshape with order (1,2,0)
* |
* Store
* |
* Result
*/
{
auto param = linear_ir->push_node<ov::opset10::Parameter>(input_precision, input_shape_0);
auto load_reshape = linear_ir->push_node<ov::snippets::op::LoadReshape>(param.second, 1, 0, layout);
auto store = linear_ir->push_node<ov::snippets::op::Store>(load_reshape.second, 1, 0);
init_expr_descriptors(*load_reshape.first, {subtensor, subtensor}, {order, layout});
init_expr_descriptors(*store.first, {subtensor, subtensor}, {layout, layout});
auto result = linear_ir->push_node<ov::opset10::Result>(store.second);
linear_ir->get_loop_manager()->mark_loop(load_reshape.first, result.first, 32, 1,
std::vector<LoopPort>{LoopPort((*load_reshape.first)->get_input_port(0), true, 0)},
std::vector<LoopPort>{LoopPort((*store.first)->get_output_port(0), true, 0)});
linear_ir->get_loop_manager()->mark_loop(load_reshape.first, result.first, 1, 1,
std::vector<LoopPort>{LoopPort((*load_reshape.first)->get_input_port(0), true, 1)},
std::vector<LoopPort>{LoopPort((*store.first)->get_output_port(0), true, 1)});
linear_ir->set_loop_depth(2);
}
}

TEST_F(ExtractLoopInvariantsTest, ExtractedLoopInvariantsSplitLoops) {
size_t vector_size = 16;
size_t block_size = 32;
Expand Down
Loading