aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/layers/Convolution2dLayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnn/layers/Convolution2dLayer.cpp')
-rw-r--r--src/armnn/layers/Convolution2dLayer.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/armnn/layers/Convolution2dLayer.cpp b/src/armnn/layers/Convolution2dLayer.cpp
index df971a517d..2fcc4aa755 100644
--- a/src/armnn/layers/Convolution2dLayer.cpp
+++ b/src/armnn/layers/Convolution2dLayer.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017-2023 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2017-2024 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -63,15 +63,30 @@ Convolution2dLayer* Convolution2dLayer::Clone(Graph& graph) const
std::vector<TensorShape> Convolution2dLayer::InferOutputShapes(const std::vector<TensorShape>& inputShapes) const
{
- ARMNN_ASSERT(inputShapes.size() == 2);
+ if (inputShapes.size() != 2)
+ {
+ throw armnn::Exception("inputShapes' size is \"" + std::to_string(inputShapes.size()) +
+ "\" - should be \"2\".");
+ }
+
const TensorShape& inputShape = inputShapes[0];
const TensorShape filterShape = inputShapes[1];
// If we support multiple batch dimensions in the future, then this assert will need to change.
- ARMNN_ASSERT_MSG(inputShape.GetNumDimensions() == 4, "Convolutions will always have 4D input.");
+ if (inputShape.GetNumDimensions() != 4)
+ {
+ throw armnn::Exception("Convolutions will always have 4D input.");
+ }
+
+ if (m_Param.m_StrideX == 0)
+ {
+ throw armnn::Exception("m_StrideX cannot be 0.");
+ }
- ARMNN_ASSERT( m_Param.m_StrideX > 0);
- ARMNN_ASSERT( m_Param.m_StrideY > 0);
+ if (m_Param.m_StrideY == 0)
+ {
+ throw armnn::Exception("m_StrideY cannot be 0.");
+ }
DataLayoutIndexed dataLayoutIndex(m_Param.m_DataLayout);
@@ -107,14 +122,21 @@ void Convolution2dLayer::ValidateTensorShapesFromInputs()
VerifyShapeInferenceType(outputShape, m_ShapeInferenceMethod);
- ARMNN_ASSERT_MSG(GetInputSlot(1).GetConnection(),
- "Convolution2dLayer: Weights should be connected to input slot 1.");
+ if (!GetInputSlot(1).GetConnection())
+ {
+ throw armnn::NullPointerException("Convolution2dLayer: Weights should be connected to input slot 1.");
+ }
std::vector<TensorShape> inferredShapes = InferOutputShapes({
GetInputSlot(0).GetTensorInfo().GetShape(),
GetInputSlot(1).GetTensorInfo().GetShape() });
- ARMNN_ASSERT(inferredShapes.size() == 1);
+ if (inferredShapes.size() != 1)
+ {
+ throw armnn::Exception("inferredShapes has "
+ + std::to_string(inferredShapes.size()) +
+ " elements - should only have 1.");
+ }
ValidateAndCopyShape(outputShape, inferredShapes[0], m_ShapeInferenceMethod, "Convolution2dLayer");
}