aboutsummaryrefslogtreecommitdiff
path: root/src/armnnTfLiteParser
diff options
context:
space:
mode:
authorTianle Cheng <tianle.cheng@arm.com>2023-10-03 12:01:11 +0100
committerTianle Cheng <tianle.cheng@arm.com>2023-10-03 14:31:21 +0100
commit2077348da176dd5f264bb04a0b500c5901969d09 (patch)
tree6a2e944d16b2693bbc6a666cd3c5432e59265498 /src/armnnTfLiteParser
parentad323af0e9b47e53d366b85cdf74927f88748d40 (diff)
downloadarmnn-2077348da176dd5f264bb04a0b500c5901969d09.tar.gz
IVGCVSW-7749 DTS: Fix reshape floating point exception
* Updated Opaque Delegate, TfliteParser, OnnxParser, and Deserializer to handle the Zero In Shape edge case Signed-off-by: Tianle Cheng <tianle.cheng@arm.com> Change-Id: I4a0d1e72a66de1fa56de99af9b6730a84e0ff596
Diffstat (limited to 'src/armnnTfLiteParser')
-rw-r--r--src/armnnTfLiteParser/TfLiteParser.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp
index c2be54f5f5..30875d5650 100644
--- a/src/armnnTfLiteParser/TfLiteParser.cpp
+++ b/src/armnnTfLiteParser/TfLiteParser.cpp
@@ -3252,6 +3252,7 @@ void TfLiteParserImpl::ParseActivation(size_t subgraphIndex, size_t operatorInde
auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex));
RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]});
}
+
armnn::TensorInfo TfLiteParserImpl::OutputShapeOfReshape(const armnn::TensorInfo& inputTensorInfo,
const std::vector<int32_t>& targetDimsIn)
{
@@ -3271,7 +3272,24 @@ armnn::TensorInfo TfLiteParserImpl::OutputShapeOfReshape(const armnn::TensorInfo
std::accumulate(targetDimsIn.begin(), targetDimsIn.end(), -1, std::multiplies<int32_t>()));
auto stretchIndex = static_cast<size_t>(std::distance(targetDimsIn.begin(), stretchDim));
- outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements;
+
+ if (targetNumElements == 0)
+ {
+ if (inputTensorInfo.GetNumElements() == 0)
+ {
+ outputDims[stretchIndex] = 0;
+ }
+ else
+ {
+ throw ParseException(
+ fmt::format("Input to reshape is a tensor with elements, but the requested shape has 0. {}",
+ CHECK_LOCATION().AsString()));
+ }
+ }
+ else
+ {
+ outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements;
+ }
}
TensorShape outputShape = TensorShape(static_cast<unsigned int>(outputDims.size()), outputDims.data());