-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[mlir][vector][nfc] Replace failure() with notifyMatchFailure()
#129278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
banach-space
merged 2 commits into
llvm:main
from
banach-space:andrzej/add_notify_match_failure
Mar 6, 2025
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -549,22 +549,26 @@ struct Strategy<TransferWriteOp> { | |
| }; | ||
|
|
||
| template <typename OpTy> | ||
| LogicalResult checkPrepareXferOp(OpTy xferOp, | ||
| VectorTransferToSCFOptions options) { | ||
| static LogicalResult checkPrepareXferOp(OpTy xferOp, PatternRewriter &rewriter, | ||
| VectorTransferToSCFOptions options) { | ||
| if (xferOp->hasAttr(kPassLabel)) | ||
| return failure(); | ||
| return rewriter.notifyMatchFailure( | ||
| xferOp, "kPassLabel is present (progressing lowering in progress)"); | ||
| if (xferOp.getVectorType().getRank() <= options.targetRank) | ||
| return failure(); | ||
| // Currently the unpacking of the leading dimension into the memref is not | ||
| // supported for scalable dimensions. | ||
| return rewriter.notifyMatchFailure( | ||
| xferOp, "xferOp vector rank <= transformation target rank"); | ||
| if (xferOp.getVectorType().getScalableDims().front()) | ||
| return failure(); | ||
| return rewriter.notifyMatchFailure( | ||
| xferOp, "Unpacking of the leading dimension into the memref is not yet " | ||
| "supported for scalable dims"); | ||
| if (isTensorOp(xferOp) && !options.lowerTensors) | ||
| return failure(); | ||
| // Transfer ops that modify the element type are not supported atm. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we retain this comment if it gives additional info?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I just moved the comment inside // BEFORE
// Transfer ops that modify the element type are not supported atm.
if (xferOp.getVectorType().getElementType() !=
xferOp.getShapedType().getElementType())
return failure();// AFTER
if (xferOp.getVectorType().getElementType() !=
xferOp.getShapedType().getElementType())
return rewriter.notifyMatchFailure(
xferOp, "Mismatching source and destination element types."); |
||
| return rewriter.notifyMatchFailure( | ||
| xferOp, "Unpacking for tensors has been disabled."); | ||
| if (xferOp.getVectorType().getElementType() != | ||
| xferOp.getShapedType().getElementType()) | ||
| return failure(); | ||
| return rewriter.notifyMatchFailure( | ||
| xferOp, "Mismatching source and destination element types."); | ||
|
|
||
| return success(); | ||
| } | ||
|
|
||
|
|
@@ -597,8 +601,9 @@ struct PrepareTransferReadConversion | |
|
|
||
| LogicalResult matchAndRewrite(TransferReadOp xferOp, | ||
| PatternRewriter &rewriter) const override { | ||
| if (checkPrepareXferOp(xferOp, options).failed()) | ||
| return failure(); | ||
| if (checkPrepareXferOp(xferOp, rewriter, options).failed()) | ||
| return rewriter.notifyMatchFailure( | ||
| xferOp, "checkPrepareXferOp conditions not met!"); | ||
|
|
||
| auto buffers = allocBuffers(rewriter, xferOp); | ||
| auto *newXfer = rewriter.clone(*xferOp.getOperation()); | ||
|
|
@@ -646,8 +651,9 @@ struct PrepareTransferWriteConversion | |
|
|
||
| LogicalResult matchAndRewrite(TransferWriteOp xferOp, | ||
| PatternRewriter &rewriter) const override { | ||
| if (checkPrepareXferOp(xferOp, options).failed()) | ||
| return failure(); | ||
| if (checkPrepareXferOp(xferOp, rewriter, options).failed()) | ||
| return rewriter.notifyMatchFailure( | ||
| xferOp, "checkPrepareXferOp conditions not met!"); | ||
|
|
||
| Location loc = xferOp.getLoc(); | ||
| auto buffers = allocBuffers(rewriter, xferOp); | ||
|
|
@@ -903,15 +909,17 @@ struct TransferOpConversion : public VectorToSCFPattern<OpTy> { | |
| LogicalResult matchAndRewrite(OpTy xferOp, | ||
| PatternRewriter &rewriter) const override { | ||
| if (!xferOp->hasAttr(kPassLabel)) | ||
| return failure(); | ||
| return rewriter.notifyMatchFailure( | ||
| xferOp, "kPassLabel is present (progressing lowering in progress)"); | ||
|
|
||
| // Find and cast data buffer. How the buffer can be found depends on OpTy. | ||
| ImplicitLocOpBuilder locB(xferOp.getLoc(), rewriter); | ||
| Value dataBuffer = Strategy<OpTy>::getBuffer(xferOp); | ||
| auto dataBufferType = dyn_cast<MemRefType>(dataBuffer.getType()); | ||
| FailureOr<MemRefType> castedDataType = unpackOneDim(dataBufferType); | ||
| if (failed(castedDataType)) | ||
| return failure(); | ||
| return rewriter.notifyMatchFailure(xferOp, | ||
| "Failed to unpack one vector dim."); | ||
|
|
||
| auto castedDataBuffer = | ||
| locB.create<vector::TypeCastOp>(*castedDataType, dataBuffer); | ||
|
|
@@ -1294,16 +1302,14 @@ struct UnrollTransferReadConversion | |
| xferOp, "vector rank is less or equal to target rank"); | ||
| if (failed(checkLowerTensors(xferOp, rewriter))) | ||
| return failure(); | ||
| // Transfer ops that modify the element type are not supported atm. | ||
| if (xferOp.getVectorType().getElementType() != | ||
| xferOp.getShapedType().getElementType()) | ||
| return rewriter.notifyMatchFailure( | ||
| xferOp, "not yet supported: element type mismatch"); | ||
| auto xferVecType = xferOp.getVectorType(); | ||
| if (xferVecType.getScalableDims()[0]) { | ||
| // Cannot unroll a scalable dimension at compile time. | ||
| return rewriter.notifyMatchFailure( | ||
| xferOp, "scalable dimensions cannot be unrolled"); | ||
| xferOp, "scalable dimensions cannot be unrolled at compile time"); | ||
| } | ||
|
|
||
| auto insertOp = getInsertOp(xferOp); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(progressing lowering in progress)maybe (vector-to-scf lowering in progress)?