blob: 5c755e96acdc961339491f1ad7843bdb6b110969 [file] [log] [blame]
giuros0192fd9432018-12-03 17:30:00 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * 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 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100273 * @note The tensor data type for the inputs must be U8/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 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100293 * @param[in, out] input1 First tensor input. Data types supported: U8/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.
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +0100295 * @param[out] output Output tensor. Data types supported: U8.
George Wortd88590f2018-12-12 17:39:58 +0000296 * @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 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100301 * @param[in] input1 First tensor input info. Data types supported: U8/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.
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +0100303 * @param[in] output Output tensor info. Data types supported: U8.
George Wortd88590f2018-12-12 17:39:58 +0000304 * @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 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100320 * @note The tensor data type for the inputs must be U8/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 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100341 * @param[in, out] input1 First tensor input. Data types supported: U8/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 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100348 * @param[in] input1 First tensor input info. Data types supported: U8/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 *
Georgios Pinitas09cad722020-07-22 12:11:20 +0100389 * @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.
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100392 */
Georgios Pinitas09cad722020-07-22 12:11:20 +0100393 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100394 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for max
395 *
Georgios Pinitas09cad722020-07-22 12:11:20 +0100396 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
397 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
398 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100399 *
400 * @return a status
401 */
Georgios Pinitas09cad722020-07-22 12:11:20 +0100402 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100403};
404
405/** Basic function to run @ref NEArithmeticOperationKernel for min
406 *
407 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
408 * @note The function performs a min operation between two tensors.
409 */
410class NEElementwiseMin : public INEOperator
411{
412public:
413 /** Initialise the kernel's inputs, output and conversion policy.
414 *
Georgios Pinitas09cad722020-07-22 12:11:20 +0100415 * @param[in, out] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
416 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
417 * @param[out] output Output tensor info. Data types supported: Same as @p input1.
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100418 */
Georgios Pinitas09cad722020-07-22 12:11:20 +0100419 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100420 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for min
421 *
Georgios Pinitas09cad722020-07-22 12:11:20 +0100422 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
423 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
424 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100425 *
426 * @return a status
427 */
Georgios Pinitas09cad722020-07-22 12:11:20 +0100428 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100429};
430
431/** Basic function to run @ref NEArithmeticOperationKernel for squared difference
432 *
433 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
434 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
435 */
436class NEElementwiseSquaredDiff : public INEOperator
437{
438public:
439 /** Initialise the kernel's inputs, output and conversion policy.
440 *
Georgios Pinitas09cad722020-07-22 12:11:20 +0100441 * @param[in, out] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
442 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
443 * @param[out] output Output tensor info. Data types supported: Same as @p input1.
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100444 */
Georgios Pinitas09cad722020-07-22 12:11:20 +0100445 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100446 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for squared difference
447 *
Georgios Pinitas09cad722020-07-22 12:11:20 +0100448 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
449 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
450 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100451 *
452 * @return a status
453 */
Georgios Pinitas09cad722020-07-22 12:11:20 +0100454 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100455};
456
457/** Basic function to run @ref NEArithmeticOperationKernel for division
458 *
Georgios Pinitas18134222020-09-03 21:00:23 +0100459 * @note The tensor data type for the inputs must be S32/F16/F32.
460 * @note The function performs a division operation between two tensors (i.e., out[i] = in1[i] / in2[i])
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100461 */
462class NEElementwiseDivision : public INEOperator
463{
464public:
465 /** Initialise the kernel's inputs, output and conversion policy.
466 *
Georgios Pinitas18134222020-09-03 21:00:23 +0100467 * @param[in, out] input1 First tensor input info. Data types supported: S32/F16/F32.
Georgios Pinitas09cad722020-07-22 12:11:20 +0100468 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
469 * @param[out] output Output tensor info. Data types supported: Same as @p input1.
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100470 */
Georgios Pinitas09cad722020-07-22 12:11:20 +0100471 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100472 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for division
473 *
Georgios Pinitas18134222020-09-03 21:00:23 +0100474 * @param[in] input1 First tensor input info. Data types supported: S32/F16/F32.
Georgios Pinitas09cad722020-07-22 12:11:20 +0100475 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
476 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100477 *
478 * @return a status
479 */
Georgios Pinitas09cad722020-07-22 12:11:20 +0100480 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100481};
482
483/** Basic function to run @ref NEArithmeticOperationKernel for power
484 *
485 * @note The tensor data type for the inputs must be F16/F32.
486 * @note The function performs a elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
487 * @note For an exponent that is a float, this function will only work with a positive base.
488 */
489class NEElementwisePower : public INEOperator
490{
491public:
492 /** Initialise the kernel's inputs, output and conversion policy.
493 *
Georgios Pinitas09cad722020-07-22 12:11:20 +0100494 * @param[in, out] input1 First tensor input info. Data types supported: F16/F32.
495 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
496 * @param[out] output Output tensor info. Data types supported: Same as @p input1.
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100497 */
Georgios Pinitas09cad722020-07-22 12:11:20 +0100498 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100499 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for power
500 *
Georgios Pinitas09cad722020-07-22 12:11:20 +0100501 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
502 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
503 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100504 *
505 * @return a status
506 */
Georgios Pinitas09cad722020-07-22 12:11:20 +0100507 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100508};
509
510/** Basic function to run @ref NEComparisonOperationKernel.
511 *
512 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
513 * @note The function performs a comparison operation between two tensors.
514 */
515class NEElementwiseComparison : public INEOperator
516{
517public:
518 /** Initialise the kernel's inputs, output and conversion policy.
519 *
520 * @param[in, out] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
521 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
522 * @param[out] output Output tensor info. Data types supported: U16/U32.
523 * @param[in] op Comparison Operation to be performed.
524 */
525 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output, ComparisonOperation op);
526 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
527 *
528 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
529 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
530 * @param[in] output Output tensor info. Data types supported: U16/U32.
531 * @param[in] op Comparison Operation to be performed.
532 *
533 * @return a status
534 */
535 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100536};
537
538/** Basic function to run @ref NEComparisonOperationKernel
539 *
540 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
541 * @note The function performs a comparison operation between two tensors.
542 */
543template <ComparisonOperation op>
544class NEElementwiseComparisonStatic : public INEOperator
545{
546public:
547 /** Initialise the kernel's inputs, output and conversion policy.
548 *
549 * @param[in, out] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
550 * @param[in, out] input2 Second tensor input info. Data types supported: Same as @p input1.
551 * @param[out] output Output tensor info. Data types supported: U16/U32.
552 */
553 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output);
554 /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel
555 *
556 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
557 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
558 * @param[in] output Output tensor info. Data types supported: U16/U32.
559 *
560 * @return a status
561 */
562 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100563};
564
565/** Basic function to run equal comparison. */
566using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>;
567/** Basic function to run not equal comparison. */
568using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>;
569/** Basic function to run greater comparison. */
570using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>;
571/** Basic function to run greater-equal comparison. */
572using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>;
573/** Basic function to run less comparison. */
574using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>;
575/** Basic function to run less-equal comparison. */
576using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>;
577} // namespace experimental
giuros0192fd9432018-12-03 17:30:00 +0000578} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000579#endif /* ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H */