23.02
ElementwiseFunction.cpp
Go to the documentation of this file.
1
//
2
// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3
// SPDX-License-Identifier: MIT
4
//
5
6
#include "
ElementwiseFunction.hpp
"
7
#include "
Broadcast.hpp
"
8
#include <functional>
9
#include "
Minimum.hpp
"
10
#include "
Maximum.hpp
"
11
#include "
Abs.hpp
"
12
#include "
Exp.hpp
"
13
#include "
Log.hpp
"
14
#include "
Rsqrt.hpp
"
15
#include "
Sin.hpp
"
16
#include "
Sqrt.hpp
"
17
18
19
namespace
armnn
20
{
21
22
template
<
typename
Functor>
23
ElementwiseBinaryFunction<Functor>::ElementwiseBinaryFunction
(
const
TensorShape
& inShape0,
24
const
TensorShape
& inShape1,
25
const
TensorShape
& outShape,
26
Decoder<InType>
& inData0,
27
Decoder<InType>
& inData1,
28
Encoder<OutType>
& outData)
29
{
30
BroadcastLoop
(inShape0, inShape1, outShape).
Unroll
(Functor(), 0, inData0, inData1, outData);
31
}
32
33
template
<
typename
Functor>
34
ElementwiseUnaryFunction<Functor>::ElementwiseUnaryFunction
(
const
TensorShape
& inShape,
35
const
TensorShape
& outShape,
36
Decoder<InType>
& inData,
37
Encoder<OutType>
& outData)
38
{
39
BroadcastLoop
(inShape, outShape).
Unroll
(Functor(), 0, inData, outData);
40
}
41
42
template
<
typename
Functor>
43
LogicalBinaryFunction<Functor>::LogicalBinaryFunction
(
const
TensorShape
& inShape0,
44
const
TensorShape
& inShape1,
45
const
TensorShape
& outShape,
46
Decoder<InType>
& inData0,
47
Decoder<InType>
& inData1,
48
Encoder<OutType>
& outData)
49
{
50
BroadcastLoop
(inShape0, inShape1, outShape).
Unroll
(Functor(), 0, inData0, inData1, outData);
51
}
52
53
template
<
typename
Functor>
54
LogicalUnaryFunction<Functor>::LogicalUnaryFunction
(
const
TensorShape
& inShape,
55
const
TensorShape
& outShape,
56
Decoder<InType>
& inData,
57
Encoder<OutType>
& outData)
58
{
59
BroadcastLoop
(inShape, outShape).
Unroll
(Functor(), 0, inData, outData);
60
}
61
62
}
//namespace armnn
63
64
template
struct
armnn::ElementwiseBinaryFunction<std::plus<float>
>;
65
template
struct
armnn::ElementwiseBinaryFunction<std::minus<float>
>;
66
template
struct
armnn::ElementwiseBinaryFunction<std::multiplies<float>
>;
67
template
struct
armnn::ElementwiseBinaryFunction<std::divides<float>
>;
68
template
struct
armnn::ElementwiseBinaryFunction<armnn::maximum<float>
>;
69
template
struct
armnn::ElementwiseBinaryFunction<armnn::minimum<float>
>;
70
71
template
struct
armnn::ElementwiseBinaryFunction<std::plus<int32_t>
>;
72
template
struct
armnn::ElementwiseBinaryFunction<std::minus<int32_t>
>;
73
template
struct
armnn::ElementwiseBinaryFunction<std::multiplies<int32_t>
>;
74
template
struct
armnn::ElementwiseBinaryFunction<std::divides<int32_t>
>;
75
template
struct
armnn::ElementwiseBinaryFunction<armnn::maximum<int32_t>
>;
76
template
struct
armnn::ElementwiseBinaryFunction<armnn::minimum<int32_t>
>;
77
78
// Comparison
79
template
struct
armnn::ElementwiseBinaryFunction<std::equal_to<float>
>;
80
template
struct
armnn::ElementwiseBinaryFunction<std::greater<float>
>;
81
template
struct
armnn::ElementwiseBinaryFunction<std::greater_equal<float>
>;
82
template
struct
armnn::ElementwiseBinaryFunction<std::less<float>
>;
83
template
struct
armnn::ElementwiseBinaryFunction<std::less_equal<float>
>;
84
template
struct
armnn::ElementwiseBinaryFunction<std::not_equal_to<float>
>;
85
86
// Unary
87
template
struct
armnn::ElementwiseUnaryFunction<armnn::abs<float>
>;
88
template
struct
armnn::ElementwiseUnaryFunction<armnn::exp<float>
>;
89
template
struct
armnn::ElementwiseUnaryFunction<armnn::log<float>
>;
90
template
struct
armnn::ElementwiseUnaryFunction<std::negate<float>
>;
91
template
struct
armnn::ElementwiseUnaryFunction<armnn::rsqrt<float>
>;
92
template
struct
armnn::ElementwiseUnaryFunction<armnn::sin<float>
>;
93
template
struct
armnn::ElementwiseUnaryFunction<armnn::sqrt<float>
>;
94
95
// Logical Unary
96
template
struct
armnn::LogicalUnaryFunction<std::logical_not<bool>
>;
97
template
struct
armnn::LogicalBinaryFunction<std::logical_and<bool>
>;
98
template
struct
armnn::LogicalBinaryFunction<std::logical_or<bool>
>;
Exp.hpp
armnn::BroadcastLoop::Unroll
void Unroll(Func operationFunc, unsigned int dimension, DecoderOp &inData0, DecoderOp &inData1, EncoderOp &outData)
Definition:
Broadcast.hpp:26
armnn::Encoder
Definition:
BaseIterator.hpp:54
Log.hpp
armnn::LogicalUnaryFunction
Definition:
ElementwiseFunction.hpp:55
armnn::ElementwiseUnaryFunction
Definition:
ElementwiseFunction.hpp:29
Rsqrt.hpp
armnn::ElementwiseUnaryFunction::ElementwiseUnaryFunction
ElementwiseUnaryFunction(const TensorShape &inShape, const TensorShape &outShape, Decoder< InType > &inData, Encoder< OutType > &outData)
Definition:
ElementwiseFunction.cpp:34
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition:
01_00_quick_start.dox:6
ElementwiseFunction.hpp
armnn::LogicalUnaryFunction::LogicalUnaryFunction
LogicalUnaryFunction(const TensorShape &inShape, const TensorShape &outShape, Decoder< InType > &inData, Encoder< OutType > &outData)
Definition:
ElementwiseFunction.cpp:54
Minimum.hpp
armnn::TensorShape
Definition:
Tensor.hpp:20
Maximum.hpp
armnn::Decoder
Definition:
BaseIterator.hpp:37
armnn::LogicalBinaryFunction::LogicalBinaryFunction
LogicalBinaryFunction(const TensorShape &inShape0, const TensorShape &inShape1, const TensorShape &outShape, Decoder< InType > &inData0, Decoder< InType > &inData1, Encoder< OutType > &outData)
Definition:
ElementwiseFunction.cpp:43
armnn::LogicalBinaryFunction
Definition:
ElementwiseFunction.hpp:41
Broadcast.hpp
armnn::ElementwiseBinaryFunction
Definition:
ElementwiseFunction.hpp:15
Abs.hpp
armnn::BroadcastLoop
Definition:
Broadcast.hpp:14
armnn::ElementwiseBinaryFunction::ElementwiseBinaryFunction
ElementwiseBinaryFunction(const TensorShape &inShape0, const TensorShape &inShape1, const TensorShape &outShape, Decoder< InType > &inData0, Decoder< InType > &inData1, Encoder< OutType > &outData)
Definition:
ElementwiseFunction.cpp:23
Sin.hpp
Sqrt.hpp
src
backends
reference
workloads
ElementwiseFunction.cpp
Generated on Wed Mar 22 2023 15:53:02 for ArmNN by
1.8.17