aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/layers/ElementwiseBinaryLayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnn/layers/ElementwiseBinaryLayer.cpp')
-rw-r--r--src/armnn/layers/ElementwiseBinaryLayer.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/armnn/layers/ElementwiseBinaryLayer.cpp b/src/armnn/layers/ElementwiseBinaryLayer.cpp
index 67619fc463..5459aafbca 100644
--- a/src/armnn/layers/ElementwiseBinaryLayer.cpp
+++ b/src/armnn/layers/ElementwiseBinaryLayer.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2024 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -30,7 +30,12 @@ ElementwiseBinaryLayer* ElementwiseBinaryLayer::Clone(Graph& graph) const
std::vector<TensorShape> ElementwiseBinaryLayer::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\".");
+ }
+
TensorShape input0 = inputShapes[0];
TensorShape input1 = inputShapes[1];
@@ -51,8 +56,10 @@ std::vector<TensorShape> ElementwiseBinaryLayer::InferOutputShapes(const std::ve
unsigned int dim1 = input1[i - shiftedDims];
// Validate inputs are broadcast compatible.
- ARMNN_ASSERT_MSG(dim0 == dim1 || dim0 == 1 || dim1 == 1,
- "Dimensions should either match or one should be of size 1.");
+ if (dim0 != dim1 && dim0 != 1 && dim1 != 1)
+ {
+ throw armnn::Exception("Dimensions should either match or one should be of size 1.");
+ }
dims[i] = std::max(dim0, dim1);
}
@@ -77,7 +84,12 @@ void ElementwiseBinaryLayer::ValidateTensorShapesFromInputs()
auto inferredShapes = InferOutputShapes({ GetInputSlot(0).GetTensorInfo().GetShape(),
GetInputSlot(1).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, GetLayerTypeAsCString(GetType()));
}