Skip to content

Commit 33c134e

Browse files
authored
[mlir][linalg] Refine test for tensor.pad vectorization (#110742)
This particular test was missing the `vectorize_padding` attribute and hence didn't really trigger anything meaningful. I've added the attribute and additional check-lines to verify that: * The vectorizer was indeed run (and generated vector Ops). * The final `tensor.insert_slice` Op is preserved. Note that another `tensor.insert_slice` Op, inserted by the vectoriser, was rewritten as a `vector.transfer_read`/`vector.transfer_write` pair and hence is not present in the test output.
1 parent 30f58ab commit 33c134e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mlir/test/Dialect/Linalg/vectorization-with-patterns.mlir

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,15 @@ module attributes {transform.with_named_sequence} {
10911091
func.func private @make_vector() -> tensor<12x13xf32>
10921092

10931093
// CHECK-LABEL: func @pad_and_insert_slice_dest
1094+
// CHECK-SAME: %[[ARG0:.*]]: tensor<1x5x6xf32>
10941095
// Check the insert slice is not rewritten if the padded result is used by the destination operand.
1096+
// CHECK-NOT: tensor.pad
1097+
// CHECK: %[[EMPTY:.*]] = tensor.empty() : tensor<1x12x13xf32>
1098+
// CHECK: %[[WRITE_1:.*]] = vector.transfer_write %{{.*}}, %[[EMPTY]]{{.*}} : vector<1x12x13xf32>, tensor<1x12x13xf32>
1099+
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG0:.*]]{{.*}} : tensor<1x5x6xf32>, vector<1x5x6xf32>
1100+
// CHECK: %[[WRITE_2:.*]] = vector.transfer_write %[[READ]], %[[WRITE_1]]{{.*}} : vector<1x5x6xf32>, tensor<1x12x13xf32>
10951101
// CHECK: %[[T1:.*]] = call @make_vector() : () -> tensor<12x13xf32>
1096-
// CHECK: = tensor.insert_slice %[[T1]] into
1102+
// CHECK: tensor.insert_slice %[[T1]] into %[[WRITE_2]]
10971103
func.func @pad_and_insert_slice_dest(
10981104
%arg0: tensor<1x5x6xf32>) -> tensor<1x12x13xf32> {
10991105
%c5 = arith.constant 5.0 : f32
@@ -1110,7 +1116,7 @@ module attributes {transform.with_named_sequence} {
11101116
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
11111117
%3 = transform.structured.match ops{["tensor.pad"]} in %arg1 : (!transform.any_op) -> !transform.any_op
11121118
%4 = transform.get_parent_op %3 {isolated_from_above} : (!transform.any_op) -> !transform.any_op
1113-
%5 = transform.structured.vectorize_children_and_apply_patterns %4 : (!transform.any_op) -> !transform.any_op
1119+
%5 = transform.structured.vectorize_children_and_apply_patterns %4 { vectorize_padding } : (!transform.any_op) -> !transform.any_op
11141120
transform.yield
11151121
}
11161122
}

0 commit comments

Comments
 (0)