Release 18.03
[platform/upstream/armnn.git] / src / armnn / backends / RefWorkloads / Multiplication.cpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
4 //
5
6 #include "Multiplication.hpp"
7 #include "Broadcast.hpp"
8
9 #include <functional>
10
11 namespace
12 {
13
14 void ElementwiseMultiplication(unsigned int numElements,
15                                const float* inData0,
16                                const float* inData1,
17                                float* outData)
18 {
19     for (unsigned int i = 0; i < numElements; ++i)
20     {
21         outData[i] = inData0[i] * inData1[i];
22     }
23 }
24
25 } // namespace
26
27 namespace armnn
28 {
29
30 void Multiplication(const TensorShape& inShape0,
31                     const TensorShape& inShape1,
32                     const TensorShape& outShape,
33                     const float* inData0,
34                     const float* inData1,
35                     float* outData)
36 {
37     if (inShape0 == inShape1)
38     {
39         ElementwiseMultiplication(inShape0.GetNumElements(), inData0, inData1, outData);
40     }
41     else
42     {
43         BroadcastLoop(inShape0, inShape1, outShape).Unroll(
44             std::multiplies<float>(),
45             0,
46             inData0,
47             inData1,
48             outData);
49     }
50 }
51
52 } //namespace armnn