-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add lower pass test to compare graph and loop
- Loading branch information
1 parent
c575707
commit 015a5ae
Showing
3 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/common/snippets/tests/src/lowered/pass/extracte_loop_invariants.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "lir_test_utils.hpp" | ||
|
||
#include "openvino/opsets/opset10.hpp" | ||
#include "snippets/lowered/pass/extract_loop_invariants.hpp" | ||
|
||
namespace ov { | ||
namespace test { | ||
namespace snippets { | ||
|
||
using namespace ov::snippets::lowered; | ||
using namespace ov::snippets::lowered::pass; | ||
|
||
class ExtractLoopInvariantsTest : public LoweredPassTestsF { | ||
public: | ||
ExtractLoopInvariantsTest() : LoweredPassTestsF() { | ||
comparator.enable(LIRComparator::LIRCmpValues::LOOP_INDICES); | ||
comparator.enable(LIRComparator::LIRCmpValues::PORT_DESCRIPTORS); | ||
comparator.enable(LIRComparator::LIRCmpValues::PORT_CONNECTORS); | ||
comparator.enable(LIRComparator::LIRCmpValues::LOOP_MANAGER); | ||
} | ||
|
||
void SetUp() override { | ||
pipeline.register_pass<ExtractLoopInvariants>(); | ||
} | ||
}; | ||
|
||
TEST_F(ExtractLoopInvariantsTest, ExtractLoopInvariants) { | ||
size_t vector_size = 16; | ||
const auto input_precision = ov::element::f32; | ||
const ov::Shape scalar_shape{1}; | ||
const ov::Shape input_shape0{1}; | ||
const ov::Shape input_shape1{512}; | ||
/* | ||
* Param0 Scalar | ||
* \ / | ||
* Multiply(loopBegin) | ||
* | | ||
* Broadcast Param1 | ||
* \ / | ||
* Substract(loopBeginRef) | ||
* | | ||
* Store | ||
* | | ||
* Result(LoopEnd and LoopEndRef) | ||
*/ | ||
{ | ||
auto param0 = linear_ir->push_node<ov::opset10::Parameter>(input_precision, input_shape0); | ||
auto param1 = linear_ir->push_node<ov::opset10::Parameter>(input_precision, input_shape1); | ||
auto scalar = linear_ir->push_node<ov::snippets::op::Scalar>(input_precision, scalar_shape, 3.8f); | ||
auto multiply = linear_ir->push_node<ov::opset10::Multiply>(param0.second, scalar.second); | ||
init_expr_descriptors(*multiply.first, {{1}, {1}, {1}}, {{0}, {0}, {0}}); | ||
auto broadcastmove = linear_ir->push_node<ov::snippets::op::BroadcastMove>(multiply.second, 256); | ||
auto sub = linear_ir->push_node<ov::opset10::Subtract>(param1.second, broadcastmove.second); | ||
auto result = linear_ir->push_node<ov::opset10::Result>(sub.second); | ||
init_expr_descriptors(*sub.first, {{512}, {1}, {512}}, {{0}, {0}, {0}}); | ||
auto begin = linear_ir->find(*scalar.first); | ||
auto end = linear_ir->find(*result.first); | ||
create_and_add_unified_loop_info(linear_ir, begin, end, 512, vector_size, | ||
{LoopPort((*multiply.first)->get_input_port(0)), LoopPort((*sub.first)->get_input_port(0))}, | ||
{LoopPort((*sub.first)->get_output_port(0))}); | ||
} | ||
{ | ||
auto param0 = linear_ir_ref->push_node<ov::opset10::Parameter>(input_precision, input_shape0); | ||
auto param1 = linear_ir_ref->push_node<ov::opset10::Parameter>(input_precision, input_shape1); | ||
auto scalar = linear_ir_ref->push_node<ov::snippets::op::Scalar>(input_precision, scalar_shape, 3.8f); | ||
auto multiply = linear_ir_ref->push_node<ov::opset10::Multiply>(param0.second, scalar.second); | ||
init_expr_descriptors(*multiply.first, {{1}, {1}, {1}}, {{0}, {0}, {0}}); | ||
auto broadcastmove = linear_ir_ref->push_node<ov::snippets::op::BroadcastMove>(multiply.second, 256); | ||
auto sub = linear_ir_ref->push_node<ov::opset10::Subtract>(param1.second, broadcastmove.second); | ||
auto result = linear_ir_ref->push_node<ov::opset10::Result>(sub.second); | ||
init_expr_descriptors(*sub.first, {{512}, {1}, {512}}, {{0}, {0}, {0}}); | ||
auto begin = linear_ir_ref->find(*sub.first); | ||
auto end = linear_ir_ref->find(*result.first); | ||
create_and_add_unified_loop_info(linear_ir_ref, begin, end, 512, vector_size, | ||
{LoopPort((*sub.first)->get_input_port(0)), LoopPort((*sub.first)->get_input_port(1))}, | ||
{LoopPort((*sub.first)->get_output_port(0))}); | ||
} | ||
} | ||
} // namespace snippets | ||
} // namespace test | ||
} // namespace ov |