aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference/workloads/Broadcast.hpp
diff options
context:
space:
mode:
authorDavid Beck <david.beck@arm.com>2018-09-24 13:18:27 +0100
committerMatthew Bentham <matthew.bentham@arm.com>2018-10-10 16:16:57 +0100
commitb4540bef0b0327683fe8e63f727c1212800dc2a9 (patch)
treee1ea8bb6ee981640a1c469ceb556ed648ffde411 /src/backends/reference/workloads/Broadcast.hpp
parent2d9dd36fb6bc20b370701ab15463359b9db35f18 (diff)
downloadarmnn-b4540bef0b0327683fe8e63f727c1212800dc2a9.tar.gz
IVGCVSW-1898 : Ref backend folder structure
* Reference backend is renamed to backends/reference as per https://confluence.arm.com/display/MLENG/Pluggable+backends Change-Id: I27a13c274eb60995dfb459e3c49c0e2f60bcd32c
Diffstat (limited to 'src/backends/reference/workloads/Broadcast.hpp')
-rw-r--r--src/backends/reference/workloads/Broadcast.hpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/backends/reference/workloads/Broadcast.hpp b/src/backends/reference/workloads/Broadcast.hpp
new file mode 100644
index 0000000000..e92ed0598d
--- /dev/null
+++ b/src/backends/reference/workloads/Broadcast.hpp
@@ -0,0 +1,58 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include <armnn/Tensor.hpp>
+
+#include <functional>
+
+namespace armnn
+{
+
+struct BroadcastLoop
+{
+ BroadcastLoop(const TensorShape& inShape0, const TensorShape& inShape1, const TensorShape& outShape);
+
+ unsigned int GetNumDimensions()
+ {
+ return static_cast<unsigned int>(m_DimData.size());
+ }
+
+ template <typename T0, typename T1, typename U, typename Func>
+ void Unroll(Func operationFunc,
+ unsigned int dimension,
+ const T0* inData0,
+ const T1* inData1,
+ U* outData)
+ {
+ if (dimension >= GetNumDimensions())
+ {
+ *outData = operationFunc(*inData0, *inData1);
+ return;
+ }
+
+ for (unsigned int i = 0; i < m_DimData[dimension].m_DimSize; i++)
+ {
+ Unroll(operationFunc, dimension + 1, inData0, inData1, outData);
+
+ inData0 += m_DimData[dimension].m_Stride1;
+ inData1 += m_DimData[dimension].m_Stride2;
+ outData += m_DimData[dimension].m_StrideOut;
+ }
+ }
+
+private:
+ // Struct to hold the dimension data.
+ struct BroadcastDimensionData
+ {
+ unsigned int m_DimSize;
+ unsigned int m_StrideOut;
+ unsigned int m_Stride1;
+ unsigned int m_Stride2;
+ };
+
+ std::vector<BroadcastDimensionData> m_DimData;
+};
+
+} //namespace armnn \ No newline at end of file