aboutsummaryrefslogtreecommitdiff
path: root/delegate/src/ElementwiseBinary.hpp
diff options
context:
space:
mode:
authorRyan OShea <ryan.oshea3@arm.com>2023-01-25 18:10:20 +0000
committerryan.oshea3 <ryan.oshea3@arm.com>2023-02-21 14:36:56 +0000
commita544f0f5d01ea980ca86e1e13e2530fea4fddcd2 (patch)
treedead6db771d8d78f1e797d3a556586bd9f5129af /delegate/src/ElementwiseBinary.hpp
parentb2293702c16d107ac1ad80cfac9bd84d804f55d4 (diff)
downloadarmnn-a544f0f5d01ea980ca86e1e13e2530fea4fddcd2.tar.gz
MLCE-753 Expand Tensorshape for relevent layers before verifying support
Previously we were adding a reshape layer to "broadcast" tensors for elementwise operations. This broadcast was happening too late and was really just an expand dims. This was breaking the constant attributes of tensors and layer support of certain backends. * Remove addition of reshape layer when expanding dimensions * Replace broadcast function with expand dims to equal rank function * Fix some error status checks in various layers * Add new TensorUtil function that expands dims to a defined rank * Add unit tests to new TensorUtil function Signed-off-by: Ryan OShea <ryan.oshea3@arm.com> Change-Id: I31aca47c98075fef4f86864a15470f5faa55ab8d
Diffstat (limited to 'delegate/src/ElementwiseBinary.hpp')
-rw-r--r--delegate/src/ElementwiseBinary.hpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/delegate/src/ElementwiseBinary.hpp b/delegate/src/ElementwiseBinary.hpp
index 8096acfefb..52c6b2434b 100644
--- a/delegate/src/ElementwiseBinary.hpp
+++ b/delegate/src/ElementwiseBinary.hpp
@@ -254,6 +254,13 @@ TfLiteStatus VisitElementwiseBinaryOperator(DelegateData& delegateData,
const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteTensor(tfLiteOutputTensor, true);
+ // Check if we need to expand the dims of the input tensor infos.
+ // This is required for a few of the backends.
+ if(inputTensorInfo0.GetNumDimensions() != inputTensorInfo1.GetNumDimensions())
+ {
+ ExpandTensorRankToEqual(inputTensorInfo0, inputTensorInfo1);
+ }
+
auto* tfLiteNodeParameters = reinterpret_cast<TfLiteAddParams*>(tfLiteNode->builtin_data);
TfLiteFusedActivation activationType = kTfLiteActNone;
if (tfLiteNodeParameters)
@@ -363,13 +370,7 @@ TfLiteStatus VisitElementwiseBinaryOperator(DelegateData& delegateData,
return inputsTensorsProcess;
}
- auto reshapeLayer = BroadcastTensor(inputTensorInfo0,
- inputTensorInfo1,
- elementwiseBinaryLayer,
- tfLiteContext,
- tfLiteNode,
- delegateData);
- if (!reshapeLayer)
+ if(Connect(elementwiseBinaryLayer, tfLiteNode, delegateData) != kTfLiteOk)
{
return kTfLiteError;
}