aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Kunze <eric.kunze@arm.com>2022-09-19 14:30:51 -0700
committerEric Kunze <eric.kunze@arm.com>2022-10-24 13:58:46 -0700
commitbeb3ea0819794a9d835142065643a489917c3994 (patch)
tree09c6e54e4f49a1006ba243ce16523777a7203280
parent5e4073f63247b6d63a0937df8764714d45cd5974 (diff)
downloadtosa_mlir_translator-beb3ea0819794a9d835142065643a489917c3994.tar.gz
Avoid crash when serializing unranked tensor
Report an error instead during serialization. Change-Id: Ib53b1c76079909aaf84f643655939d024d7eec0c
-rw-r--r--src/TosaSerialize.cpp5
1 files changed, 5 insertions, 0 deletions
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<mlir::RankedTensorType>();
+ if (!tensor) {
+ llvm::errs() << "TOSA serialization, attempt to build an "
+ "non-RankedTensorType Tensor\n";
+ return nullptr;
+ }
std::vector<int32_t> shape(tensor.getShape().begin(),
tensor.getShape().end());
DType type = Type2DType(tensor.getElementType());