Downgrade some emitErrors in patterns to notifyMatchFailure.

PiperOrigin-RevId: 375160543
This commit is contained in:
Stella Laurenzo 2021-05-21 14:08:22 -07:00 committed by TensorFlow MLIR Team
parent 1ba4c714c9
commit 28c4112f35
1 changed files with 4 additions and 8 deletions

View File

@ -245,10 +245,8 @@ class PointwiseToLinalgConverter : public OpConversionPattern<OpTy> {
return fail(this->typeConverter->convertType(t) return fail(this->typeConverter->convertType(t)
.template dyn_cast<ShapedType>()); .template dyn_cast<ShapedType>());
})) { })) {
return emitError(loc, return rewriter.notifyMatchFailure(
"hlo to linalg conversion expects ranked args of " op, "mismatched operand/result types or iterator count");
"signless int, float or complex element type with ")
<< nloops << " parallel iterators: " << *(op.getOperation());
} }
// Construct the indexing maps needed for linalg.generic ops. // Construct the indexing maps needed for linalg.generic ops.
@ -1095,8 +1093,7 @@ class ReduceConverter : public OpConversionPattern<lmhlo::ReduceOp> {
auto operand_shape = auto operand_shape =
adaptor.inputs()[0].getType().template dyn_cast<ShapedType>(); adaptor.inputs()[0].getType().template dyn_cast<ShapedType>();
if (!operand_shape || !operand_shape.hasRank()) { if (!operand_shape || !operand_shape.hasRank()) {
emitError(loc, "lhlo to linalg conversion expects known-rank args"); return rewriter.notifyMatchFailure(reduce_op, "expects known-rank args");
return failure();
} }
// First fill the output buffer with the init value. // First fill the output buffer with the init value.
@ -1216,8 +1213,7 @@ class SliceConverter : public OpConversionPattern<OpTy> {
auto loc = slice_op.getLoc(); auto loc = slice_op.getLoc();
auto arg_type = args[0].getType().template dyn_cast<ShapedType>(); auto arg_type = args[0].getType().template dyn_cast<ShapedType>();
if (!arg_type || !arg_type.hasRank()) { if (!arg_type || !arg_type.hasRank()) {
emitError(loc, "lhlo to linalg conversion expects known-rank args"); return rewriter.notifyMatchFailure(slice_op, "expects known-rank args");
return failure();
} }
SmallVector<OpFoldResult, 3> offsets, sizes, strides; SmallVector<OpFoldResult, 3> offsets, sizes, strides;