Skip to content

Commit c634746

Browse files
committed
[mlir][linalg] Fix the semantic use of a flag
`useInBoundsInsteadOfMasking` was doing the opposite i.e., when set to true; was updating the mask instead of updating the inBounds.
1 parent deafb36 commit c634746

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ bool isLinearizableVector(VectorType type);
194194
/// for each dimension of the passed in tensor.
195195
Value createReadOrMaskedRead(OpBuilder &builder, Location loc, Value source,
196196
ArrayRef<int64_t> readShape, Value padValue,
197-
bool useInBoundsInsteadOfMasking = true);
197+
bool useInBoundsInsteadOfMasking = false);
198198

199199
/// Returns success if `inputVectorSizes` is a valid masking configuraion for
200200
/// given `shape`, i.e., it meets:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,11 +1499,11 @@ vectorizeAsTensorPackOp(RewriterBase &rewriter, tensor::PackOp packOp,
14991499
// If the input vector sizes are not provided, then the vector sizes are
15001500
// determined by the result tensor shape. In case the vector sizes aren't
15011501
// provided, we update the inBounds attribute instead of masking.
1502-
bool useInBoundsInsteadOfMasking = true;
1502+
bool useInBoundsInsteadOfMasking = false;
15031503
if (inputVectorSizes.empty()) {
15041504
ArrayRef<int64_t> resultTensorShape = packOp.getDestType().getShape();
15051505
inputVectorSizes = resultTensorShape.take_front(packOp.getSourceRank());
1506-
useInBoundsInsteadOfMasking = false;
1506+
useInBoundsInsteadOfMasking = true;
15071507
}
15081508

15091509
// Create masked TransferReadOp.

mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ Value vector::createReadOrMaskedRead(OpBuilder &builder, Location loc,
345345
int64_t readRank = readShape.size();
346346
auto zero = builder.create<arith::ConstantIndexOp>(loc, 0);
347347
SmallVector<bool> inBoundsVal(readRank, true);
348-
if (!useInBoundsInsteadOfMasking) {
348+
if (useInBoundsInsteadOfMasking) {
349349
// Update the inBounds attribute.
350350
for (unsigned i = 0; i < readRank; i++)
351351
inBoundsVal[i] = (sourceShape[i] == readShape[i]) &&
@@ -359,7 +359,7 @@ Value vector::createReadOrMaskedRead(OpBuilder &builder, Location loc,
359359
/*padding=*/padValue,
360360
/*inBounds=*/inBoundsVal);
361361

362-
if (llvm::equal(readShape, sourceShape) || !useInBoundsInsteadOfMasking)
362+
if (llvm::equal(readShape, sourceShape) || useInBoundsInsteadOfMasking)
363363
return transferReadOp;
364364
SmallVector<OpFoldResult> mixedSourceDims =
365365
tensor::getMixedSizes(builder, loc, source);

0 commit comments

Comments
 (0)