Skip to content

Commit

Permalink
[luci-interpreter] Relax Transpose rank limitations (#14512)
Browse files Browse the repository at this point in the history
This commit removes assert that limit Transpose rank to 4. TF 2.8 allows to inference this operator with rank 5.

ONE-DCO-1.0-Signed-off-by: Mateusz Bencer [email protected]
  • Loading branch information
mbencer authored Jan 3, 2025
1 parent ac8885a commit 548c522
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/luci-interpreter/src/kernels/Transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Transpose::configure()
int dims = input()->shape().num_dims();
const int32_t *perm_data = getTensorData<int32_t>(perm());

assert(input()->shape().num_dims() <= 4);
assert(input()->shape().num_dims() <= 5);
assert(input()->element_type() == output()->element_type());

assert(perm()->shape().num_dims() == 1);
Expand Down
13 changes: 13 additions & 0 deletions compiler/luci-interpreter/src/kernels/Transpose.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ TYPED_TEST(TransposeTest, Large2D)
70, 82, 94, 106, 118, 11, 23, 35, 47, 59, 71, 83, 95, 107, 119});
}

TYPED_TEST(TransposeTest, Small5D)
{
Check<TypeParam>(
/*input_shape=*/{2, 3, 4, 1, 2}, /*perm_shape=*/{5}, /*output_shape=*/{1, 3, 4, 2, 2},
/*input_data=*/{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47},
/*perm_data=*/{3, 1, 2, 0, 4},
/*output_data=*/{0, 1, 24, 25, 2, 3, 26, 27, 4, 5, 28, 29, 6, 7, 30, 31,
8, 9, 32, 33, 10, 11, 34, 35, 12, 13, 36, 37, 14, 15, 38, 39,
16, 17, 40, 41, 18, 19, 42, 43, 20, 21, 44, 45, 22, 23, 46, 47});
}

} // namespace
} // namespace kernels
} // namespace luci_interpreter

0 comments on commit 548c522

Please sign in to comment.