diff options
author | Dmitriy Smirnov <dmitriy.smirnov@arm.com> | 2023-01-06 19:22:08 +0000 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2023-03-02 16:17:47 +0000 |
commit | 5412590a0e4ddb731c04b1c6fe03690e28ef3e27 (patch) | |
tree | ab56082e965e960271a30cdd11a99e7e40c62b6a /src | |
parent | cbedb765fd7c54c55599bf164c065eb2a2085451 (diff) | |
download | tosa_mlir_translator-5412590a0e4ddb731c04b1c6fe03690e28ef3e27.tar.gz |
Added support of unranked tensors
Added support of unranked tensors
to TosaSerializationBlockBuilder::BuildTosaSerializationTensor
method
Signed-off-by: Dmitriy Smirnov <dmitriy.smirnov@arm.com>
Change-Id: Ia691437b7571f01a4b964a286c6d844eed80af75
Diffstat (limited to 'src')
-rw-r--r-- | src/TosaSerialize.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/TosaSerialize.cpp b/src/TosaSerialize.cpp index 547da8c..e69fcba 100644 --- a/src/TosaSerialize.cpp +++ b/src/TosaSerialize.cpp @@ -1559,17 +1559,18 @@ TosaSerializationBlockBuilder::BuildTosaSerializationTensor( return nullptr; } - mlir::RankedTensorType tensor = - val.getType().dyn_cast<mlir::RankedTensorType>(); - if (!tensor) { - llvm::errs() << "TOSA serialization, attempt to build an " - "non-RankedTensorType Tensor\n"; + auto ttype = val.getType().dyn_cast<mlir::TensorType>(); + if (!ttype) { + llvm::errs() << "TOSA serialization, supplied value is not of TensorType\n"; return nullptr; } - std::vector<int32_t> shape(tensor.getShape().begin(), - tensor.getShape().end()); - DType type = Type2DType(tensor.getElementType()); + auto ranked = val.getType().dyn_cast<mlir::RankedTensorType>(); + std::vector<int32_t> shape = + ttype.hasRank() ? std::vector<int32_t>(ranked.getShape().begin(), + ranked.getShape().end()) + : std::vector<int32_t>(); + DType type = Type2DType(ttype.getElementType()); ts = new TosaSerializationTensor(name, shape, type, std::vector<uint8_t>()); return ts; |