[Mlir-commits] [mlir] [mlir][vector] Add a negative test for `FoldTransposeBroadcast` (PR #217915)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Tue Aug 25 07:32:38 PDT 2026
================
@@ -67,18 +67,31 @@ func.func @broadcast_transpose_partial_ones_to_broadcast(%arg0 : vector<1xi8>) -
// -----
-// CHECK-LABEL: broadcast_transpose_mixed_example
+// CHECK-LABEL: broadcast_transpose_mixed_order_preserving
// CHECK-SAME: %[[ARG:.*]]: vector<4x1x1x7xi8>) -> vector<3x2x4x5x6x7xi8> {
// CHECK: %[[RES:.*]] = vector.broadcast %[[ARG]] : vector<4x1x1x7xi8> to vector<3x2x4x5x6x7xi8>
// CHECK: return %[[RES]] : vector<3x2x4x5x6x7xi8>
-func.func @broadcast_transpose_mixed_example(%arg0 : vector<4x1x1x7xi8>) -> vector<3x2x4x5x6x7xi8> {
+func.func @broadcast_transpose_mixed_order_preserving(%arg0 : vector<4x1x1x7xi8>) -> vector<3x2x4x5x6x7xi8> {
%0 = vector.broadcast %arg0 : vector<4x1x1x7xi8> to vector<2x3x4x5x6x7xi8>
%1 = vector.transpose %0, [1, 0, 2, 3, 4, 5] : vector<2x3x4x5x6x7xi8> to vector<3x2x4x5x6x7xi8>
return %1 : vector<3x2x4x5x6x7xi8>
}
// -----
+// CHECK-LABEL: negative_broadcast_transpose_mixed_not_order_preserving
+// CHECK-SAME: %[[ARG:.*]]: vector<4x1x1x7xi8>) -> vector<6x2x4x5x3x7xi8> {
+// CHECK: %[[BC:.*]] = vector.broadcast
+// CHECK: %[[TR:.*]] = vector.transpose %[[BC]]
+// CHECK: return %[[TR]] : vector<6x2x4x5x3x7xi8>
+func.func @negative_broadcast_transpose_mixed_not_order_preserving(%arg0 : vector<4x1x1x7xi8>) -> vector<6x2x4x5x3x7xi8> {
+ %0 = vector.broadcast %arg0 : vector<4x1x1x7xi8> to vector<2x3x4x5x6x7xi8>
+ %1 = vector.transpose %0, [4, 0, 2, 3, 1, 5] : vector<2x3x4x5x6x7xi8> to vector<6x2x4x5x3x7xi8>
----------------
banach-space wrote:
> I don't know the historical reason behind this implementation choice.
Since it's a canonicalisation, it must have been related to preserving information that would otherwise be lost.
In any case, we should always take extra care when modifying the semantics of a folder. This PR is the first step. Let's land it and then return to #215940 . I am hoping that @dcaballe will be able to chime in too.
https://github.com/llvm/llvm-project/pull/217915
More information about the Mlir-commits
mailing list