[Snippets][CPU] Fix cycle dependency check in snippets tokenizer (#16760)
This commit is contained in:
@@ -325,7 +325,7 @@ TokenizeSnippets::TokenizeSnippets() {
|
||||
// Skip the node being attached, since it will be a part of subgraph and can't introduce loop dependency
|
||||
const int64_t minChildOrder = std::accumulate(childNodes.begin(), childNodes.end(), currentBounds.second,
|
||||
[&node](int64_t minOrder, std::shared_ptr<Node> n){
|
||||
if (ngraph::op::is_constant(n) || ngraph::op::is_parameter(n) || n == node)
|
||||
if (ov::is_type<ov::op::v0::Result>(n) || n == node)
|
||||
return minOrder;
|
||||
return std::min(minOrder, GetTopologicalOrder(n));
|
||||
});
|
||||
|
||||
@@ -38,6 +38,14 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_Eltwise, TwoInputsAndOutputs,
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
TwoInputsAndOutputs::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_Snippets_Eltwise, TwoInputsAndOutputsWithReversedOutputs,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(input_shapes),
|
||||
::testing::Values(2),
|
||||
::testing::Values(1),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
TwoInputsAndOutputsWithReversedOutputs::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
} // namespace snippets
|
||||
} // namespace test
|
||||
|
||||
@@ -26,6 +26,15 @@ protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
|
||||
// TwoInputsAndOutputsWithReversedOutput tests the same network with reversed order of Result nodes.
|
||||
// It changes order of nodes after topological sort. The test checks the correctness of the
|
||||
// algorithm for checking possible cyclic dependency for nodes with Result node in consumers in tokenization.
|
||||
class TwoInputsAndOutputsWithReversedOutputs : public TwoInputsAndOutputs {
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
} // namespace snippets
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
||||
@@ -33,11 +33,24 @@ void TwoInputsAndOutputs::SetUp() {
|
||||
function = f.getOriginal();
|
||||
}
|
||||
|
||||
void TwoInputsAndOutputsWithReversedOutputs::SetUp() {
|
||||
std::vector<ov::PartialShape> inputShape;
|
||||
std::tie(inputShape, ref_num_nodes, ref_num_subgraphs, targetDevice) = this->GetParam();
|
||||
init_input_shapes(static_partial_shapes_to_test_representation(inputShape));
|
||||
auto f = ov::test::snippets::TwoInputsAndOutputsWithReversedOutputsFunction(inputShape);
|
||||
function = f.getOriginal();
|
||||
}
|
||||
|
||||
TEST_P(TwoInputsAndOutputs, CompareWithRefImpl) {
|
||||
run();
|
||||
validateNumSubgraphs();
|
||||
}
|
||||
|
||||
TEST_P(TwoInputsAndOutputsWithReversedOutputs, CompareWithRefImpl) {
|
||||
run();
|
||||
validateNumSubgraphs();
|
||||
}
|
||||
|
||||
} // namespace snippets
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
||||
@@ -181,6 +181,22 @@ public:
|
||||
protected:
|
||||
std::shared_ptr<ov::Model> initOriginal() const override;
|
||||
};
|
||||
/// Two different Input and Outputs.
|
||||
/// This function is to check correct Broadcasting
|
||||
// in1 in2
|
||||
// HSwish /
|
||||
// Result Add
|
||||
// Relu
|
||||
// Sin
|
||||
// Result
|
||||
class TwoInputsAndOutputsWithReversedOutputsFunction : public SnippetsFunctionBase {
|
||||
public:
|
||||
explicit TwoInputsAndOutputsWithReversedOutputsFunction(const std::vector<PartialShape>& inputShapes) : SnippetsFunctionBase(inputShapes) {
|
||||
NGRAPH_CHECK(input_shapes.size() == 2, "Got invalid number of input shapes");
|
||||
}
|
||||
protected:
|
||||
std::shared_ptr<ov::Model> initOriginal() const override;
|
||||
};
|
||||
/// Verify Select
|
||||
// in0 in1 in2
|
||||
// \ | /
|
||||
|
||||
@@ -277,6 +277,17 @@ std::shared_ptr<ov::Model> TwoInputsAndOutputsFunction::initOriginal() const {
|
||||
return std::make_shared<Model>(NodeVector{hswish, sin3}, ParameterVector{data0, data1});
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::Model> TwoInputsAndOutputsWithReversedOutputsFunction::initOriginal() const {
|
||||
auto data0 = std::make_shared<op::v0::Parameter>(precision, input_shapes[0]);
|
||||
auto data1 = std::make_shared<op::v0::Parameter>(precision, input_shapes[1]);
|
||||
auto hswish = std::make_shared<op::v4::HSwish>(data0);
|
||||
auto add = std::make_shared<op::v1::Add>(hswish, data1);
|
||||
auto relu = std::make_shared<op::v0::Relu>(add);
|
||||
auto sin3 = std::make_shared<op::v0::Sin>(relu);
|
||||
|
||||
return std::make_shared<Model>(NodeVector{sin3, hswish}, ParameterVector{data0, data1});
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::Model> SelectFunction::initOriginal() const {
|
||||
auto data0 = std::make_shared<op::v0::Parameter>(ov::element::boolean, input_shapes[0]);
|
||||
auto data1 = std::make_shared<op::v0::Parameter>(precision, input_shapes[1]);
|
||||
|
||||
Reference in New Issue
Block a user