aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/layers/ArgMinMaxLayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnn/layers/ArgMinMaxLayer.cpp')
-rw-r--r--src/armnn/layers/ArgMinMaxLayer.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/armnn/layers/ArgMinMaxLayer.cpp b/src/armnn/layers/ArgMinMaxLayer.cpp
index 37986572a0..537d7d10c5 100644
--- a/src/armnn/layers/ArgMinMaxLayer.cpp
+++ b/src/armnn/layers/ArgMinMaxLayer.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017,2019-2023 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2017,2019-2024 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -36,7 +36,11 @@ ArgMinMaxLayer* ArgMinMaxLayer::Clone(Graph& graph) const
std::vector<TensorShape> ArgMinMaxLayer::InferOutputShapes(const std::vector<TensorShape>& inputShapes) const
{
- ARMNN_ASSERT(inputShapes.size() == 1);
+ if (inputShapes.size() != 1)
+ {
+ throw armnn::LayerValidationException("inputShapes' size is \"" + std::to_string(inputShapes.size()) +
+ "\" - should be \"1\".");
+ }
TensorShape inputShape = inputShapes[0];
auto inputNumDimensions = inputShape.GetNumDimensions();
@@ -44,7 +48,13 @@ std::vector<TensorShape> ArgMinMaxLayer::InferOutputShapes(const std::vector<Ten
auto axis = m_Param.m_Axis;
auto unsignedAxis = armnnUtils::GetUnsignedAxis(inputNumDimensions, axis);
- ARMNN_ASSERT(unsignedAxis <= inputNumDimensions);
+ if (unsignedAxis > inputNumDimensions)
+ {
+ throw armnn::LayerValidationException("Axis must not be greater than number of input dimensions (\""
+ + std::to_string(unsignedAxis) +
+ "\" vs \""
+ + std::to_string(inputNumDimensions) + "\").");
+ }
// 1D input shape results in scalar output
if (inputShape.GetNumDimensions() == 1)
@@ -81,7 +91,12 @@ void ArgMinMaxLayer::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, "ArgMinMaxLayer");
}