blob: 8421a0a7ed91b09999abe03fc0842d70657dcc65 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5
6#include "Broadcast.hpp"
7
8namespace armnn
9{
10
11BroadcastLoop::BroadcastLoop(const TensorShape& inShape0, const TensorShape& inShape1, const TensorShape& outShape)
12: m_DimData(outShape.GetNumDimensions())
13{
14 const unsigned int numDims = GetNumDimensions();
15
16 unsigned int sIn0 = 1;
17 unsigned int sIn1 = 1;
18 unsigned int sOut = 1;
19
20 for (unsigned int j = numDims - 1, k = 0; k < numDims ; k++, j--)
21 {
22 m_DimData[j].m_DimSize = outShape[j];
23 m_DimData[j].m_Stride1 = (inShape0[j] > 1) ? sIn0 : 0;
24 m_DimData[j].m_Stride2 = (inShape1[j] > 1) ? sIn1 : 0;
25 m_DimData[j].m_StrideOut = sOut;
26
27 sIn0 *= inShape0[j];
28 sIn1 *= inShape1[j];
29 sOut *= outShape[j];
30 }
31}
32
33} // namespace armnn