From 28c4112f35af3161886da91134898954e261cefa Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Fri, 21 May 2021 14:08:22 -0700 Subject: [PATCH] Downgrade some emitErrors in patterns to notifyMatchFailure. PiperOrigin-RevId: 375160543 --- lib/Dialect/mhlo/transforms/legalize_to_linalg.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc b/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc index 5c8184d..3347137 100644 --- a/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc +++ b/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc @@ -245,10 +245,8 @@ class PointwiseToLinalgConverter : public OpConversionPattern { return fail(this->typeConverter->convertType(t) .template dyn_cast()); })) { - return emitError(loc, - "hlo to linalg conversion expects ranked args of " - "signless int, float or complex element type with ") - << nloops << " parallel iterators: " << *(op.getOperation()); + return rewriter.notifyMatchFailure( + op, "mismatched operand/result types or iterator count"); } // Construct the indexing maps needed for linalg.generic ops. @@ -1095,8 +1093,7 @@ class ReduceConverter : public OpConversionPattern { auto operand_shape = adaptor.inputs()[0].getType().template dyn_cast(); if (!operand_shape || !operand_shape.hasRank()) { - emitError(loc, "lhlo to linalg conversion expects known-rank args"); - return failure(); + return rewriter.notifyMatchFailure(reduce_op, "expects known-rank args"); } // First fill the output buffer with the init value. @@ -1216,8 +1213,7 @@ class SliceConverter : public OpConversionPattern { auto loc = slice_op.getLoc(); auto arg_type = args[0].getType().template dyn_cast(); if (!arg_type || !arg_type.hasRank()) { - emitError(loc, "lhlo to linalg conversion expects known-rank args"); - return failure(); + return rewriter.notifyMatchFailure(slice_op, "expects known-rank args"); } SmallVector offsets, sizes, strides;