blob: eec9bb9fa9b827adada8cf6a7378e873de3d273f [file] [log] [blame]
giuros0192fd9432018-12-03 17:30:00 +00001/*
morgolocka3598052019-12-31 12:20:47 +00002 * Copyright (c) 2018-2020 ARM Limited.
giuros0192fd9432018-12-03 17:30:00 +00003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
George Wortd88590f2018-12-12 17:39:58 +000017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
giuros0192fd9432018-12-03 17:30:00 +000018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
George Wortd88590f2018-12-12 17:39:58 +000019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
giuros0192fd9432018-12-03 17:30:00 +000021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H
25#define ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H
giuros0192fd9432018-12-03 17:30:00 +000026
27#include "arm_compute/core/Types.h"
28#include "arm_compute/runtime/NEON/INESimpleFunction.h"
29
30namespace arm_compute
31{
32class ITensor;
33
34/** Basic function to run @ref NEArithmeticOperationKernel for max
35 *
morgolock6427c822020-01-13 11:53:20 +000036 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000037 * @note The function performs a max operation between two tensors.
38 */
39class NEElementwiseMax : public INESimpleFunction
40{
41public:
42 /** Initialise the kernel's inputs, output and conversion policy.
43 *
morgolocka3598052019-12-31 12:20:47 +000044 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000045 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
46 * @param[out] output Output tensor. Data types supported: Same as @p input1.
47 */
48 void configure(ITensor *input1, ITensor *input2, ITensor *output);
49 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for max
50 *
morgolocka3598052019-12-31 12:20:47 +000051 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000052 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
53 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
54 *
55 * @return a status
56 */
57 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
58};
59
60/** Basic function to run @ref NEArithmeticOperationKernel for min
61 *
morgolock6427c822020-01-13 11:53:20 +000062 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
63 * @note The function performs a min operation between two tensors.
giuros0192fd9432018-12-03 17:30:00 +000064 */
65class NEElementwiseMin : public INESimpleFunction
66{
67public:
68 /** Initialise the kernel's inputs, output and conversion policy.
69 *
morgolock781d7272020-01-10 10:11:14 +000070 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000071 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
72 * @param[out] output Output tensor. Data types supported: Same as @p input1.
73 */
74 void configure(ITensor *input1, ITensor *input2, ITensor *output);
75 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for min
76 *
morgolock781d7272020-01-10 10:11:14 +000077 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000078 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
79 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
80 *
81 * @return a status
82 */
83 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
84};
85
86/** Basic function to run @ref NEArithmeticOperationKernel for squared difference
87 *
morgolock6427c822020-01-13 11:53:20 +000088 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000089 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
90 */
91class NEElementwiseSquaredDiff : public INESimpleFunction
92{
93public:
94 /** Initialise the kernel's inputs, output and conversion policy.
95 *
morgolock6427c822020-01-13 11:53:20 +000096 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000097 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
98 * @param[out] output Output tensor. Data types supported: Same as @p input1.
99 */
100 void configure(ITensor *input1, ITensor *input2, ITensor *output);
101 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for squared difference
102 *
morgolock6427c822020-01-13 11:53:20 +0000103 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +0000104 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
105 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
106 *
107 * @return a status
108 */
109 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
110};
George Wortd88590f2018-12-12 17:39:58 +0000111
George Worta1e7e282019-01-15 11:00:29 +0000112/** Basic function to run @ref NEArithmeticOperationKernel for division
113 *
114 * @note The tensor data type for the inputs must be F16/F32.
115 * @note The function performs a squared different operation between two tensors (i.e., out[i] = in1[i] / in2[i])
116 */
117class NEElementwiseDivision : public INESimpleFunction
118{
119public:
120 /** Initialise the kernel's inputs, output and conversion policy.
121 *
122 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
123 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
124 * @param[out] output Output tensor. Data types supported: Same as @p input1.
125 */
126 void configure(ITensor *input1, ITensor *input2, ITensor *output);
127 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for division
128 *
129 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
130 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
131 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
132 *
133 * @return a status
134 */
135 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
136};
137
Usama Arif81e671e2019-05-13 13:33:14 +0100138/** Basic function to run @ref NEArithmeticOperationKernel for power
139 *
140 * @note The tensor data type for the inputs must be F16/F32.
141 * @note The function performs a elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
142 * @note For an exponent that is a float, this function will only work with a positive base.
143 */
144class NEElementwisePower : public INESimpleFunction
145{
146public:
147 /** Initialise the kernel's inputs, output and conversion policy.
148 *
149 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
150 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
151 * @param[out] output Output tensor. Data types supported: Same as @p input1.
152 */
153 void configure(ITensor *input1, ITensor *input2, ITensor *output);
154 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for power
155 *
156 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
157 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
158 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
159 *
160 * @return a status
161 */
162 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
163};
164
George Worta1e7e282019-01-15 11:00:29 +0000165/** Basic function to run @ref NEComparisonOperationKernel.
George Wortd88590f2018-12-12 17:39:58 +0000166 *
167 * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32.
168 * @note The function performs a comparison operation between two tensors.
169 */
170class NEElementwiseComparison : public INESimpleFunction
171{
172public:
173 /** Initialise the kernel's inputs, output and conversion policy.
174 *
175 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/S16/F16/S32/F32.
176 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
177 * @param[out] output Output tensor. Data types supported: U16/U32.
178 * @param[in] op Comparison Operation to be performed.
179 */
180 void configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op);
181 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
182 *
183 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32.
184 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
185 * @param[in] output Output tensor info. Data types supported: U16/U32.
186 * @param[in] op Comparison Operation to be performed.
187 *
188 * @return a status
189 */
190 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op);
191};
192
193/** Basic function to run @ref NEComparisonOperationKernel
194 *
195 * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32.
196 * @note The function performs a comparison operation between two tensors.
197 */
198template <ComparisonOperation op>
199class NEElementwiseComparisonStatic : public INESimpleFunction
200{
201public:
202 /** Initialise the kernel's inputs, output and conversion policy.
203 *
204 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/S16/F16/S32/F32.
205 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
206 * @param[out] output Output tensor. Data types supported: U16/U32.
207 */
208 void configure(ITensor *input1, ITensor *input2, ITensor *output);
209 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
210 *
211 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32.
212 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
213 * @param[in] output Output tensor info. Data types supported: U16/U32.
214 *
215 * @return a status
216 */
217 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
218};
219
220/** Basic function to run equal comparison. */
221using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>;
222/** Basic function to run not equal comparison. */
223using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>;
224/** Basic function to run greater comparison. */
225using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>;
226/** Basic function to run greater-equal comparison. */
227using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>;
228/** Basic function to run less comparison. */
229using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>;
230/** Basic function to run less-equal comparison. */
231using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>;
giuros0192fd9432018-12-03 17:30:00 +0000232} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000233#endif /* ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H */