Skip to content

Commit b09adbb

Browse files
committed
[mlir][vector] Relax the requirements on broadcast dims
NOTE: This is a follow-up for #97049 in which the `in_bounds` attribute was made mandatory. This PR updates the semantics of the `in_bounds` attribute so that broadcast dimensions are no longer required to be "in bounds". Specifically, these xfer_read/xfer_write Ops become valid after this change: ```mlir %read = vector.transfer_read %A[%base1, %base2], %pad {in_bounds = [false], permutation_map = affine_map<(d0, d1) -> (0)>} {permutation_map = affine_map<(d0, d1) -> (0)>} : memref<?x?xf32>, vector<9xf32> vector.transfer_write %vec, %A[%base1, %base2], {in_bounds = [false], permutation_map = affine_map<(d0, d1) -> (0)>} {permutation_map = affine_map<(d0, d1) -> (0)>} : vector<9xf32>, memref<?x?xf32> ``` Note that the value `false` merely means "may run out-of-bounds", i.e., the corresponding access can still be "in bounds". In fact, the folder for xfer Ops is also updated (*) and will update the attribute value corresponding to broadcast dims to `true`. Indeed, such dims would never be out-of-bounds in practice. Still, there's no need to require Op "users" to always set the corresponding `in_bounds` flag to `true. Note that this PR doesn't change any of the lowerings. The changes in "SuperVectorize.cpp", "Vectorization.cpp" and "AffineMap.cpp" are simple reverts of recent changes in #97049. Those were only meant to facilitate making `in_bounds` mandatory and to work around the extra requirements for broadcast dims (those requirements ere removed in this PR). All changes in tests are also reverts of changes from #97049. For context, here's a PR in which "broadcast" dims where forced to always be "in-bounds": * https://reviews.llvm.org/D102566 (*) See `foldTransferInBoundsAttribute`.
1 parent bb604ae commit b09adbb

File tree

20 files changed

+50
-101
lines changed

20 files changed

+50
-101
lines changed

mlir/include/mlir/Dialect/Vector/IR/VectorOps.td

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,12 +1405,12 @@ def Vector_TransferReadOp :
14051405
specifies if the transfer is guaranteed to be within the source bounds. If
14061406
set to "false", accesses (including the starting point) may run
14071407
out-of-bounds along the respective vector dimension as the index increases.
1408-
Non-vector and broadcast dimensions *must* always be in-bounds. The
1409-
`in_bounds` array length has to be equal to the vector rank. This attribute
1410-
has a default value: `false` (i.e. "out-of-bounds"). When skipped in the
1411-
textual IR, the default value is assumed. Similarly, the OP printer will
1412-
omit this attribute when all dimensions are out-of-bounds (i.e. the default
1413-
value is used).
1408+
Non-vector dimensions *must* always be in-bounds. The `in_bounds` array
1409+
length has to be equal to the vector rank. This attribute has a default
1410+
value: `false` (i.e. "out-of-bounds"). When skipped in the textual IR, the
1411+
default value is assumed. Similarly, the OP printer will omit this
1412+
attribute when all dimensions are out-of-bounds (i.e. the default value is
1413+
used).
14141414

14151415
A `vector.transfer_read` can be lowered to a simple load if all dimensions
14161416
are specified to be within bounds and no `mask` was specified.
@@ -1650,12 +1650,12 @@ def Vector_TransferWriteOp :
16501650
specifies if the transfer is guaranteed to be within the source bounds. If
16511651
set to "false", accesses (including the starting point) may run
16521652
out-of-bounds along the respective vector dimension as the index increases.
1653-
Non-vector and broadcast dimensions *must* always be in-bounds. The
1654-
`in_bounds` array length has to be equal to the vector rank. This attribute
1655-
has a default value: `false` (i.e. "out-of-bounds"). When skipped in the
1656-
textual IR, the default value is assumed. Similarly, the OP printer will
1657-
omit this attribute when all dimensions are out-of-bounds (i.e. the default
1658-
value is used).
1653+
Non-vector dimensions *must* always be in-bounds. The `in_bounds` array
1654+
length has to be equal to the vector rank. This attribute has a default
1655+
value: `false` (i.e. "out-of-bounds"). When skipped in the textual IR, the
1656+
default value is assumed. Similarly, the OP printer will omit this
1657+
attribute when all dimensions are out-of-bounds (i.e. the default value is
1658+
used).
16591659

16601660
A `vector.transfer_write` can be lowered to a simple store if all
16611661
dimensions are specified to be within bounds and no `mask` was specified.

mlir/include/mlir/IR/AffineMap.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,6 @@ class AffineMap {
146146
/// affine map (d0, ..., dn) -> (dp, ..., dn) on the most minor dimensions.
147147
bool isMinorIdentity() const;
148148

149-
/// Returns the list of broadcast dimensions (i.e. dims indicated by value 0
150-
/// in the result).
151-
/// Ex:
152-
/// * (d0, d1, d2) -> (0, d1) gives [0]
153-
/// * (d0, d1, d2) -> (d2, d1) gives []
154-
/// * (d0, d1, d2, d4) -> (d0, 0, d1, 0) gives [1, 3]
155-
SmallVector<unsigned> getBroadcastDims() const;
156-
157149
/// Returns true if this affine map is a minor identity up to broadcasted
158150
/// dimensions which are indicated by value 0 in the result. If
159151
/// `broadcastedDims` is not null, it will be populated with the indices of

mlir/include/mlir/Interfaces/VectorInterfaces.td

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,9 @@ def VectorTransferOpInterface : OpInterface<"VectorTransferOpInterface"> {
234234
return constExpr && constExpr.getValue() == 0;
235235
}
236236

237-
/// Return "true" if the vector transfer dimension `dim` is in-bounds. Also
238-
/// return "true" if the dimension is a broadcast dimension. Return "false"
239-
/// otherwise.
237+
/// Return "true" if the vector transfer dimension `dim` is in-bounds.
238+
/// Return "false" otherwise.
240239
bool isDimInBounds(unsigned dim) {
241-
if ($_op.isBroadcastDim(dim))
242-
return true;
243240
auto inBounds = $_op.getInBounds();
244241
return ::llvm::cast<::mlir::BoolAttr>(inBounds[dim]).getValue();
245242
}

mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,19 +1223,8 @@ static Operation *vectorizeAffineLoad(AffineLoadOp loadOp,
12231223
LLVM_DEBUG(dbgs() << "\n[early-vect]+++++ permutationMap: ");
12241224
LLVM_DEBUG(permutationMap.print(dbgs()));
12251225

1226-
// Make sure that the in_bounds attribute corresponding to a broadcast dim
1227-
// is set to `true` - that's required by the xfer Op.
1228-
// FIXME: We're not veryfying whether the corresponding access is in bounds.
1229-
// TODO: Use masking instead.
1230-
SmallVector<unsigned> broadcastedDims = permutationMap.getBroadcastDims();
1231-
SmallVector<bool> inBounds(vectorType.getRank(), false);
1232-
1233-
for (auto idx : broadcastedDims)
1234-
inBounds[idx] = true;
1235-
12361226
auto transfer = state.builder.create<vector::TransferReadOp>(
1237-
loadOp.getLoc(), vectorType, loadOp.getMemRef(), indices, permutationMap,
1238-
inBounds);
1227+
loadOp.getLoc(), vectorType, loadOp.getMemRef(), indices, permutationMap);
12391228

12401229
// Register replacement for future uses in the scope.
12411230
state.registerOpVectorReplacement(loadOp, transfer);

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,17 +1343,8 @@ vectorizeAsLinalgGeneric(RewriterBase &rewriter, VectorizationState &state,
13431343

13441344
SmallVector<Value> indices(linalgOp.getShape(opOperand).size(), zero);
13451345

1346-
// Make sure that the in_bounds attribute corresponding to a broadcast dim
1347-
// is `true`
1348-
SmallVector<unsigned> broadcastedDims = readMap.getBroadcastDims();
1349-
SmallVector<bool> inBounds(readType.getRank(), false);
1350-
1351-
for (auto idx : broadcastedDims)
1352-
inBounds[idx] = true;
1353-
13541346
Operation *read = rewriter.create<vector::TransferReadOp>(
1355-
loc, readType, opOperand->get(), indices, readMap,
1356-
ArrayRef<bool>(inBounds));
1347+
loc, readType, opOperand->get(), indices, readMap);
13571348
read = state.maskOperation(rewriter, read, linalgOp, maskingMap);
13581349
Value readValue = read->getResult(0);
13591350

mlir/lib/Dialect/Vector/IR/VectorOps.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,10 +3958,6 @@ verifyTransferOp(VectorTransferOpInterface op, ShapedType shapedType,
39583958
"as permutation_map results: ")
39593959
<< AffineMapAttr::get(permutationMap)
39603960
<< " vs inBounds of size: " << inBounds.size();
3961-
for (unsigned int i = 0, e = permutationMap.getNumResults(); i < e; ++i)
3962-
if (isa<AffineConstantExpr>(permutationMap.getResult(i)) &&
3963-
!llvm::cast<BoolAttr>(inBounds.getValue()[i]).getValue())
3964-
return op->emitOpError("requires broadcast dimensions to be in-bounds");
39653961

39663962
return success();
39673963
}
@@ -4150,17 +4146,24 @@ static LogicalResult foldTransferInBoundsAttribute(TransferOp op) {
41504146
SmallVector<bool, 4> newInBounds;
41514147
newInBounds.reserve(op.getTransferRank());
41524148
for (unsigned i = 0; i < op.getTransferRank(); ++i) {
4153-
// Already marked as in-bounds, nothing to see here.
4149+
// 1. Already marked as in-bounds, nothing to see here.
41544150
if (op.isDimInBounds(i)) {
41554151
newInBounds.push_back(true);
41564152
continue;
41574153
}
4158-
// Currently out-of-bounds, check whether we can statically determine it is
4159-
// inBounds.
4154+
// 2. Currently out-of-bounds, check whether we can statically determine it
4155+
// is inBounds.
4156+
bool inBounds = false;
41604157
auto dimExpr = dyn_cast<AffineDimExpr>(permutationMap.getResult(i));
4161-
assert(dimExpr && "Broadcast dims must be in-bounds");
4162-
auto inBounds =
4163-
isInBounds(op, /*resultIdx=*/i, /*indicesIdx=*/dimExpr.getPosition());
4158+
if (dimExpr) {
4159+
// 2.a Non-broadcast dim
4160+
inBounds = isInBounds(op, /*resultIdx=*/i,
4161+
/*indicesIdx=*/dimExpr.getPosition());
4162+
} else {
4163+
// 2.b Broadcast dim
4164+
inBounds = true;
4165+
}
4166+
41644167
newInBounds.push_back(inBounds);
41654168
// We commit the pattern if it is "more inbounds".
41664169
changed |= inBounds;

mlir/lib/IR/AffineMap.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,6 @@ bool AffineMap::isMinorIdentity() const {
158158
getMinorIdentityMap(getNumDims(), getNumResults(), getContext());
159159
}
160160

161-
SmallVector<unsigned> AffineMap::getBroadcastDims() const {
162-
SmallVector<unsigned> broadcastedDims;
163-
for (const auto &[resIdx, expr] : llvm::enumerate(getResults())) {
164-
if (auto constExpr = dyn_cast<AffineConstantExpr>(expr)) {
165-
if (constExpr.getValue() != 0)
166-
continue;
167-
broadcastedDims.push_back(resIdx);
168-
}
169-
}
170-
171-
return broadcastedDims;
172-
}
173-
174161
/// Returns true if this affine map is a minor identity up to broadcasted
175162
/// dimensions which are indicated by value 0 in the result.
176163
bool AffineMap::isMinorIdentityWithBroadcasting(

mlir/test/Conversion/VectorToSCF/vector-to-scf.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func.func @materialize_read(%M: index, %N: index, %O: index, %P: index) {
133133
affine.for %i1 = 0 to %N {
134134
affine.for %i2 = 0 to %O {
135135
affine.for %i3 = 0 to %P step 5 {
136-
%f = vector.transfer_read %A[%i0, %i1, %i2, %i3], %f0 {in_bounds = [false, true, false], permutation_map = affine_map<(d0, d1, d2, d3) -> (d3, 0, d0)>} : memref<?x?x?x?xf32>, vector<5x4x3xf32>
136+
%f = vector.transfer_read %A[%i0, %i1, %i2, %i3], %f0 {permutation_map = affine_map<(d0, d1, d2, d3) -> (d3, 0, d0)>} : memref<?x?x?x?xf32>, vector<5x4x3xf32>
137137
// Add a dummy use to prevent dead code elimination from removing
138138
// transfer read ops.
139139
"dummy_use"(%f) : (vector<5x4x3xf32>) -> ()
@@ -507,7 +507,7 @@ func.func @transfer_read_with_tensor(%arg: tensor<f32>) -> vector<1xf32> {
507507
// CHECK-NEXT: %[[RESULT:.*]] = vector.broadcast %[[EXTRACTED]] : f32 to vector<1xf32>
508508
// CHECK-NEXT: return %[[RESULT]] : vector<1xf32>
509509
%f0 = arith.constant 0.0 : f32
510-
%0 = vector.transfer_read %arg[], %f0 {in_bounds = [true], permutation_map = affine_map<()->(0)>} :
510+
%0 = vector.transfer_read %arg[], %f0 {permutation_map = affine_map<()->(0)>} :
511511
tensor<f32>, vector<1xf32>
512512
return %0: vector<1xf32>
513513
}
@@ -746,7 +746,7 @@ func.func @cannot_lower_transfer_read_with_leading_scalable(%arg0: memref<?x4xf3
746746
func.func @does_not_crash_on_unpack_one_dim(%subview: memref<1x1x1x1xi32>, %mask: vector<1x1xi1>) -> vector<1x1x1x1xi32> {
747747
%c0 = arith.constant 0 : index
748748
%c0_i32 = arith.constant 0 : i32
749-
%3 = vector.transfer_read %subview[%c0, %c0, %c0, %c0], %c0_i32, %mask {in_bounds = [false, true, true, false], permutation_map = #map1}
749+
%3 = vector.transfer_read %subview[%c0, %c0, %c0, %c0], %c0_i32, %mask {permutation_map = #map1}
750750
: memref<1x1x1x1xi32>, vector<1x1x1x1xi32>
751751
return %3 : vector<1x1x1x1xi32>
752752
}

mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func.func @vec1d_1(%A : memref<?x?xf32>, %B : memref<?x?x?xf32>) {
2222
// CHECK-NEXT: %{{.*}} = affine.apply #[[$map_id1]](%[[C0]])
2323
// CHECK-NEXT: %{{.*}} = affine.apply #[[$map_id1]](%[[C0]])
2424
// CHECK-NEXT: %{{.*}} = arith.constant 0.0{{.*}}: f32
25-
// CHECK-NEXT: {{.*}} = vector.transfer_read %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}} {in_bounds = [true], permutation_map = #[[$map_proj_d0d1_0]]} : memref<?x?xf32>, vector<128xf32>
25+
// CHECK-NEXT: {{.*}} = vector.transfer_read %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}} {permutation_map = #[[$map_proj_d0d1_0]]} : memref<?x?xf32>, vector<128xf32>
2626
affine.for %i0 = 0 to %M { // vectorized due to scalar -> vector
2727
%a0 = affine.load %A[%c0, %c0] : memref<?x?xf32>
2828
}
@@ -425,7 +425,7 @@ func.func @vec_rejected_8(%A : memref<?x?xf32>, %B : memref<?x?x?xf32>) {
425425
// CHECK: %{{.*}} = affine.apply #[[$map_id1]](%{{.*}})
426426
// CHECK: %{{.*}} = affine.apply #[[$map_id1]](%{{.*}})
427427
// CHECK: %{{.*}} = arith.constant 0.0{{.*}}: f32
428-
// CHECK: {{.*}} = vector.transfer_read %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}} {in_bounds = [true], permutation_map = #[[$map_proj_d0d1_0]]} : memref<?x?xf32>, vector<128xf32>
428+
// CHECK: {{.*}} = vector.transfer_read %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}} {permutation_map = #[[$map_proj_d0d1_0]]} : memref<?x?xf32>, vector<128xf32>
429429
affine.for %i17 = 0 to %M { // not vectorized, the 1-D pattern that matched %{{.*}} in DFS post-order prevents vectorizing %{{.*}}
430430
affine.for %i18 = 0 to %M { // vectorized due to scalar -> vector
431431
%a18 = affine.load %A[%c0, %c0] : memref<?x?xf32>
@@ -459,7 +459,7 @@ func.func @vec_rejected_9(%A : memref<?x?xf32>, %B : memref<?x?x?xf32>) {
459459
// CHECK: %{{.*}} = affine.apply #[[$map_id1]](%{{.*}})
460460
// CHECK-NEXT: %{{.*}} = affine.apply #[[$map_id1]](%{{.*}})
461461
// CHECK-NEXT: %{{.*}} = arith.constant 0.0{{.*}}: f32
462-
// CHECK-NEXT: {{.*}} = vector.transfer_read %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}} {in_bounds = [true], permutation_map = #[[$map_proj_d0d1_0]]} : memref<?x?xf32>, vector<128xf32>
462+
// CHECK-NEXT: {{.*}} = vector.transfer_read %{{.*}}[%{{.*}}, %{{.*}}], %{{.*}} {permutation_map = #[[$map_proj_d0d1_0]]} : memref<?x?xf32>, vector<128xf32>
463463
affine.for %i17 = 0 to %M { // not vectorized, the 1-D pattern that matched %i18 in DFS post-order prevents vectorizing %{{.*}}
464464
affine.for %i18 = 0 to %M { // vectorized due to scalar -> vector
465465
%a18 = affine.load %A[%c0, %c0] : memref<?x?xf32>

mlir/test/Dialect/Affine/SuperVectorize/vectorize_2d.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ func.func @vectorize_matmul(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg
123123
// VECT: affine.for %[[I2:.*]] = #[[$map_id1]](%[[C0]]) to #[[$map_id1]](%[[M]]) step 4 {
124124
// VECT-NEXT: affine.for %[[I3:.*]] = #[[$map_id1]](%[[C0]]) to #[[$map_id1]](%[[N]]) step 8 {
125125
// VECT-NEXT: affine.for %[[I4:.*]] = #[[$map_id1]](%[[C0]]) to #[[$map_id1]](%[[K]]) {
126-
// VECT: %[[A:.*]] = vector.transfer_read %{{.*}}[%[[I4]], %[[I3]]], %{{.*}} {in_bounds = [true, false], permutation_map = #[[$map_proj_d0d1_zerod1]]} : memref<?x?xf32>, vector<4x8xf32>
127-
// VECT: %[[B:.*]] = vector.transfer_read %{{.*}}[%[[I2]], %[[I4]]], %{{.*}} {in_bounds = [false, true], permutation_map = #[[$map_proj_d0d1_d0zero]]} : memref<?x?xf32>, vector<4x8xf32>
126+
// VECT: %[[A:.*]] = vector.transfer_read %{{.*}}[%[[I4]], %[[I3]]], %{{.*}} {permutation_map = #[[$map_proj_d0d1_zerod1]]} : memref<?x?xf32>, vector<4x8xf32>
127+
// VECT: %[[B:.*]] = vector.transfer_read %{{.*}}[%[[I2]], %[[I4]]], %{{.*}} {permutation_map = #[[$map_proj_d0d1_d0zero]]} : memref<?x?xf32>, vector<4x8xf32>
128128
// VECT-NEXT: %[[C:.*]] = arith.mulf %[[B]], %[[A]] : vector<4x8xf32>
129129
// VECT: %[[D:.*]] = vector.transfer_read %{{.*}}[%[[I2]], %[[I3]]], %{{.*}} : memref<?x?xf32>, vector<4x8xf32>
130130
// VECT-NEXT: %[[E:.*]] = arith.addf %[[D]], %[[C]] : vector<4x8xf32>

mlir/test/Dialect/Affine/SuperVectorize/vectorize_affine_apply.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func.func @affine_map_with_expr_2(%arg0: memref<8x12x16xf32>, %arg1: memref<8x24
141141
// CHECK-NEXT: %[[S1:.*]] = affine.apply #[[$MAP_ID4]](%[[ARG3]], %[[ARG4]], %[[I0]])
142142
// CHECK-NEXT: %[[S2:.*]] = affine.apply #[[$MAP_ID5]](%[[ARG3]], %[[ARG4]], %[[I0]])
143143
// CHECK-NEXT: %[[CST:.*]] = arith.constant 0.000000e+00 : f32
144-
// CHECK-NEXT: %[[S3:.*]] = vector.transfer_read %[[ARG0]][%[[S0]], %[[S1]], %[[S2]]], %[[CST]] {in_bounds = [true], permutation_map = #[[$MAP_ID6]]} : memref<8x12x16xf32>, vector<8xf32>
144+
// CHECK-NEXT: %[[S3:.*]] = vector.transfer_read %[[ARG0]][%[[S0]], %[[S1]], %[[S2]]], %[[CST]] {permutation_map = #[[$MAP_ID6]]} : memref<8x12x16xf32>, vector<8xf32>
145145
// CHECK-NEXT: vector.transfer_write %[[S3]], %[[ARG1]][%[[ARG3]], %[[ARG4]], %[[ARG5]]] : vector<8xf32>, memref<8x24x48xf32>
146146
// CHECK-NEXT: }
147147
// CHECK-NEXT: }

mlir/test/Dialect/Linalg/hoisting.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func.func @hoist_vector_transfer_pairs_in_affine_loops(%memref0: memref<64x64xi3
200200
affine.for %arg3 = 0 to 64 {
201201
affine.for %arg4 = 0 to 64 step 16 {
202202
affine.for %arg5 = 0 to 64 {
203-
%0 = vector.transfer_read %memref0[%arg3, %arg5], %c0_i32 {in_bounds = [true], permutation_map = affine_map<(d0, d1) -> (0)>} : memref<64x64xi32>, vector<16xi32>
203+
%0 = vector.transfer_read %memref0[%arg3, %arg5], %c0_i32 {permutation_map = affine_map<(d0, d1) -> (0)>} : memref<64x64xi32>, vector<16xi32>
204204
%1 = vector.transfer_read %memref1[%arg5, %arg4], %c0_i32 : memref<64x64xi32>, vector<16xi32>
205205
%2 = vector.transfer_read %memref2[%arg3, %arg4], %c0_i32 : memref<64x64xi32>, vector<16xi32>
206206
%3 = arith.muli %0, %1 : vector<16xi32>

mlir/test/Dialect/Linalg/vectorization.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func.func @vectorize_dynamic_1d_broadcast(%arg0: tensor<?xf32>,
130130
// CHECK-LABEL: @vectorize_dynamic_1d_broadcast
131131
// CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
132132
// CHECK: %[[VAL_4:.*]] = tensor.dim %{{.*}}, %[[VAL_3]] : tensor<?xf32>
133-
// CHECK: %[[VAL_7:.*]] = vector.transfer_read %{{.*}} {in_bounds = {{.*}}, permutation_map = #{{.*}}} : tensor<?xf32>, vector<4xf32>
133+
// CHECK: %[[VAL_7:.*]] = vector.transfer_read %{{.*}} {permutation_map = #{{.*}}} : tensor<?xf32>, vector<4xf32>
134134
// CHECK: %[[VAL_9:.*]] = vector.create_mask %[[VAL_4]] : vector<4xi1>
135135
// CHECK: %[[VAL_10:.*]] = vector.mask %[[VAL_9]] { vector.transfer_read %{{.*}} {in_bounds = [true]} : tensor<?xf32>, vector<4xf32> } : vector<4xi1> -> vector<4xf32>
136136
// CHECK: %[[VAL_12:.*]] = vector.mask %[[VAL_9]] { vector.transfer_read %{{.*}} {in_bounds = [true]} : tensor<?xf32>, vector<4xf32> } : vector<4xi1> -> vector<4xf32>

mlir/test/Dialect/Vector/invalid.mlir

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -484,16 +484,6 @@ func.func @test_vector.transfer_read(%arg0: memref<?x?xvector<2x3xf32>>) {
484484

485485
// -----
486486

487-
func.func @test_vector.transfer_read(%arg0: memref<?x?xvector<2x3xf32>>) {
488-
%c3 = arith.constant 3 : index
489-
%f0 = arith.constant 0.0 : f32
490-
%vf0 = vector.splat %f0 : vector<2x3xf32>
491-
// expected-error@+1 {{requires broadcast dimensions to be in-bounds}}
492-
%0 = vector.transfer_read %arg0[%c3, %c3], %vf0 {in_bounds = [false, true], permutation_map = affine_map<(d0, d1)->(0, d1)>} : memref<?x?xvector<2x3xf32>>, vector<1x1x2x3xf32>
493-
}
494-
495-
// -----
496-
497487
func.func @test_vector.transfer_read(%arg0: memref<?x?xvector<2x3xf32>>) {
498488
%c3 = arith.constant 3 : index
499489
%f0 = arith.constant 0.0 : f32

mlir/test/Dialect/Vector/ops.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func.func @vector_transfer_ops(%arg0: memref<?x?xf32>,
7070
// CHECK: vector.transfer_read %{{.*}}[%[[C3]], %[[C3]]], %{{.*}}, %{{.*}} : memref<?x?xf32>, vector<5xf32>
7171
%8 = vector.transfer_read %arg0[%c3, %c3], %f0, %m : memref<?x?xf32>, vector<5xf32>
7272
// CHECK: vector.transfer_read %{{.*}}[%[[C3]], %[[C3]], %[[C3]]], %{{.*}}, %{{.*}} : memref<?x?x?xf32>, vector<5x4x8xf32>
73-
%9 = vector.transfer_read %arg4[%c3, %c3, %c3], %f0, %m2 {in_bounds = [false, false, true], permutation_map = affine_map<(d0, d1, d2)->(d1, d0, 0)>} : memref<?x?x?xf32>, vector<5x4x8xf32>
73+
%9 = vector.transfer_read %arg4[%c3, %c3, %c3], %f0, %m2 {permutation_map = affine_map<(d0, d1, d2)->(d1, d0, 0)>} : memref<?x?x?xf32>, vector<5x4x8xf32>
7474

7575
// CHECK: vector.transfer_write
7676
vector.transfer_write %0, %arg0[%c3, %c3] {permutation_map = affine_map<(d0, d1)->(d0)>} : vector<128xf32>, memref<?x?xf32>

mlir/test/Dialect/Vector/vector-transfer-permutation-lowering.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func.func @permutation_with_mask_xfer_read_scalable(%mem: memref<?x?xf32>, %dim_
228228
func.func @masked_permutation_xfer_read_fixed_width(%arg0: tensor<?x1xf32>, %mask : vector<4x1xi1>) {
229229
%cst = arith.constant 0.000000e+00 : f32
230230
%c0 = arith.constant 0 : index
231-
%3 = vector.mask %mask { vector.transfer_read %arg0[%c0, %c0], %cst {in_bounds = [false, true, false], permutation_map = affine_map<(d0, d1) -> (d1, 0, d0)>} : tensor<?x1xf32>, vector<1x4x4xf32> } : vector<4x1xi1> -> vector<1x4x4xf32>
231+
%3 = vector.mask %mask { vector.transfer_read %arg0[%c0, %c0], %cst {permutation_map = affine_map<(d0, d1) -> (d1, 0, d0)>} : tensor<?x1xf32>, vector<1x4x4xf32> } : vector<4x1xi1> -> vector<1x4x4xf32>
232232
call @test.some_use(%3) : (vector<1x4x4xf32>) -> ()
233233
return
234234
}

mlir/test/Dialect/Vector/vector-transfer-unroll.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func.func @transfer_read_unroll_permutation(%arg0 : memref<6x4xf32>) -> vector<4
199199
func.func @transfer_read_unroll_broadcast(%arg0 : memref<6x4xf32>) -> vector<6x4xf32> {
200200
%c0 = arith.constant 0 : index
201201
%cf0 = arith.constant 0.0 : f32
202-
%0 = vector.transfer_read %arg0[%c0, %c0], %cf0 {in_bounds = [true, false], permutation_map = #map0} : memref<6x4xf32>, vector<6x4xf32>
202+
%0 = vector.transfer_read %arg0[%c0, %c0], %cf0 {permutation_map = #map0} : memref<6x4xf32>, vector<6x4xf32>
203203
return %0 : vector<6x4xf32>
204204
}
205205

@@ -226,7 +226,7 @@ func.func @transfer_read_unroll_broadcast(%arg0 : memref<6x4xf32>) -> vector<6x4
226226
func.func @transfer_read_unroll_broadcast_permuation(%arg0 : memref<6x4xf32>) -> vector<4x6xf32> {
227227
%c0 = arith.constant 0 : index
228228
%cf0 = arith.constant 0.0 : f32
229-
%0 = vector.transfer_read %arg0[%c0, %c0], %cf0 {in_bounds = [true, false], permutation_map = #map0} : memref<6x4xf32>, vector<4x6xf32>
229+
%0 = vector.transfer_read %arg0[%c0, %c0], %cf0 {permutation_map = #map0} : memref<6x4xf32>, vector<4x6xf32>
230230
return %0 : vector<4x6xf32>
231231
}
232232

0 commit comments

Comments
 (0)