aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference/workloads/ElementwiseFunction.cpp
blob: 5687cf5861ac4e9009d2c8e2d82aa13aff3b31ef (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "ElementwiseFunction.hpp"
#include "Broadcast.hpp"
#include <functional>
#include "Minimum.hpp"
#include "Maximum.hpp"
#include "Abs.hpp"
#include "Exp.hpp"
#include "Rsqrt.hpp"
#include "Sqrt.hpp"


namespace armnn
{

template <typename Functor>
ElementwiseBinaryFunction<Functor>::ElementwiseBinaryFunction(const TensorShape& inShape0,
                                                              const TensorShape& inShape1,
                                                              const TensorShape& outShape,
                                                              Decoder<InType>& inData0,
                                                              Decoder<InType>& inData1,
                                                              Encoder<OutType>& outData)
{
    BroadcastLoop(inShape0, inShape1, outShape).Unroll(Functor(), 0, inData0, inData1, outData);
}

template <typename Functor>
ElementwiseUnaryFunction<Functor>::ElementwiseUnaryFunction(const TensorShape& inShape,
                                                            const TensorShape& outShape,
                                                            Decoder<InType>& inData,
                                                            Encoder<OutType>& outData)
{
    BroadcastLoop(inShape, outShape).Unroll(Functor(), 0, inData, outData);
}

} //namespace armnn

template struct armnn::ElementwiseBinaryFunction<std::plus<float>>;
template struct armnn::ElementwiseBinaryFunction<std::minus<float>>;
template struct armnn::ElementwiseBinaryFunction<std::multiplies<float>>;
template struct armnn::ElementwiseBinaryFunction<std::divides<float>>;
template struct armnn::ElementwiseBinaryFunction<armnn::maximum<float>>;
template struct armnn::ElementwiseBinaryFunction<armnn::minimum<float>>;

// Comparison
template struct armnn::ElementwiseBinaryFunction<std::equal_to<float>>;
template struct armnn::ElementwiseBinaryFunction<std::greater<float>>;
template struct armnn::ElementwiseBinaryFunction<std::greater_equal<float>>;
template struct armnn::ElementwiseBinaryFunction<std::less<float>>;
template struct armnn::ElementwiseBinaryFunction<std::less_equal<float>>;
template struct armnn::ElementwiseBinaryFunction<std::not_equal_to<float>>;

// Unary
template struct armnn::ElementwiseUnaryFunction<armnn::abs<float>>;
template struct armnn::ElementwiseUnaryFunction<armnn::exp<float>>;
template struct armnn::ElementwiseUnaryFunction<std::negate<float>>;
template struct armnn::ElementwiseUnaryFunction<armnn::rsqrt<float>>;
template struct armnn::ElementwiseUnaryFunction<armnn::sqrt<float>>;