Skip to content

Commit

Permalink
Fail to match if type cannot convert (instead of crash)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljfitz committed Mar 15, 2024
1 parent 2fa0e68 commit 9ea886f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Conversion/ONNXToTOSA/Tensor/Constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class ONNXConstOpLoweringToTOSA : public OpConversionPattern<ONNXConstantOp> {
op, "tosa.const does not support non-tensor types");
}
Type resultType = getTypeConverter()->convertType(op.getResult().getType());
if (! resultType) {
return rewriter.notifyMatchFailure(
op, "tosa.const does not support the requested type");
}
rewriter.replaceOpWithNewOp<mlir::tosa::ConstOp>(
op, resultType, currentAttr.cast<ElementsAttr>());
return success();
Expand Down

0 comments on commit 9ea886f

Please sign in to comment.