aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference/workloads/Broadcast.hpp
diff options
context:
space:
mode:
authorjosh minor <josh.minor@arm.com>2020-01-06 16:40:46 -0600
committerDerek Lamberti <derek.lamberti@arm.com>2020-01-23 14:29:14 +0000
commit4a3c61091037e7e86e8b03bb060d8c1ab82731a9 (patch)
tree928644023400ad5ac0c26b33dfff2f975567d6e8 /src/backends/reference/workloads/Broadcast.hpp
parent190a39a4a9598e42b636ae4ab843761884148160 (diff)
downloadarmnn-4a3c61091037e7e86e8b03bb060d8c1ab82731a9.tar.gz
IVGCVSW-4259 Add frontend and reference workload for UnaryOperationLayer
* Added new layer named ElementwiseUnary * Deprecated existing Abs/Rsqrt layer functions * Updated existing Abs/Rsqrt test infrastructure to use new layer * Added boilerplate for new Exp,Neg,Sqrt elemwise op layers * AbsQuantize test removed pending future commit * Serialization support added !android-nn-driver:2550 Change-Id: Ic595c645925e17b45db568187fd05646daf2e87f Signed-off-by: josh minor <josh.minor@arm.com>
Diffstat (limited to 'src/backends/reference/workloads/Broadcast.hpp')
-rw-r--r--src/backends/reference/workloads/Broadcast.hpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/backends/reference/workloads/Broadcast.hpp b/src/backends/reference/workloads/Broadcast.hpp
index 5bf6be8939..a3d944ae75 100644
--- a/src/backends/reference/workloads/Broadcast.hpp
+++ b/src/backends/reference/workloads/Broadcast.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -15,6 +15,8 @@ struct BroadcastLoop
{
BroadcastLoop(const TensorShape& inShape0, const TensorShape& inShape1, const TensorShape& outShape);
+ BroadcastLoop(const TensorShape& inShape, const TensorShape& outShape);
+
unsigned int GetNumDimensions()
{
return static_cast<unsigned int>(m_DimData.size());
@@ -56,6 +58,37 @@ struct BroadcastLoop
outData -= outDataMovement;
}
+ template <typename Func, typename DecoderOp, typename EncoderOp>
+ void Unroll(Func operationFunc,
+ unsigned int dimension,
+ DecoderOp& inData,
+ EncoderOp& outData)
+ {
+ if (dimension >= GetNumDimensions())
+ {
+ outData.Set(operationFunc(inData.Get()));
+ return;
+ }
+
+ unsigned int inDataMovement = 0;
+ unsigned int outDataMovement = 0;
+
+ for (unsigned int i = 0; i < m_DimData[dimension].m_DimSize; i++)
+ {
+ Unroll(operationFunc, dimension + 1, inData, outData);
+
+ inData += m_DimData[dimension].m_Stride1;
+ outData += m_DimData[dimension].m_StrideOut;
+
+ inDataMovement += m_DimData[dimension].m_Stride1;
+ outDataMovement += m_DimData[dimension].m_StrideOut;
+ }
+
+ // move iterator back to the start
+ inData -= inDataMovement;
+ outData -= outDataMovement;
+ }
+
private:
// Struct to hold the dimension data.
struct BroadcastDimensionData