@@ -1636,6 +1636,47 @@ auto test_backward_reshape_unsqueeze = []() {
1636
1636
INSTANTIATE_TEST_SUITE_P (TransposeSinkingCommonReshapeUnsqueezeBackward,
1637
1637
TSTestFixture,
1638
1638
test_backward_reshape_unsqueeze ());
1639
+
1640
+ auto test_backward_unsqueeze_dyn_rank = []() {
1641
+ TestCase test_case;
1642
+
1643
+ // Initialize common attributes
1644
+ test_case.transformation = CREATE_PASS_FACTORY (TSUnsqueezeBackward);
1645
+ test_case.num_main_ops = {1 };
1646
+ test_case.inputs_to_main = {
1647
+ parameter (element::f32, PartialShape::dynamic ()),
1648
+ constant<int64_t >(element::i32, {2 }, {-1 }),
1649
+ };
1650
+
1651
+ auto dyn_transpose = [](const vector<size_t >& idxs, const OutputVector& out_vec) -> OutputVector {
1652
+ OutputVector result = out_vec;
1653
+ for (const auto & idx : idxs) {
1654
+ const auto & out = out_vec[idx];
1655
+
1656
+ // fill the order const with the stub values {-1, -2}
1657
+ auto order = make_shared<Constant>(element::i32, Shape{2 }, vector<int64_t >{-1 , -2 });
1658
+ auto transpose = make_shared<Transpose>(out, order);
1659
+ result[idx] = transpose;
1660
+ }
1661
+ return result;
1662
+ };
1663
+
1664
+ // Test model description:
1665
+ test_case.model .main_op = {CREATE_BINARY_FACTORY (Unsqueeze)};
1666
+ test_case.model .preprocess_outputs_of_main = {{dyn_transpose}, {{0 }}};
1667
+ test_case.model .model_template = create_model;
1668
+
1669
+ // Ref model description, the same as the original model, the transformation is not applied
1670
+ // it's expected.
1671
+ test_case.model_ref .main_op = {CREATE_BINARY_FACTORY (Unsqueeze)};
1672
+ test_case.model_ref .preprocess_outputs_of_main = {{dyn_transpose}, {{0 }}};
1673
+ test_case.model_ref .model_template = create_model;
1674
+ return wrapper (test_case);
1675
+ };
1676
+
1677
+ INSTANTIATE_TEST_SUITE_P (TransposeSinkingCommonUnsqueezeBackwardDynRank,
1678
+ TSTestFixture,
1679
+ test_backward_unsqueeze_dyn_rank ());
1639
1680
} // namespace common
1640
1681
} // namespace testing
1641
1682
} // namespace transpose_sinking
0 commit comments