[Mlir-commits] [mlir] d246bf4 - mlir/TosaToLinalg: improve debugging during conversion
Rob Suderman
llvmlistbot at llvm.org
Mon Dec 5 11:46:04 PST 2022
Author: Ramkumar Ramachandra
Date: 2022-12-05T11:40:08-08:00
New Revision: d246bf4199e9c7030c62e34b704fe8c824152e41
URL: https://github.com/llvm/llvm-project/commit/d246bf4199e9c7030c62e34b704fe8c824152e41
DIFF: https://github.com/llvm/llvm-project/commit/d246bf4199e9c7030c62e34b704fe8c824152e41.diff
LOG: mlir/TosaToLinalg: improve debugging during conversion
Make systematic use of notifyMatchFailure.
Signed-off-by: Ramkumar Ramachandra <r at artagnon.com>
Reviewed By: rsuderman
Differential Revision: https://reviews.llvm.org/D139190
Added:
Modified:
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index 839dfb4d0d034..ab21055422d36 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -639,7 +639,8 @@ elementwiseMatchAndRewriteHelper(Operation *operation,
});
if (didEncounterError)
- return failure();
+ return rewriter.notifyMatchFailure(
+ operation, "unable to create linalg.generic body for elementwise op");
rewriter.replaceOp(operation, linalgOp->getResults());
return success();
@@ -816,7 +817,8 @@ static LogicalResult reduceMatchAndRewriteHelper(Operation *op, uint64_t axis,
});
if (!didEncounterError)
- return failure();
+ return rewriter.notifyMatchFailure(
+ op, "unable to create linalg.generic body for reduce op");
SmallVector<ReassociationExprs, 4> reassociationMap;
uint64_t expandInputRank =
@@ -1086,7 +1088,7 @@ class TransposeConverter : public OpRewritePattern<tosa::TransposeOp> {
PatternRewriter &rewriter) const final {
DenseIntElementsAttr perms;
if (!matchPattern(op.getPerms(), m_Constant(&perms))) {
- return failure();
+ return rewriter.notifyMatchFailure(op, "unmatched permutation tensor");
}
auto loc = op.getLoc();
@@ -1348,7 +1350,8 @@ class BroadcastResizeConverter : public OpRewritePattern<tosa::ResizeOp> {
// TODO(suderman): These string values should be declared the TOSA dialect.
if (op.getMode() != "NEAREST_NEIGHBOR" && op.getMode() != "BILINEAR")
- return failure();
+ return rewriter.notifyMatchFailure(
+ op, "tosa.resize mode should be NEAREST_NEIGHBOR or BILINEAR");
const bool isBilinear = op.getMode() == "BILINEAR";
@@ -1439,11 +1442,13 @@ class GenericResizeConverter : public OpRewritePattern<tosa::ResizeOp> {
auto dynamicDimsOr =
checkHasDynamicBatchDims(rewriter, op, {input, op.getOutput()});
if (!dynamicDimsOr.has_value())
- return failure();
+ return rewriter.notifyMatchFailure(
+ op, "unable to get dynamic dimensions of tosa.resize");
SmallVector<Value> dynamicDims = dynamicDimsOr.value();
if (op.getMode() != "NEAREST_NEIGHBOR" && op.getMode() != "BILINEAR")
- return failure();
+ return rewriter.notifyMatchFailure(
+ op, "tosa.resize mode should be NEAREST_NEIGHBOR or BILINEAR");
auto emptyTensor = rewriter.create<tensor::EmptyOp>(
loc, resultTy.getShape(), resultElementTy, dynamicDims);
@@ -2149,7 +2154,8 @@ class GatherConverter : public OpConversionPattern<tosa::GatherOp> {
auto dynamicDimsOr = checkHasDynamicBatchDims(
rewriter, op, {input, indices, op.getOutput()});
if (!dynamicDimsOr.has_value())
- return failure();
+ return rewriter.notifyMatchFailure(
+ op, "tosa.gather currently only supports dynamic batch dimensions");
SmallVector<Value> dynamicDims = dynamicDimsOr.value();
auto resultElementTy = resultTy.getElementType();
More information about the Mlir-commits
mailing list