From beb3ea0819794a9d835142065643a489917c3994 Mon Sep 17 00:00:00 2001 From: Eric Kunze Date: Mon, 19 Sep 2022 14:30:51 -0700 Subject: Avoid crash when serializing unranked tensor Report an error instead during serialization. Change-Id: Ib53b1c76079909aaf84f643655939d024d7eec0c --- src/TosaSerialize.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/TosaSerialize.cpp b/src/TosaSerialize.cpp index 21c0f93..625a922 100644 --- a/src/TosaSerialize.cpp +++ b/src/TosaSerialize.cpp @@ -1558,6 +1558,11 @@ TosaSerializationBlockBuilder::BuildTosaSerializationTensor( mlir::RankedTensorType tensor = val.getType().dyn_cast(); + if (!tensor) { + llvm::errs() << "TOSA serialization, attempt to build an " + "non-RankedTensorType Tensor\n"; + return nullptr; + } std::vector shape(tensor.getShape().begin(), tensor.getShape().end()); DType type = Type2DType(tensor.getElementType()); -- cgit v1.2.1