Skip to content

Commit 43df98c

Browse files
committed
[mlir][vector][nfc] Replace failure() with notifyMatchFailure()
Updates some instances of plain `return failure();` in VectorToSCF.cpp with `return notifyMatchFailure();` and a description (usually copied from the nearby comment). There's many more "plain" `return failure();` left, but I ATM I only have the cycles for the ones updated here.
1 parent 1aea024 commit 43df98c

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -549,22 +549,25 @@ struct Strategy<TransferWriteOp> {
549549
};
550550

551551
template <typename OpTy>
552-
LogicalResult checkPrepareXferOp(OpTy xferOp,
553-
VectorTransferToSCFOptions options) {
552+
static LogicalResult checkPrepareXferOp(OpTy xferOp, PatternRewriter &rewriter,
553+
VectorTransferToSCFOptions options) {
554554
if (xferOp->hasAttr(kPassLabel))
555-
return failure();
555+
return rewriter.notifyMatchFailure(xferOp, "kPassLabel is present!");
556556
if (xferOp.getVectorType().getRank() <= options.targetRank)
557-
return failure();
558-
// Currently the unpacking of the leading dimension into the memref is not
559-
// supported for scalable dimensions.
557+
return rewriter.notifyMatchFailure(
558+
xferOp, "xferOp vector rank <= transformation target rank");
560559
if (xferOp.getVectorType().getScalableDims().front())
561-
return failure();
560+
return rewriter.notifyMatchFailure(
561+
xferOp, "Unpacking of the leading dimension into the memref is not yet "
562+
"supported for scalable dims");
562563
if (isTensorOp(xferOp) && !options.lowerTensors)
563-
return failure();
564-
// Transfer ops that modify the element type are not supported atm.
564+
return rewriter.notifyMatchFailure(
565+
xferOp, "Unpacking for tensors has been disabled.");
565566
if (xferOp.getVectorType().getElementType() !=
566567
xferOp.getShapedType().getElementType())
567-
return failure();
568+
return rewriter.notifyMatchFailure(
569+
xferOp, "Mismatching source and destination element types.");
570+
568571
return success();
569572
}
570573

@@ -597,8 +600,9 @@ struct PrepareTransferReadConversion
597600

598601
LogicalResult matchAndRewrite(TransferReadOp xferOp,
599602
PatternRewriter &rewriter) const override {
600-
if (checkPrepareXferOp(xferOp, options).failed())
601-
return failure();
603+
if (checkPrepareXferOp(xferOp, rewriter, options).failed())
604+
return rewriter.notifyMatchFailure(
605+
xferOp, "checkPrepareXferOp conditions not met!");
602606

603607
auto buffers = allocBuffers(rewriter, xferOp);
604608
auto *newXfer = rewriter.clone(*xferOp.getOperation());
@@ -646,8 +650,9 @@ struct PrepareTransferWriteConversion
646650

647651
LogicalResult matchAndRewrite(TransferWriteOp xferOp,
648652
PatternRewriter &rewriter) const override {
649-
if (checkPrepareXferOp(xferOp, options).failed())
650-
return failure();
653+
if (checkPrepareXferOp(xferOp, rewriter, options).failed())
654+
return rewriter.notifyMatchFailure(
655+
xferOp, "checkPrepareXferOp conditions not met!");
651656

652657
Location loc = xferOp.getLoc();
653658
auto buffers = allocBuffers(rewriter, xferOp);
@@ -1294,16 +1299,14 @@ struct UnrollTransferReadConversion
12941299
xferOp, "vector rank is less or equal to target rank");
12951300
if (failed(checkLowerTensors(xferOp, rewriter)))
12961301
return failure();
1297-
// Transfer ops that modify the element type are not supported atm.
12981302
if (xferOp.getVectorType().getElementType() !=
12991303
xferOp.getShapedType().getElementType())
13001304
return rewriter.notifyMatchFailure(
13011305
xferOp, "not yet supported: element type mismatch");
13021306
auto xferVecType = xferOp.getVectorType();
13031307
if (xferVecType.getScalableDims()[0]) {
1304-
// Cannot unroll a scalable dimension at compile time.
13051308
return rewriter.notifyMatchFailure(
1306-
xferOp, "scalable dimensions cannot be unrolled");
1309+
xferOp, "scalable dimensions cannot be unrolled at compile time");
13071310
}
13081311

13091312
auto insertOp = getInsertOp(xferOp);

0 commit comments

Comments
 (0)