diff options
Diffstat (limited to 'src/armnn/layers/Pooling3dLayer.cpp')
-rw-r--r-- | src/armnn/layers/Pooling3dLayer.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/armnn/layers/Pooling3dLayer.cpp b/src/armnn/layers/Pooling3dLayer.cpp index ec1ec80f0e..0506efa7d3 100644 --- a/src/armnn/layers/Pooling3dLayer.cpp +++ b/src/armnn/layers/Pooling3dLayer.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2021-2023 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2021-2024 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -39,12 +39,20 @@ Pooling3dLayer* Pooling3dLayer::Clone(Graph& graph) const std::vector<TensorShape> Pooling3dLayer::InferOutputShapes(const std::vector<TensorShape>& inputShapes) const { - ARMNN_ASSERT(inputShapes.size() == 1); + if (inputShapes.size() != 1) + { + throw armnn::Exception("inputShapes' size is \"" + std::to_string(inputShapes.size()) + + "\" - should be \"1\"."); + } + const TensorShape& inputShape = inputShapes[0]; const DataLayoutIndexed dimensionIndices = m_Param.m_DataLayout; // If we support multiple batch dimensions in the future, then this assert will need to change. - ARMNN_ASSERT_MSG(inputShape.GetNumDimensions() == 5, "Pooling3dLayer will always have 5D input."); + if (inputShape.GetNumDimensions() != 5) + { + throw armnn::Exception("Pooling3dLayer will always have 5D input."); + } unsigned int inWidth = inputShape[dimensionIndices.GetWidthIndex()]; unsigned int inHeight = inputShape[dimensionIndices.GetHeightIndex()]; @@ -58,8 +66,10 @@ std::vector<TensorShape> Pooling3dLayer::InferOutputShapes(const std::vector<Ten unsigned int outDepth = 1; if (!isGlobalPooling) { - ARMNN_ASSERT_MSG(m_Param.m_StrideX!=0 && m_Param.m_StrideY!=0 && m_Param.m_StrideZ!=0, - "Stride can only be zero when performing global pooling"); + if (!m_Param.m_StrideX || !m_Param.m_StrideY || !m_Param.m_StrideZ) + { + throw armnn::Exception("Stride can only be zero when performing global pooling"); + } auto CalcSize = [](auto inSize, auto lowPad, auto highPad, auto poolSize, auto stride, auto outputShapeRounding) { @@ -76,7 +86,7 @@ std::vector<TensorShape> Pooling3dLayer::InferOutputShapes(const std::vector<Ten size = static_cast<unsigned int>(floor(div)) + 1; break; default: - ARMNN_ASSERT_MSG(false, "Unsupported Output Shape Rounding"); + throw armnn::Exception("Unsupported Output Shape Rounding"); } // Makes sure that border operations will start from inside the input and not the padded area. @@ -116,7 +126,12 @@ void Pooling3dLayer::ValidateTensorShapesFromInputs() auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetTensorInfo().GetShape() }); - ARMNN_ASSERT(inferredShapes.size() == 1); + if (inferredShapes.size() != 1) + { + throw armnn::LayerValidationException("inferredShapes has " + + std::to_string(inferredShapes.size()) + + " elements - should only have 1."); + } ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "Pooling3dLayer"); } |