aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/backends/RefWorkloads/Addition.cpp
blob: 6d53a702e4d4bb9d1cea69a820ee16ace8e3c7c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// See LICENSE file in the project root for full license information.
//

#include "Addition.hpp"
#include "Broadcast.hpp"

#include <functional>

namespace
{

void ElementwiseAddition(unsigned int numElements, const float* inData0, const float* inData1, float* outData)
{
    for (unsigned int i = 0; i < numElements; ++i)
    {
        outData[i] = inData0[i] + inData1[i];
    }
}

} // namespace

namespace armnn
{

void Addition(const TensorShape& inShape0,
              const TensorShape& inShape1,
              const TensorShape& outShape,
              const float* inData0,
              const float* inData1,
              float* outData)
{
    if (inShape0 == inShape1)
    {
        ElementwiseAddition(inShape0.GetNumElements(), inData0, inData1, outData);
    }
    else
    {
        BroadcastLoop(inShape0, inShape1, outShape).Unroll(std::plus<float>(), 0, inData0, inData1, outData);
    }
}

} //namespace armnn