blob: 08f798ec6e5c21acdbf0841e7161d93ed60d08cb [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"
Michalis Spyrouce0c6752020-06-18 10:14:57 +010028#include "arm_compute/runtime/IFunction.h"
29#include "arm_compute/runtime/NEON/INEOperator.h"
giuros0192fd9432018-12-03 17:30:00 +000030
31namespace arm_compute
32{
33class ITensor;
34
35/** Basic function to run @ref NEArithmeticOperationKernel for max
36 *
morgolock6427c822020-01-13 11:53:20 +000037 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000038 * @note The function performs a max operation between two tensors.
39 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +010040class NEElementwiseMax : public IFunction
giuros0192fd9432018-12-03 17:30:00 +000041{
42public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +010043 /** Default Constructor */
44 NEElementwiseMax();
45 /** Default Destructor */
46 ~NEElementwiseMax();
47 /** Prevent instances of this class from being copied (As this class contains pointers) */
48 NEElementwiseMax(const NEElementwiseMax &) = delete;
49 /** Default move constructor */
50 NEElementwiseMax(NEElementwiseMax &&);
51 /** Prevent instances of this class from being copied (As this class contains pointers) */
52 NEElementwiseMax &operator=(const NEElementwiseMax &) = delete;
53 /** Default move assignment operator */
54 NEElementwiseMax &operator=(NEElementwiseMax &&);
giuros0192fd9432018-12-03 17:30:00 +000055 /** Initialise the kernel's inputs, output and conversion policy.
56 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000057 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
58 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
59 * @param[out] output Output tensor. Data types supported: Same as @p input1.
60 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +000061 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000062 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros0192fd9432018-12-03 17:30:00 +000063 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for max
64 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000065 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
66 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
67 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
68 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +000069 *
70 * @return a status
71 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000072 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +010073
74 // Inherited methods overridden:
75 void run() override;
76
77private:
78 struct Impl;
79 std::unique_ptr<Impl> _impl;
giuros0192fd9432018-12-03 17:30:00 +000080};
81
82/** Basic function to run @ref NEArithmeticOperationKernel for min
83 *
morgolock6427c822020-01-13 11:53:20 +000084 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
85 * @note The function performs a min operation between two tensors.
giuros0192fd9432018-12-03 17:30:00 +000086 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +010087class NEElementwiseMin : public IFunction
giuros0192fd9432018-12-03 17:30:00 +000088{
89public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +010090 /** Default Constructor */
91 NEElementwiseMin();
92 /** Default Destructor */
93 ~NEElementwiseMin();
94 /** Prevent instances of this class from being copied (As this class contains pointers) */
95 NEElementwiseMin(const NEElementwiseMin &) = delete;
96 /** Default move constructor */
97 NEElementwiseMin(NEElementwiseMin &&);
98 /** Prevent instances of this class from being copied (As this class contains pointers) */
99 NEElementwiseMin &operator=(const NEElementwiseMin &) = delete;
100 /** Default move assignment operator */
101 NEElementwiseMin &operator=(NEElementwiseMin &&);
giuros0192fd9432018-12-03 17:30:00 +0000102 /** Initialise the kernel's inputs, output and conversion policy.
103 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000104 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
105 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
106 * @param[out] output Output tensor. Data types supported: Same as @p input1.
107 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000108 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000109 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros0192fd9432018-12-03 17:30:00 +0000110 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for min
111 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000112 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
113 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
114 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
115 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000116 *
117 * @return a status
118 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000119 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100120
121 // Inherited methods overridden:
122 void run() override;
123
124private:
125 struct Impl;
126 std::unique_ptr<Impl> _impl;
giuros0192fd9432018-12-03 17:30:00 +0000127};
128
129/** Basic function to run @ref NEArithmeticOperationKernel for squared difference
130 *
morgolock6427c822020-01-13 11:53:20 +0000131 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +0000132 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
133 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100134class NEElementwiseSquaredDiff : public IFunction
giuros0192fd9432018-12-03 17:30:00 +0000135{
136public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100137 /** Default Constructor */
138 NEElementwiseSquaredDiff();
139 /** Default Destructor */
140 ~NEElementwiseSquaredDiff();
141 /** Prevent instances of this class from being copied (As this class contains pointers) */
142 NEElementwiseSquaredDiff(const NEElementwiseSquaredDiff &) = delete;
143 /** Default move constructor */
144 NEElementwiseSquaredDiff(NEElementwiseSquaredDiff &&);
145 /** Prevent instances of this class from being copied (As this class contains pointers) */
146 NEElementwiseSquaredDiff &operator=(const NEElementwiseSquaredDiff &) = delete;
147 /** Default move assignment operator */
148 NEElementwiseSquaredDiff &operator=(NEElementwiseSquaredDiff &&);
giuros0192fd9432018-12-03 17:30:00 +0000149 /** Initialise the kernel's inputs, output and conversion policy.
150 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000151 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
152 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
153 * @param[out] output Output tensor. Data types supported: Same as @p input1.
154 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000155 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000156 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros0192fd9432018-12-03 17:30:00 +0000157 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for squared difference
158 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000159 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
160 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
161 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
162 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000163 *
164 * @return a status
165 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000166 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100167
168 // Inherited methods overridden:
169 void run() override;
170
171private:
172 struct Impl;
173 std::unique_ptr<Impl> _impl;
giuros0192fd9432018-12-03 17:30:00 +0000174};
George Wortd88590f2018-12-12 17:39:58 +0000175
George Worta1e7e282019-01-15 11:00:29 +0000176/** Basic function to run @ref NEArithmeticOperationKernel for division
177 *
178 * @note The tensor data type for the inputs must be F16/F32.
179 * @note The function performs a squared different operation between two tensors (i.e., out[i] = in1[i] / in2[i])
180 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100181class NEElementwiseDivision : public IFunction
George Worta1e7e282019-01-15 11:00:29 +0000182{
183public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100184 /** Default Constructor */
185 NEElementwiseDivision();
186 /** Default Destructor */
187 ~NEElementwiseDivision();
188 /** Prevent instances of this class from being copied (As this class contains pointers) */
189 NEElementwiseDivision(const NEElementwiseDivision &) = delete;
190 /** Default move constructor */
191 NEElementwiseDivision(NEElementwiseDivision &&);
192 /** Prevent instances of this class from being copied (As this class contains pointers) */
193 NEElementwiseDivision &operator=(const NEElementwiseDivision &) = delete;
194 /** Default move assignment operator */
195 NEElementwiseDivision &operator=(NEElementwiseDivision &&);
George Worta1e7e282019-01-15 11:00:29 +0000196 /** Initialise the kernel's inputs, output and conversion policy.
197 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000198 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
199 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
200 * @param[out] output Output tensor. Data types supported: Same as @p input1.
201 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
George Worta1e7e282019-01-15 11:00:29 +0000202 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000203 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
George Worta1e7e282019-01-15 11:00:29 +0000204 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for division
205 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000206 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
207 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
208 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
209 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
George Worta1e7e282019-01-15 11:00:29 +0000210 *
211 * @return a status
212 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000213 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100214
215 // Inherited methods overridden:
216 void run() override;
217
218private:
219 struct Impl;
220 std::unique_ptr<Impl> _impl;
George Worta1e7e282019-01-15 11:00:29 +0000221};
222
Usama Arif81e671e2019-05-13 13:33:14 +0100223/** Basic function to run @ref NEArithmeticOperationKernel for power
224 *
225 * @note The tensor data type for the inputs must be F16/F32.
226 * @note The function performs a elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
227 * @note For an exponent that is a float, this function will only work with a positive base.
228 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100229class NEElementwisePower : public IFunction
Usama Arif81e671e2019-05-13 13:33:14 +0100230{
231public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100232 /** Default Constructor */
233 NEElementwisePower();
234 /** Default Destructor */
235 ~NEElementwisePower();
236 /** Prevent instances of this class from being copied (As this class contains pointers) */
237 NEElementwisePower(const NEElementwisePower &) = delete;
238 /** Default move constructor */
239 NEElementwisePower(NEElementwisePower &&);
240 /** Prevent instances of this class from being copied (As this class contains pointers) */
241 NEElementwisePower &operator=(const NEElementwisePower &) = delete;
242 /** Default move assignment operator */
243 NEElementwisePower &operator=(NEElementwisePower &&);
Usama Arif81e671e2019-05-13 13:33:14 +0100244 /** Initialise the kernel's inputs, output and conversion policy.
245 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000246 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
247 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
248 * @param[out] output Output tensor. Data types supported: Same as @p input1.
249 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Usama Arif81e671e2019-05-13 13:33:14 +0100250 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000251 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Usama Arif81e671e2019-05-13 13:33:14 +0100252 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for power
253 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000254 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
255 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
256 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
257 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Usama Arif81e671e2019-05-13 13:33:14 +0100258 *
259 * @return a status
260 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000261 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100262
263 // Inherited methods overridden:
264 void run() override;
265
266private:
267 struct Impl;
268 std::unique_ptr<Impl> _impl;
Usama Arif81e671e2019-05-13 13:33:14 +0100269};
270
George Worta1e7e282019-01-15 11:00:29 +0000271/** Basic function to run @ref NEComparisonOperationKernel.
George Wortd88590f2018-12-12 17:39:58 +0000272 *
morgolock74a16962020-01-15 11:40:49 +0000273 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000274 * @note The function performs a comparison operation between two tensors.
275 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100276class NEElementwiseComparison : public IFunction
George Wortd88590f2018-12-12 17:39:58 +0000277{
278public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100279 /** Default Constructor */
280 NEElementwiseComparison();
281 /** Default Destructor */
282 ~NEElementwiseComparison();
283 /** Prevent instances of this class from being copied (As this class contains pointers) */
284 NEElementwiseComparison(const NEElementwiseComparison &) = delete;
285 /** Default move constructor */
286 NEElementwiseComparison(NEElementwiseComparison &&);
287 /** Prevent instances of this class from being copied (As this class contains pointers) */
288 NEElementwiseComparison &operator=(const NEElementwiseComparison &) = delete;
289 /** Default move assignment operator */
290 NEElementwiseComparison &operator=(NEElementwiseComparison &&);
George Wortd88590f2018-12-12 17:39:58 +0000291 /** Initialise the kernel's inputs, output and conversion policy.
292 *
morgolock74a16962020-01-15 11:40:49 +0000293 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000294 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
295 * @param[out] output Output tensor. Data types supported: U16/U32.
296 * @param[in] op Comparison Operation to be performed.
297 */
298 void configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op);
299 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
300 *
morgolock74a16962020-01-15 11:40:49 +0000301 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000302 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
303 * @param[in] output Output tensor info. Data types supported: U16/U32.
304 * @param[in] op Comparison Operation to be performed.
305 *
306 * @return a status
307 */
308 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100309
310 // Inherited methods overridden:
311 void run() override;
312
313private:
314 struct Impl;
315 std::unique_ptr<Impl> _impl;
George Wortd88590f2018-12-12 17:39:58 +0000316};
317
318/** Basic function to run @ref NEComparisonOperationKernel
319 *
morgolock74a16962020-01-15 11:40:49 +0000320 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000321 * @note The function performs a comparison operation between two tensors.
322 */
323template <ComparisonOperation op>
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100324class NEElementwiseComparisonStatic : public IFunction
George Wortd88590f2018-12-12 17:39:58 +0000325{
326public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100327 /** Default Constructor */
328 NEElementwiseComparisonStatic();
329 /** Default Destructor */
330 ~NEElementwiseComparisonStatic();
331 /** Prevent instances of this class from being copied (As this class contains pointers) */
332 NEElementwiseComparisonStatic(const NEElementwiseComparisonStatic &) = delete;
333 /** Default move constructor */
334 NEElementwiseComparisonStatic(NEElementwiseComparisonStatic &&);
335 /** Prevent instances of this class from being copied (As this class contains pointers) */
336 NEElementwiseComparisonStatic &operator=(const NEElementwiseComparisonStatic &) = delete;
337 /** Default move assignment operator */
338 NEElementwiseComparisonStatic &operator=(NEElementwiseComparisonStatic &&);
George Wortd88590f2018-12-12 17:39:58 +0000339 /** Initialise the kernel's inputs, output and conversion policy.
340 *
morgolock74a16962020-01-15 11:40:49 +0000341 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000342 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
343 * @param[out] output Output tensor. Data types supported: U16/U32.
344 */
345 void configure(ITensor *input1, ITensor *input2, ITensor *output);
346 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
347 *
morgolock74a16962020-01-15 11:40:49 +0000348 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
George Wortd88590f2018-12-12 17:39:58 +0000349 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
350 * @param[in] output Output tensor info. Data types supported: U16/U32.
351 *
352 * @return a status
353 */
354 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100355
356 // Inherited methods overridden:
357 void run() override;
358
359private:
360 struct Impl;
361 std::unique_ptr<Impl> _impl;
George Wortd88590f2018-12-12 17:39:58 +0000362};
363
364/** Basic function to run equal comparison. */
365using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>;
366/** Basic function to run not equal comparison. */
367using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>;
368/** Basic function to run greater comparison. */
369using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>;
370/** Basic function to run greater-equal comparison. */
371using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>;
372/** Basic function to run less comparison. */
373using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>;
374/** Basic function to run less-equal comparison. */
375using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>;
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100376
377namespace experimental
378{
379/** Basic function to run @ref NEArithmeticOperationKernel for max
380 *
381 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
382 * @note The function performs a max operation between two tensors.
383 */
384class NEElementwiseMax : public INEOperator
385{
386public:
387 /** Initialise the kernel's inputs, output and conversion policy.
388 *
389 * @param[in, out] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
390 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
391 * @param[out] output Output tensor info. Data types supported: Same as @p input1.
392 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
393 */
394 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
395 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for max
396 *
397 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
398 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
399 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
400 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
401 *
402 * @return a status
403 */
404 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
405
406 // Inherited methods overridden:
407 MemoryRequirements workspace() const override;
408};
409
410/** Basic function to run @ref NEArithmeticOperationKernel for min
411 *
412 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
413 * @note The function performs a min operation between two tensors.
414 */
415class NEElementwiseMin : public INEOperator
416{
417public:
418 /** Initialise the kernel's inputs, output and conversion policy.
419 *
420 * @param[in, out] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
421 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
422 * @param[out] output Output tensor info. Data types supported: Same as @p input1.
423 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
424 */
425 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
426 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for min
427 *
428 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
429 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
430 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
431 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
432 *
433 * @return a status
434 */
435 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
436
437 // Inherited methods overridden:
438 MemoryRequirements workspace() const override;
439};
440
441/** Basic function to run @ref NEArithmeticOperationKernel for squared difference
442 *
443 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
444 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
445 */
446class NEElementwiseSquaredDiff : public INEOperator
447{
448public:
449 /** Initialise the kernel's inputs, output and conversion policy.
450 *
451 * @param[in, out] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
452 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
453 * @param[out] output Output tensor info. Data types supported: Same as @p input1.
454 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
455 */
456 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
457 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for squared difference
458 *
459 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
460 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
461 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
462 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
463 *
464 * @return a status
465 */
466 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
467
468 // Inherited methods overridden:
469 MemoryRequirements workspace() const override;
470};
471
472/** Basic function to run @ref NEArithmeticOperationKernel for division
473 *
474 * @note The tensor data type for the inputs must be F16/F32.
475 * @note The function performs a squared different operation between two tensors (i.e., out[i] = in1[i] / in2[i])
476 */
477class NEElementwiseDivision : public INEOperator
478{
479public:
480 /** Initialise the kernel's inputs, output and conversion policy.
481 *
482 * @param[in, out] input1 First tensor input info. Data types supported: F16/F32.
483 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
484 * @param[out] output Output tensor info. Data types supported: Same as @p input1.
485 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
486 */
487 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
488 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for division
489 *
490 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
491 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
492 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
493 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
494 *
495 * @return a status
496 */
497 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
498
499 // Inherited methods overridden:
500 MemoryRequirements workspace() const override;
501};
502
503/** Basic function to run @ref NEArithmeticOperationKernel for power
504 *
505 * @note The tensor data type for the inputs must be F16/F32.
506 * @note The function performs a elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
507 * @note For an exponent that is a float, this function will only work with a positive base.
508 */
509class NEElementwisePower : public INEOperator
510{
511public:
512 /** Initialise the kernel's inputs, output and conversion policy.
513 *
514 * @param[in, out] input1 First tensor input info. Data types supported: F16/F32.
515 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
516 * @param[out] output Output tensor info. Data types supported: Same as @p input1.
517 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
518 */
519 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
520 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for power
521 *
522 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
523 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
524 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
525 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
526 *
527 * @return a status
528 */
529 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
530
531 // Inherited methods overridden:
532 MemoryRequirements workspace() const override;
533};
534
535/** Basic function to run @ref NEComparisonOperationKernel.
536 *
537 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
538 * @note The function performs a comparison operation between two tensors.
539 */
540class NEElementwiseComparison : public INEOperator
541{
542public:
543 /** Initialise the kernel's inputs, output and conversion policy.
544 *
545 * @param[in, out] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
546 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
547 * @param[out] output Output tensor info. Data types supported: U16/U32.
548 * @param[in] op Comparison Operation to be performed.
549 */
550 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output, ComparisonOperation op);
551 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
552 *
553 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
554 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
555 * @param[in] output Output tensor info. Data types supported: U16/U32.
556 * @param[in] op Comparison Operation to be performed.
557 *
558 * @return a status
559 */
560 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op);
561
562 // Inherited methods overridden:
563 MemoryRequirements workspace() const override;
564};
565
566/** Basic function to run @ref NEComparisonOperationKernel
567 *
568 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
569 * @note The function performs a comparison operation between two tensors.
570 */
571template <ComparisonOperation op>
572class NEElementwiseComparisonStatic : public INEOperator
573{
574public:
575 /** Initialise the kernel's inputs, output and conversion policy.
576 *
577 * @param[in, out] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
578 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
579 * @param[out] output Output tensor info. Data types supported: U16/U32.
580 */
581 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output);
582 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
583 *
584 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
585 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
586 * @param[in] output Output tensor info. Data types supported: U16/U32.
587 *
588 * @return a status
589 */
590 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
591
592 // Inherited methods overridden:
593 MemoryRequirements workspace() const override;
594};
595
596/** Basic function to run equal comparison. */
597using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>;
598/** Basic function to run not equal comparison. */
599using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>;
600/** Basic function to run greater comparison. */
601using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>;
602/** Basic function to run greater-equal comparison. */
603using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>;
604/** Basic function to run less comparison. */
605using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>;
606/** Basic function to run less-equal comparison. */
607using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>;
608} // namespace experimental
giuros0192fd9432018-12-03 17:30:00 +0000609} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000610#endif /* ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H */