diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp @@ -639,7 +639,8 @@ }); 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 @@ }); if (!didEncounterError) - return failure(); + return rewriter.notifyMatchFailure( + op, "unable to create linalg.generic body for reduce op"); SmallVector reassociationMap; uint64_t expandInputRank = @@ -1086,7 +1088,7 @@ 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 @@ // 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 @@ 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 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( loc, resultTy.getShape(), resultElementTy, dynamicDims); @@ -2149,7 +2154,8 @@ 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 dynamicDims = dynamicDimsOr.value(); auto resultElementTy = resultTy.getElementType();