Skip to content

Commit bca79ec

Browse files
authored
[mlir][linalg] Use ub.poison in linalg vectorizer instead of 0 for some transfer ops (#146544)
This patch is a follow up to #146088 and changes the padding value in the linalg vectorizer from `0` to `ub.poison` in `vector.transfer_read`s created for extracting slices or when vectorizing a generic. Signed-off-by: Fabian Mora <fabian.mora-cordero@amd.com>
1 parent ebcf7f9 commit bca79ec

File tree

5 files changed

+73
-76
lines changed

5 files changed

+73
-76
lines changed

mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,19 +1183,15 @@ vectorizeTensorExtract(RewriterBase &rewriter, VectorizationState &state,
11831183
auto srcRank = extractOp.getTensor().getType().getRank();
11841184
SmallVector<bool> inBounds(dstRank, true);
11851185

1186-
// Get the value to pad transfer reads with 0.
1187-
Value padding =
1188-
arith::getZeroConstant(rewriter, loc, resultType.getElementType());
1189-
11901186
// 2a. Handle scalar broadcast access.
11911187
if (memAccessKind == VectorMemoryAccessKind::ScalarBroadcast) {
11921188
MLIRContext *ctx = rewriter.getContext();
11931189
SmallVector<AffineExpr> exprs(dstRank, getAffineConstantExpr(0, ctx));
11941190
auto permutationMap = AffineMap::get(srcRank, 0, exprs, ctx);
11951191

11961192
auto transferReadOp = rewriter.create<vector::TransferReadOp>(
1197-
loc, resultType, extractOp.getTensor(), transferReadIdxs, padding,
1198-
permutationMap, inBounds);
1193+
loc, resultType, extractOp.getTensor(), transferReadIdxs,
1194+
/*padding=*/std::nullopt, permutationMap, inBounds);
11991195

12001196
// Mask this broadcasting xfer_read here rather than relying on the generic
12011197
// path (the generic path assumes identity masking map, which wouldn't be
@@ -1231,8 +1227,8 @@ vectorizeTensorExtract(RewriterBase &rewriter, VectorizationState &state,
12311227
}
12321228

12331229
auto transferReadOp = rewriter.create<vector::TransferReadOp>(
1234-
loc, resultType, extractOp.getTensor(), transferReadIdxs, padding,
1235-
permutationMap, inBounds);
1230+
loc, resultType, extractOp.getTensor(), transferReadIdxs,
1231+
/*padding=*/std::nullopt, permutationMap, inBounds);
12361232

12371233
LDBG("Vectorised as contiguous load: " << extractOp);
12381234
return VectorizationHookResult{VectorizationHookStatus::NewOp,
@@ -1444,7 +1440,7 @@ vectorizeAsLinalgGeneric(RewriterBase &rewriter, VectorizationState &state,
14441440

14451441
Operation *read = rewriter.create<vector::TransferReadOp>(
14461442
loc, readType, opOperand->get(), indices,
1447-
/*padding=*/arith::getZeroConstant(rewriter, loc, elemType), readMap);
1443+
/*padding=*/std::nullopt, readMap);
14481444
read = state.maskOperation(rewriter, read, linalgOp, indexingMap);
14491445
Value readValue = read->getResult(0);
14501446

@@ -2646,7 +2642,7 @@ LogicalResult mlir::linalg::vectorizeCopy(RewriterBase &rewriter,
26462642

26472643
Value readValue = rewriter.create<vector::TransferReadOp>(
26482644
loc, readType, copyOp.getSource(), indices,
2649-
/*padding=*/arith::getZeroConstant(rewriter, loc, srcElementType),
2645+
/*padding=*/std::nullopt,
26502646
rewriter.getMultiDimIdentityMap(srcType.getRank()));
26512647
if (cast<VectorType>(readValue.getType()).getRank() == 0) {
26522648
readValue =

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ func.func @vectorize_nd_tensor_extract_transfer_read_basic(
3131
// CHECK-SAME: %[[ARG1:.*]]: tensor<1x1x3xf32>
3232

3333
// CHECK-DAG: %[[C0:.+]] = arith.constant 0 : index
34-
// CHECK-DAG: %[[CST:.+]] = arith.constant 0.000000e+00 : f32
34+
// CHECK-DAG: %[[PV:.+]] = ub.poison : f32
3535

36-
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG0]][%[[C0]], %[[C0]], %[[C0]]], %[[CST]] {in_bounds = [true, true, true]} : tensor<3x3x3xf32>, vector<1x1x3xf32>
36+
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG0]][%[[C0]], %[[C0]], %[[C0]]], %[[PV]] {in_bounds = [true, true, true]} : tensor<3x3x3xf32>, vector<1x1x3xf32>
3737
// CHECK: vector.transfer_write %[[READ]], %[[ARG1]][%[[C0]], %[[C0]], %[[C0]]] {in_bounds = [true, true, true]} : vector<1x1x3xf32>, tensor<1x1x3xf32>
3838

3939
// -----
@@ -64,12 +64,12 @@ func.func @vectorize_nd_tensor_extract_transfer_read_complex(%6: tensor<45x80x16
6464
// CHECK-SAME: %[[ARG5:.*]]: tensor<1x4xf32>) -> tensor<1x4xf32> {
6565

6666
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
67-
// CHECK-DAG: %[[CST:.*]] = arith.constant 0.000000e+00 : f32
67+
// CHECK-DAG: %[[PV:.*]] = ub.poison : f32
6868
// CHECK-DAG: %[[C79:.*]] = arith.constant 79 : index
6969
// CHECK: %[[ADD1:.*]] = arith.addi %[[ARG1]], %[[ARG2]] : index
7070
// CHECK: %[[ADD2:.*]] = arith.addi %[[ARG3]], %[[ARG4]] : index
7171

72-
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG0]]{{\[}}%[[ADD1]], %[[C79]], %[[ADD2]]], %[[CST]] {in_bounds = [true, true]} : tensor<45x80x16xf32>, vector<1x4xf32>
72+
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG0]]{{\[}}%[[ADD1]], %[[C79]], %[[ADD2]]], %[[PV]] {in_bounds = [true, true]} : tensor<45x80x16xf32>, vector<1x4xf32>
7373
// CHECK: %[[WRITE:.*]] = vector.transfer_write %[[READ]], %[[ARG5]]{{\[}}%[[C0]], %[[C0]]] {in_bounds = [true, true]} : vector<1x4xf32>, tensor<1x4xf32>
7474
// CHECK: return %[[WRITE]] : tensor<1x4xf32>
7575
// CHECK: }
@@ -97,11 +97,11 @@ func.func @vectorize_nd_tensor_extract_with_affine_apply_contiguous(%6: tensor<8
9797
// CHECK-SAME: %[[ARG1:.*]]: index,
9898
// CHECK-SAME: %[[ARG2:.*]]: tensor<1x4xf32>) -> tensor<1x4xf32> {
9999

100-
// CHECK-DAG: %[[CST:.*]] = arith.constant 0.000000e+00 : f32
100+
// CHECK-DAG: %[[PV:.*]] = ub.poison : f32
101101
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
102102
// CHECK-DAG: %[[C79:.*]] = arith.constant 79 : index
103103

104-
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG0]]{{\[}}%[[C79]], %[[ARG1]]], %[[CST]] {in_bounds = [true, true]} : tensor<80x16xf32>, vector<1x4xf32>
104+
// CHECK: %[[READ:.*]] = vector.transfer_read %[[ARG0]]{{\[}}%[[C79]], %[[ARG1]]], %[[PV]] {in_bounds = [true, true]} : tensor<80x16xf32>, vector<1x4xf32>
105105
// CHECK: %[[WRITE:.*]] = vector.transfer_write %[[READ]], %[[ARG2]]{{\[}}%[[C0]], %[[C0]]] {in_bounds = [true, true]} : vector<1x4xf32>, tensor<1x4xf32>
106106
// CHECK: return %[[WRITE]] : tensor<1x4xf32>
107107
// CHECK: }
@@ -164,9 +164,9 @@ func.func @vectorize_nd_tensor_extract_with_maxsi_contiguous(%arg0: tensor<80x16
164164
// CHECK-SAME: %[[VAL_1:.*]]: tensor<1x4xf32>) -> tensor<1x4xf32> {
165165
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
166166
// CHECK-DAG: %[[C16:.*]] = arith.constant 16 : index
167-
// CHECK-DAG: %[[CST:.*]] = arith.constant 0.000000e+00 : f32
167+
// CHECK-DAG: %[[PV:.*]] = ub.poison : f32
168168

169-
// CHECK: %[[VAL_8:.*]] = vector.transfer_read %[[VAL_0]]{{\[}}%[[C16]], %[[C0]]], %[[CST]] {in_bounds = [true, true]} : tensor<80x16xf32>, vector<1x4xf32>
169+
// CHECK: %[[VAL_8:.*]] = vector.transfer_read %[[VAL_0]]{{\[}}%[[C16]], %[[C0]]], %[[PV]] {in_bounds = [true, true]} : tensor<80x16xf32>, vector<1x4xf32>
170170
// CHECK: %[[VAL_9:.*]] = vector.transfer_write %[[VAL_8]], %[[VAL_1]]{{\[}}%[[C0]], %[[C0]]] {in_bounds = [true, true]} : vector<1x4xf32>, tensor<1x4xf32>
171171
// CHECK: return %[[VAL_9]] : tensor<1x4xf32>
172172
// CHECK: }
@@ -229,12 +229,12 @@ func.func @vectorize_nd_tensor_extract_index_from_tensor(%arg0: tensor<3x3xf32>,
229229
// CHECK-SAME: %[[ARG3:.*]]: tensor<4x7x2xf32>
230230
// CHECK-SAME: %[[ARG4:.*]]: tensor<4x7x3x2xf32>
231231
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
232-
// CHECK-DAG: %[[C0_i32:.*]] = arith.constant 0 : i32
232+
// CHECK-DAG: %[[PV:.*]] = ub.poison : i32
233233
// CHECK-DAG: %[[CST:.*]] = arith.constant dense<3> : vector<7x2x4x3xindex>
234234
// CHECK-DAG: %[[CST_1:.*]] = arith.constant dense<true> : vector<4x7x3x2xi1>
235235
// CHECK-DAG: %[[PASSTHRU:.*]] = arith.constant dense<0.000000e+00> : vector<4x7x3x2xf32>
236-
// CHECK: %[[V0:.*]] = vector.transfer_read %[[ARG1]][%[[C0]], %[[C0]]], %[[C0_i32]] {in_bounds = [true, true]} : tensor<4x3xi32>, vector<4x3xi32>
237-
// CHECK: %[[V1:.*]] = vector.transfer_read %[[ARG2]][%[[C0]], %[[C0]]], %[[C0_i32]] {in_bounds = [true, true]} : tensor<4x3xi32>, vector<4x3xi32>
236+
// CHECK: %[[V0:.*]] = vector.transfer_read %[[ARG1]][%[[C0]], %[[C0]]], %[[PV]] {in_bounds = [true, true]} : tensor<4x3xi32>, vector<4x3xi32>
237+
// CHECK: %[[V1:.*]] = vector.transfer_read %[[ARG2]][%[[C0]], %[[C0]]], %[[PV]] {in_bounds = [true, true]} : tensor<4x3xi32>, vector<4x3xi32>
238238
// CHECK: %[[CAST:.*]] = arith.index_cast %[[V0]] : vector<4x3xi32> to vector<4x3xindex>
239239
// CHECK: %[[B1:.*]] = vector.broadcast %[[CAST]] : vector<4x3xindex> to vector<7x2x4x3xindex>
240240
// CHECK: %[[CAST_1:.*]] = arith.index_cast %[[V1]] : vector<4x3xi32> to vector<4x3xindex>
@@ -382,7 +382,7 @@ func.func @vectorize_nd_tensor_extract_contiguous_and_gather(%arg0: tensor<6xf32
382382
// CHECK-SAME: %[[VAL_0:.*]]: tensor<6xf32>
383383
// CHECK-SAME: %[[VAL_1:.*]]: tensor<5xi32>
384384
// CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : index
385-
// CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : i32
385+
// CHECK-DAG: %[[VAL_3:.*]] = ub.poison : i32
386386
// CHECK-DAG: %[[VAL_4:.*]] = arith.constant dense<0> : vector<5xindex>
387387
// CHECK-DAG: %[[VAL_5:.*]] = arith.constant dense<5> : vector<5xindex>
388388
// CHECK-DAG: %[[VAL_6:.*]] = arith.constant dense<true> : vector<5xi1>
@@ -480,13 +480,14 @@ func.func @vectorize_nd_tensor_extract_block_arg(%arg0: tensor<5x6xf32>, %arg1:
480480
// CHECK-LABEL: func.func @vectorize_nd_tensor_extract_block_arg(
481481
// CHECK-SAME: %[[VAL_0:.*]]: tensor<5x6xf32>,
482482
// CHECK-SAME: %[[VAL_1:.*]]: tensor<5xindex>) -> tensor<5xf32> {
483+
// CHECK-DAG: %[[PAD:.*]] = ub.poison : index
483484
// CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : index
484485
// CHECK-DAG: %[[VAL_3:.*]] = arith.constant dense<[0, 1, 2, 3, 4]> : vector<5xindex>
485486
// CHECK-DAG: %[[VAL_4:.*]] = arith.constant dense<true> : vector<5xi1>
486487
// CHECK-DAG: %[[VAL_5:.*]] = arith.constant dense<0.000000e+00> : vector<5xf32>
487488
// CHECK-DAG: %[[VAL_6:.*]] = arith.constant dense<6> : vector<5xindex>
488489
// CHECK: %[[VAL_7:.*]] = tensor.empty() : tensor<5xf32>
489-
// CHECK: %[[VAL_8:.*]] = vector.transfer_read %[[VAL_1]]{{\[}}%[[VAL_2]]], %[[VAL_2]] {in_bounds = [true]} : tensor<5xindex>, vector<5xindex>
490+
// CHECK: %[[VAL_8:.*]] = vector.transfer_read %[[VAL_1]]{{\[}}%[[VAL_2]]], %[[PAD]] {in_bounds = [true]} : tensor<5xindex>, vector<5xindex>
490491
// CHECK: %[[VAL_9:.*]] = arith.muli %[[VAL_8]], %[[VAL_6]] : vector<5xindex>
491492
// CHECK: %[[VAL_10:.*]] = arith.addi %[[VAL_9]], %[[VAL_3]] : vector<5xindex>
492493
// CHECK: %[[VAL_11:.*]] = vector.gather %[[VAL_0]]{{\[}}%[[VAL_2]], %[[VAL_2]]] {{\[}}%[[VAL_10]]], %[[VAL_4]], %[[VAL_5]] : tensor<5x6xf32>, vector<5xindex>, vector<5xi1>, vector<5xf32> into vector<5xf32>
@@ -559,7 +560,7 @@ func.func @vectorize_nd_tensor_extract_scalar_broadcast(%src: tensor<3x3xf32>, %
559560
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
560561
// CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index
561562
// CHECK-DAG: %[[C2:.*]] = arith.constant 2 : index
562-
// CHECK-DAG: %[[PAD:.*]] = arith.constant 0.000000e+00 : f32
563+
// CHECK-DAG: %[[PAD:.*]] = ub.poison : f32
563564
// CHECK: %[[READ:.*]] = vector.transfer_read %[[SRC]][%[[C1]], %[[C2]]], %[[PAD]] : tensor<3x3xf32>, vector<f32>
564565
// CHECK: %[[READ_BCAST:.*]] = vector.broadcast %[[READ]] : vector<f32> to vector<1x1x3xf32>
565566
// CHECK: vector.transfer_write %[[READ_BCAST]], %[[INIT]][%[[C0]], %[[C0]], %[[C0]]] {in_bounds = [true, true, true]} : vector<1x1x3xf32>, tensor<1x1x3xf32>
@@ -583,7 +584,7 @@ func.func @extract_scalar_from_0d_into_0d(%src: tensor<f32>, %init: tensor<f32>)
583584
// CHECK-LABEL: func.func @extract_scalar_from_0d_into_0d(
584585
// CHECK-SAME: %[[SRC:.*]]: tensor<f32>,
585586
// CHECK-SAME: %[[INIT:.*]]: tensor<f32>) -> tensor<f32> {
586-
// CHECK: %[[PAD:.*]] = arith.constant 0.000000e+00 : f32
587+
// CHECK: %[[PAD:.*]] = ub.poison : f32
587588
// CHECK: %[[READ:.*]] = vector.transfer_read %[[SRC]][], %[[PAD]] : tensor<f32>, vector<f32>
588589
// CHECK: vector.transfer_write %[[READ]], %[[INIT]][] : vector<f32>, tensor<f32>
589590

@@ -606,7 +607,7 @@ func.func @extract_scalar_from_0d_into_1d(%src: tensor<f32>, %init: tensor<1xf32
606607
// CHECK-SAME: %[[SRC:.*]]: tensor<f32>,
607608
// CHECK-SAME: %[[INIT:.*]]: tensor<1xf32>) -> tensor<1xf32> {
608609
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
609-
// CHECK-DAG: %[[PAD:.*]] = arith.constant 0.000000e+00 : f32
610+
// CHECK-DAG: %[[PAD:.*]] = ub.poison : f32
610611
// CHECK: %[[READ:.*]] = vector.transfer_read %[[SRC]][], %[[PAD]] : tensor<f32>, vector<f32>
611612
// CHECK: %[[READ_BCAST:.*]] = vector.broadcast %[[READ]] : vector<f32> to vector<1xf32>
612613
// CHECK: vector.transfer_write %[[READ_BCAST]], %[[INIT]][%[[C0]]] {in_bounds = [true]} : vector<1xf32>, tensor<1xf32>
@@ -654,7 +655,7 @@ func.func @scalar_read_with_broadcast_from_column_tensor(%init: tensor<1x1x4xi32
654655

655656
// CHECK-LABEL: func.func @scalar_read_with_broadcast_from_column_tensor
656657
// CHECK-SAME: %[[INIT:.*]]: tensor<1x1x4xi32>) -> tensor<1x1x4xi32> {
657-
// CHECK-DAG: %[[PAD:.*]] = arith.constant 0 : i32
658+
// CHECK-DAG: %[[PAD:.*]] = ub.poison : i32
658659
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
659660
// CHECK-DAG: %[[SRC:.*]] = arith.constant dense<{{\[\[}}0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14]]> : tensor<15x1xi32>
660661
// CHECK: %[[READ:.*]] = vector.transfer_read %[[SRC]]{{\[}}%[[C0]], %[[C0]]], %[[PAD]] : tensor<15x1xi32>, vector<i32>
@@ -688,7 +689,7 @@ func.func @vectorize_nd_tensor_extract_transfer_read_basic_column(
688689
// CHECK-SAME: %[[SRC:.*]]: tensor<3x3x3xf32>,
689690
// CHECK-SAME: %[[INIT:.*]]: tensor<3x1x1xf32>)
690691
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
691-
// CHECK-DAG: %[[CST_0:.*]] = arith.constant 0.000000e+00 : f32
692-
// CHECK: %[[READ:.*]] = vector.transfer_read %[[SRC]][%[[C0]], %[[C0]], %[[C0]]], %[[CST_0]] : tensor<3x3x3xf32>, vector<f32>
692+
// CHECK-DAG: %[[PV:.*]] = ub.poison : f32
693+
// CHECK: %[[READ:.*]] = vector.transfer_read %[[SRC]][%[[C0]], %[[C0]], %[[C0]]], %[[PV]] : tensor<3x3x3xf32>, vector<f32>
693694
// CHECK: %[[READ_BCAST:.*]] = vector.broadcast %[[READ]] : vector<f32> to vector<3x1x1xf32>
694695
// CHECK: vector.transfer_write %[[READ_BCAST]], %[[INIT]]{{\[}}%[[C0]], %[[C0]], %[[C0]]] {in_bounds = [true, true, true]} : vector<3x1x1xf32>, tensor<3x1x1xf32>

mlir/test/Dialect/Linalg/vectorization/extract.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func.func @masked_dynamic_vectorize_nd_tensor_extract_with_affine_apply_gather(%
299299
// CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
300300
// CHECK: %[[VAL_7:.*]] = tensor.dim %[[VAL_2]], %[[VAL_6]] : tensor<?x?xf32>
301301
// CHECK: %[[VAL_8:.*]] = arith.constant 0 : index
302-
// CHECK: %[[VAL_9:.*]] = arith.constant 0.000000e+00 : f32
302+
// CHECK: %[[VAL_9:.*]] = ub.poison : f32
303303
// CHECK: %[[VAL_10:.*]] = vector.create_mask %[[VAL_5]], %[[VAL_7]] : vector<1x4xi1>
304304
// CHECK: %[[VAL_11:.*]] = vector.mask %[[VAL_10]] { vector.transfer_read %[[VAL_2]]{{\[}}%[[VAL_8]], %[[VAL_8]]], %[[VAL_9]] {in_bounds = [true, true]} : tensor<?x?xf32>, vector<1x4xf32> } : vector<1x4xi1> -> vector<1x4xf32>
305305
// CHECK: %[[VAL_12:.*]] = vector.step : vector<4xindex>
@@ -356,7 +356,7 @@ func.func @extract_masked_vectorize(%arg0: tensor<?x?xf32>, %arg1: tensor<?x?xf3
356356
// CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
357357
// CHECK: %[[VAL_7:.*]] = tensor.dim %[[VAL_1]], %[[VAL_6]] : tensor<?x?xf32>
358358
// CHECK: %[[VAL_8:.*]] = arith.constant 0 : index
359-
// CHECK: %[[VAL_9:.*]] = arith.constant 0.000000e+00 : f32
359+
// CHECK: %[[VAL_9:.*]] = ub.poison : f32
360360
// CHECK: %[[VAL_10:.*]] = vector.create_mask %[[VAL_5]], %[[VAL_7]] : vector<3x3xi1>
361361
// CHECK: %[[VAL_11:.*]] = vector.mask %[[VAL_10]] { vector.transfer_read %[[VAL_1]]{{\[}}%[[VAL_8]], %[[VAL_8]]], %[[VAL_9]] {in_bounds = [true, true]} : tensor<?x?xf32>, vector<3x3xf32> } : vector<3x3xi1> -> vector<3x3xf32>
362362
// CHECK: %[[VAL_12:.*]] = arith.constant dense<true> : vector<3x3xi1>
@@ -458,7 +458,7 @@ func.func @scalar_broadcast(%init : tensor<1x1x3xi32>, %src: tensor<1x3x2x4xi32>
458458
// CHECK: %[[MASK_RES:.*]] = vector.create_mask %[[C1]], %[[C1_2]], %[[C3]] : vector<1x1x4xi1>
459459

460460
/// Read and broadcast the scalar
461-
// CHECK: %[[PAD:.*]] = arith.constant 0 : i32
461+
// CHECK: %[[PAD:.*]] = ub.poison : i32
462462
// CHECK: %[[MASK_READ:.*]] = vector.constant_mask [1] : vector<1xi1>
463463
// CHECK: %[[READ:.*]] = vector.mask %[[MASK_READ]] {
464464
// CHECK-SAME: vector.transfer_read %[[SRC]]{{\[}}%[[IDX]], %[[IDX]], %[[IDX]], %[[IDX]]], %[[PAD]]

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ module attributes {transform.with_named_sequence} {
161161
// CHECK-SAME: %[[ARG_0:.*]]: tensor<f32>, %[[ARG_1:.*]]: tensor<f32>, %[[ARG_2:.*]]: tensor<f32>)
162162
func.func @generic_0d(%arg0: tensor<f32>, %arg1: tensor<f32>,
163163
%arg2: tensor<f32>) -> tensor<f32> {
164-
// CHECK: %[[PAD:.*]] = arith.constant 0.000000e+00 : f32
164+
// CHECK: %[[PAD:.*]] = ub.poison : f32
165165
// CHECK: %[[READ_0:.*]] = vector.transfer_read %[[ARG_0]][], %[[PAD]] : tensor<f32>, vector<f32>
166166
// CHECK: %[[ARG_0_AS_SCALAR:.*]] = vector.extract %[[READ_0]][] : f32 from vector<f32>
167167
// CHECK: %[[READ_1:.*]] = vector.transfer_read %[[ARG_1]][], %[[PAD]] : tensor<f32>, vector<f32>
@@ -770,11 +770,11 @@ module attributes {transform.with_named_sequence} {
770770
// CHECK-DAG: #[[$MAP3:.*]] = affine_map<(d0, d1) -> (d1, 0, d0, 0)>
771771
// CHECK: func @generic_vectorize_broadcast_transpose
772772
// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
773-
// CHECK-DAG: %[[CF:.*]] = arith.constant 0.000000e+00 : f32
774-
// CHECK: %[[V0:.*]] = vector.transfer_read %{{.*}}[%[[C0]], %[[C0]]], %[[CF]] {in_bounds = [true, true, true, true], permutation_map = #[[$MAP0]]} : memref<4x4xf32>, vector<4x4x4x4xf32>
775-
// CHECK: %[[V1:.*]] = vector.transfer_read %{{.*}}[%[[C0]]], %[[CF]] {in_bounds = [true, true, true, true], permutation_map = #[[$MAP1]]} : memref<4xf32>, vector<4x4x4x4xf32>
776-
// CHECK: %[[V2:.*]] = vector.transfer_read %{{.*}}[%[[C0]]], %[[CF]] {in_bounds = [true, true, true, true], permutation_map = #[[$MAP2]]} : memref<4xf32>, vector<4x4x4x4xf32>
777-
// CHECK: %[[V3:.*]] = vector.transfer_read %{{.*}}[%[[C0]], %[[C0]]], %[[CF]] {in_bounds = [true, true, true, true], permutation_map = #[[$MAP3]]} : memref<4x4xf32>, vector<4x4x4x4xf32>
773+
// CHECK-DAG: %[[PV:.*]] = ub.poison : f32
774+
// CHECK: %[[V0:.*]] = vector.transfer_read %{{.*}}[%[[C0]], %[[C0]]], %[[PV]] {in_bounds = [true, true, true, true], permutation_map = #[[$MAP0]]} : memref<4x4xf32>, vector<4x4x4x4xf32>
775+
// CHECK: %[[V1:.*]] = vector.transfer_read %{{.*}}[%[[C0]]], %[[PV]] {in_bounds = [true, true, true, true], permutation_map = #[[$MAP1]]} : memref<4xf32>, vector<4x4x4x4xf32>
776+
// CHECK: %[[V2:.*]] = vector.transfer_read %{{.*}}[%[[C0]]], %[[PV]] {in_bounds = [true, true, true, true], permutation_map = #[[$MAP2]]} : memref<4xf32>, vector<4x4x4x4xf32>
777+
// CHECK: %[[V3:.*]] = vector.transfer_read %{{.*}}[%[[C0]], %[[C0]]], %[[PV]] {in_bounds = [true, true, true, true], permutation_map = #[[$MAP3]]} : memref<4x4xf32>, vector<4x4x4x4xf32>
778778
// CHECK: %[[SUB:.*]] = arith.subf %[[V0]], %[[V1]] : vector<4x4x4x4xf32>
779779
// CHECK: %[[ADD0:.*]] = arith.addf %[[V2]], %[[SUB]] : vector<4x4x4x4xf32>
780780
// CHECK: %[[ADD1:.*]] = arith.addf %[[V3]], %[[ADD0]] : vector<4x4x4x4xf32>
@@ -1702,7 +1702,7 @@ module attributes {transform.with_named_sequence} {
17021702

17031703
// CHECK-LABEL: func.func @generic_with_reduction_and_broadcast(
17041704
// CHECK-SAME: %[[VAL_0:.*]]: tensor<1x12x197x197xf32>) -> tensor<1x12x197x1xf32> {
1705-
// CHECK: %[[VAL_1:.*]] = arith.constant 0.000000e+00 : f32
1705+
// CHECK: %[[VAL_1:.*]] = ub.poison : f32
17061706
// CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
17071707
// CHECK: %[[VAL_3:.*]] = tensor.empty() : tensor<1x12x197x1xf32>
17081708
// CHECK: %[[VAL_4:.*]] = vector.transfer_read %[[VAL_0]]{{\[}}%[[VAL_2]], %[[VAL_2]], %[[VAL_2]], %[[VAL_2]]], %[[VAL_1]] {in_bounds = [true, true, true, true]} : tensor<1x12x197x197xf32>, vector<1x12x197x197xf32>

0 commit comments

Comments
 (0)