From 791684ee19f14ae9fb53334499e830a91a9459d1 Mon Sep 17 00:00:00 2001 From: Liam Fitzpatrick Date: Fri, 15 Mar 2024 00:19:44 +0000 Subject: [PATCH] Fail to match if type cannot convert (instead of crash) --- src/Conversion/ONNXToTOSA/Tensor/Constant.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Conversion/ONNXToTOSA/Tensor/Constant.cpp b/src/Conversion/ONNXToTOSA/Tensor/Constant.cpp index 0af623c4ce..07547e6146 100644 --- a/src/Conversion/ONNXToTOSA/Tensor/Constant.cpp +++ b/src/Conversion/ONNXToTOSA/Tensor/Constant.cpp @@ -44,6 +44,10 @@ class ONNXConstOpLoweringToTOSA : public OpConversionPattern { 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( op, resultType, currentAttr.cast()); return success();