From 2077348da176dd5f264bb04a0b500c5901969d09 Mon Sep 17 00:00:00 2001 From: Tianle Cheng Date: Tue, 3 Oct 2023 12:01:11 +0100 Subject: 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 Change-Id: I4a0d1e72a66de1fa56de99af9b6730a84e0ff596 --- delegate/common/src/DelegateUtils.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'delegate/common/src') diff --git a/delegate/common/src/DelegateUtils.hpp b/delegate/common/src/DelegateUtils.hpp index a74ed8b549..a2cdc83a64 100644 --- a/delegate/common/src/DelegateUtils.hpp +++ b/delegate/common/src/DelegateUtils.hpp @@ -186,7 +186,16 @@ TfLiteStatus CreateOutputTensorShape(const armnn::TensorInfo& inputTensorInfo, std::accumulate(targetShape.begin(), targetShape.end(), -1, std::multiplies())); auto stretchIndex = static_cast(std::distance(targetShape.begin(), stretchDim)); - outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements; + + if (targetNumElements == 0) + { + // To handle the edge case that input and output both have zero elements + outputDims[stretchIndex] = 0; + } + else + { + outputDims[stretchIndex] = inputTensorInfo.GetNumElements() / targetNumElements; + } } armnn::TensorShape outputShape = armnn::TensorShape(static_cast(outputDims.size()), -- cgit v1.2.1