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

[Transformations] SDPA Decomposition: avoid unnecessary ShapeOf subgraphs #28639

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 @@ -129,6 +129,36 @@ TEST_F(TransformationTestsF, ScaledDotProductAttentionDecompositionStaticBroadca
}
}

TEST_F(TransformationTestsF, ScaledDotProductAttentionPartiallyDynamic) {
const PartialShape query_shape{-1, 24, -1, 64};
const PartialShape key_shape{-1, 24, -1, 64};
const PartialShape value_shape{-1, 24, -1, 64};
const PartialShape attention_mask_shape{-1, 24, -1, 64};
const PartialShape scale_shape{};

const auto query = std::make_shared<ov::op::v0::Parameter>(element::f32, query_shape);
const auto key = std::make_shared<ov::op::v0::Parameter>(element::f32, key_shape);
const auto value = std::make_shared<ov::op::v0::Parameter>(element::f32, value_shape);
const auto attention_mask = std::make_shared<ov::op::v0::Parameter>(element::f32, attention_mask_shape);
const auto scale = std::make_shared<ov::op::v0::Parameter>(element::f32, scale_shape);
const auto casual = false;
{
const auto scaled_dot_product_attention =
std::make_shared<ov::op::v13::ScaledDotProductAttention>(query, key, value, attention_mask, scale, casual);

model = std::make_shared<ov::Model>(NodeVector{scaled_dot_product_attention},
ParameterVector{query, key, value, attention_mask, scale});
manager.register_pass<ov::pass::ScaledDotProductAttentionDecomposition>();
}

{
const auto scaled_dot_product_attention =
scaled_dot_product_attention_decomposition(query, key, value, attention_mask, scale, casual);
model_ref = std::make_shared<ov::Model>(NodeVector{scaled_dot_product_attention},
ParameterVector{query, key, value, attention_mask, scale});
}
}

TEST_F(TransformationTestsF, ScaledDotProductAttentionDecompositionDynamic) {
const PartialShape query_shape{-1, -1, -1};
const PartialShape key_shape{-1, -1, -1};
Expand Down
Loading