blob: c91ae203bbb05378ac2d91bf1dca3fbcb12a2ae1 [file] [log] [blame]
giuros0192fd9432018-12-03 17:30:00 +00001/*
Matthew Benthamf1aeab92023-05-30 13:35:34 +00002 * Copyright (c) 2018-2021, 2023 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
Matthew Benthamf1aeab92023-05-30 13:35:34 +000027#include "arm_compute/core/ActivationLayerInfo.h"
giuros0192fd9432018-12-03 17:30:00 +000028#include "arm_compute/core/Types.h"
Michalis Spyrouce0c6752020-06-18 10:14:57 +010029#include "arm_compute/runtime/IFunction.h"
30#include "arm_compute/runtime/NEON/INEOperator.h"
giuros0192fd9432018-12-03 17:30:00 +000031
32namespace arm_compute
33{
34class ITensor;
35
Sang-Hoon Park63001ac2021-01-18 14:20:27 +000036/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for max
giuros0192fd9432018-12-03 17:30:00 +000037 *
morgolock6427c822020-01-13 11:53:20 +000038 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +000039 * @note The function performs a max operation between two tensors.
40 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +010041class NEElementwiseMax : public IFunction
giuros0192fd9432018-12-03 17:30:00 +000042{
43public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +010044 /** Default Constructor */
45 NEElementwiseMax();
46 /** Default Destructor */
47 ~NEElementwiseMax();
48 /** Prevent instances of this class from being copied (As this class contains pointers) */
49 NEElementwiseMax(const NEElementwiseMax &) = delete;
50 /** Default move constructor */
51 NEElementwiseMax(NEElementwiseMax &&);
52 /** Prevent instances of this class from being copied (As this class contains pointers) */
53 NEElementwiseMax &operator=(const NEElementwiseMax &) = delete;
54 /** Default move assignment operator */
55 NEElementwiseMax &operator=(NEElementwiseMax &&);
giuros0192fd9432018-12-03 17:30:00 +000056 /** Initialise the kernel's inputs, output and conversion policy.
57 *
Sheri Zhang6124ce62021-05-04 14:03:13 +010058 * Valid data layouts:
59 * - All
60 *
61 * Valid data type configurations:
62 * |src0 |src1 |dst |
63 * |:--------------|:--------------|:--------------|
64 * |QASYMM8 |QASYMM8 |QASYMM8 |
65 * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
66 * |S32 |S32 |S32 |
67 * |S16 |S16 |S16 |
68 * |F16 |F16 |F16 |
69 * |F32 |F32 |F32 |
70 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000071 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
72 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
73 * @param[out] output Output tensor. Data types supported: Same as @p input1.
74 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +000075 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000076 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sang-Hoon Park63001ac2021-01-18 14:20:27 +000077 /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for max
giuros0192fd9432018-12-03 17:30:00 +000078 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000079 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
80 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
81 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
82 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +000083 *
84 * @return a status
85 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000086 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +010087
88 // Inherited methods overridden:
89 void run() override;
90
91private:
92 struct Impl;
93 std::unique_ptr<Impl> _impl;
giuros0192fd9432018-12-03 17:30:00 +000094};
95
Sang-Hoon Park63001ac2021-01-18 14:20:27 +000096/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for min
giuros0192fd9432018-12-03 17:30:00 +000097 *
morgolock6427c822020-01-13 11:53:20 +000098 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
99 * @note The function performs a min operation between two tensors.
giuros0192fd9432018-12-03 17:30:00 +0000100 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100101class NEElementwiseMin : public IFunction
giuros0192fd9432018-12-03 17:30:00 +0000102{
103public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100104 /** Default Constructor */
105 NEElementwiseMin();
106 /** Default Destructor */
107 ~NEElementwiseMin();
108 /** Prevent instances of this class from being copied (As this class contains pointers) */
109 NEElementwiseMin(const NEElementwiseMin &) = delete;
110 /** Default move constructor */
111 NEElementwiseMin(NEElementwiseMin &&);
112 /** Prevent instances of this class from being copied (As this class contains pointers) */
113 NEElementwiseMin &operator=(const NEElementwiseMin &) = delete;
114 /** Default move assignment operator */
115 NEElementwiseMin &operator=(NEElementwiseMin &&);
giuros0192fd9432018-12-03 17:30:00 +0000116 /** Initialise the kernel's inputs, output and conversion policy.
117 *
Sheri Zhang6124ce62021-05-04 14:03:13 +0100118 * Valid data layouts:
119 * - All
120 *
121 * Valid data type configurations:
122 * |src0 |src1 |dst |
123 * |:--------------|:--------------|:--------------|
124 * |QASYMM8 |QASYMM8 |QASYMM8 |
125 * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
126 * |S32 |S32 |S32 |
127 * |S16 |S16 |S16 |
128 * |F16 |F16 |F16 |
129 * |F32 |F32 |F32 |
130 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000131 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
132 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
133 * @param[out] output Output tensor. Data types supported: Same as @p input1.
134 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000135 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000136 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000137 /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for min
giuros0192fd9432018-12-03 17:30:00 +0000138 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000139 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
140 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
141 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
142 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000143 *
144 * @return a status
145 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000146 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100147
148 // Inherited methods overridden:
149 void run() override;
150
151private:
152 struct Impl;
153 std::unique_ptr<Impl> _impl;
giuros0192fd9432018-12-03 17:30:00 +0000154};
155
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000156/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for squared difference
giuros0192fd9432018-12-03 17:30:00 +0000157 *
morgolock6427c822020-01-13 11:53:20 +0000158 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +0000159 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
160 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100161class NEElementwiseSquaredDiff : public IFunction
giuros0192fd9432018-12-03 17:30:00 +0000162{
163public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100164 /** Default Constructor */
165 NEElementwiseSquaredDiff();
166 /** Default Destructor */
167 ~NEElementwiseSquaredDiff();
168 /** Prevent instances of this class from being copied (As this class contains pointers) */
169 NEElementwiseSquaredDiff(const NEElementwiseSquaredDiff &) = delete;
170 /** Default move constructor */
171 NEElementwiseSquaredDiff(NEElementwiseSquaredDiff &&);
172 /** Prevent instances of this class from being copied (As this class contains pointers) */
173 NEElementwiseSquaredDiff &operator=(const NEElementwiseSquaredDiff &) = delete;
174 /** Default move assignment operator */
175 NEElementwiseSquaredDiff &operator=(NEElementwiseSquaredDiff &&);
giuros0192fd9432018-12-03 17:30:00 +0000176 /** Initialise the kernel's inputs, output and conversion policy.
177 *
Sheri Zhang6124ce62021-05-04 14:03:13 +0100178 * Valid data layouts:
179 * - All
180 *
181 * Valid data type configurations:
182 * |src0 |src1 |dst |
183 * |:--------------|:--------------|:--------------|
184 * |QASYMM8 |QASYMM8 |QASYMM8 |
185 * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
186 * |S32 |S32 |S32 |
187 * |S16 |S16 |S16 |
188 * |F16 |F16 |F16 |
189 * |F32 |F32 |F32 |
190 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000191 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
192 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
193 * @param[out] output Output tensor. Data types supported: Same as @p input1.
194 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000195 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000196 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000197 /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for squared difference
giuros0192fd9432018-12-03 17:30:00 +0000198 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000199 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
200 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
201 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
202 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000203 *
204 * @return a status
205 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000206 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100207
208 // Inherited methods overridden:
209 void run() override;
210
211private:
212 struct Impl;
213 std::unique_ptr<Impl> _impl;
giuros0192fd9432018-12-03 17:30:00 +0000214};
George Wortd88590f2018-12-12 17:39:58 +0000215
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000216/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for division
George Worta1e7e282019-01-15 11:00:29 +0000217 *
218 * @note The tensor data type for the inputs must be F16/F32.
219 * @note The function performs a squared different operation between two tensors (i.e., out[i] = in1[i] / in2[i])
220 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100221class NEElementwiseDivision : public IFunction
George Worta1e7e282019-01-15 11:00:29 +0000222{
223public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100224 /** Default Constructor */
225 NEElementwiseDivision();
226 /** Default Destructor */
227 ~NEElementwiseDivision();
228 /** Prevent instances of this class from being copied (As this class contains pointers) */
229 NEElementwiseDivision(const NEElementwiseDivision &) = delete;
230 /** Default move constructor */
231 NEElementwiseDivision(NEElementwiseDivision &&);
232 /** Prevent instances of this class from being copied (As this class contains pointers) */
233 NEElementwiseDivision &operator=(const NEElementwiseDivision &) = delete;
234 /** Default move assignment operator */
235 NEElementwiseDivision &operator=(NEElementwiseDivision &&);
George Worta1e7e282019-01-15 11:00:29 +0000236 /** Initialise the kernel's inputs, output and conversion policy.
237 *
Sheri Zhang6124ce62021-05-04 14:03:13 +0100238 * Valid data layouts:
239 * - All
240 *
241 * Valid data type configurations:
242 * |src0 |src1 |dst |
243 * |:--------------|:--------------|:--------------|
244 * |F16 |F16 |F16 |
245 * |F32 |F32 |F32 |
246 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000247 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
248 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
249 * @param[out] output Output tensor. Data types supported: Same as @p input1.
250 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
George Worta1e7e282019-01-15 11:00:29 +0000251 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000252 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000253 /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for division
George Worta1e7e282019-01-15 11:00:29 +0000254 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000255 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
256 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
257 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
258 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
George Worta1e7e282019-01-15 11:00:29 +0000259 *
260 * @return a status
261 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000262 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100263
264 // Inherited methods overridden:
265 void run() override;
266
267private:
268 struct Impl;
269 std::unique_ptr<Impl> _impl;
George Worta1e7e282019-01-15 11:00:29 +0000270};
271
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000272/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for power
Usama Arif81e671e2019-05-13 13:33:14 +0100273 *
274 * @note The tensor data type for the inputs must be F16/F32.
275 * @note The function performs a elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
276 * @note For an exponent that is a float, this function will only work with a positive base.
277 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100278class NEElementwisePower : public IFunction
Usama Arif81e671e2019-05-13 13:33:14 +0100279{
280public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100281 /** Default Constructor */
282 NEElementwisePower();
283 /** Default Destructor */
284 ~NEElementwisePower();
285 /** Prevent instances of this class from being copied (As this class contains pointers) */
286 NEElementwisePower(const NEElementwisePower &) = delete;
287 /** Default move constructor */
288 NEElementwisePower(NEElementwisePower &&);
289 /** Prevent instances of this class from being copied (As this class contains pointers) */
290 NEElementwisePower &operator=(const NEElementwisePower &) = delete;
291 /** Default move assignment operator */
292 NEElementwisePower &operator=(NEElementwisePower &&);
Usama Arif81e671e2019-05-13 13:33:14 +0100293 /** Initialise the kernel's inputs, output and conversion policy.
294 *
Sheri Zhang6124ce62021-05-04 14:03:13 +0100295 * Valid data layouts:
296 * - All
297 *
298 * Valid data type configurations:
299 * |src0 |src1 |dst |
300 * |:--------------|:--------------|:--------------|
301 * |F16 |F16 |F16 |
302 * |F32 |F32 |F32 |
303 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000304 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
305 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
306 * @param[out] output Output tensor. Data types supported: Same as @p input1.
307 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Usama Arif81e671e2019-05-13 13:33:14 +0100308 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000309 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000310 /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for power
Usama Arif81e671e2019-05-13 13:33:14 +0100311 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000312 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
313 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
314 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
315 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Usama Arif81e671e2019-05-13 13:33:14 +0100316 *
317 * @return a status
318 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000319 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100320
321 // Inherited methods overridden:
322 void run() override;
323
324private:
325 struct Impl;
326 std::unique_ptr<Impl> _impl;
Usama Arif81e671e2019-05-13 13:33:14 +0100327};
328
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000329/** Basic function to run @ref cpu::kernels::CpuComparisonKernel.
George Wortd88590f2018-12-12 17:39:58 +0000330 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100331 * @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 +0000332 * @note The function performs a comparison operation between two tensors.
333 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100334class NEElementwiseComparison : public IFunction
George Wortd88590f2018-12-12 17:39:58 +0000335{
336public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100337 /** Default Constructor */
338 NEElementwiseComparison();
339 /** Default Destructor */
340 ~NEElementwiseComparison();
341 /** Prevent instances of this class from being copied (As this class contains pointers) */
342 NEElementwiseComparison(const NEElementwiseComparison &) = delete;
343 /** Default move constructor */
344 NEElementwiseComparison(NEElementwiseComparison &&);
345 /** Prevent instances of this class from being copied (As this class contains pointers) */
346 NEElementwiseComparison &operator=(const NEElementwiseComparison &) = delete;
347 /** Default move assignment operator */
348 NEElementwiseComparison &operator=(NEElementwiseComparison &&);
George Wortd88590f2018-12-12 17:39:58 +0000349 /** Initialise the kernel's inputs, output and conversion policy.
350 *
Sheri Zhang6124ce62021-05-04 14:03:13 +0100351 * Valid data layouts:
352 * - All
353 *
354 * Valid data type configurations:
355 * |src0 |src1 |dst |
356 * |:--------------|:--------------|:-----|
357 * |QASYMM8 |QASYMM8 |U8 |
358 * |QASYMM8_SIGNED |QASYMM8_SIGNED |U8 |
359 * |S32 |S32 |U8 |
360 * |U8 |U8 |U8 |
361 * |S16 |S16 |U8 |
362 * |F16 |F16 |U8 |
363 * |F32 |F32 |U8 |
364 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100365 * @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 +0000366 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +0100367 * @param[out] output Output tensor. Data types supported: U8.
George Wortd88590f2018-12-12 17:39:58 +0000368 * @param[in] op Comparison Operation to be performed.
369 */
370 void configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op);
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000371 /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuComparisonKernel
George Wortd88590f2018-12-12 17:39:58 +0000372 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100373 * @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 +0000374 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +0100375 * @param[in] output Output tensor info. Data types supported: U8.
George Wortd88590f2018-12-12 17:39:58 +0000376 * @param[in] op Comparison Operation to be performed.
377 *
378 * @return a status
379 */
380 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100381
382 // Inherited methods overridden:
383 void run() override;
384
385private:
386 struct Impl;
387 std::unique_ptr<Impl> _impl;
George Wortd88590f2018-12-12 17:39:58 +0000388};
389
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000390/** Basic function to run @ref cpu::kernels::CpuComparisonKernel
George Wortd88590f2018-12-12 17:39:58 +0000391 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100392 * @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 +0000393 * @note The function performs a comparison operation between two tensors.
394 */
395template <ComparisonOperation op>
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100396class NEElementwiseComparisonStatic : public IFunction
George Wortd88590f2018-12-12 17:39:58 +0000397{
398public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100399 /** Default Constructor */
400 NEElementwiseComparisonStatic();
401 /** Default Destructor */
402 ~NEElementwiseComparisonStatic();
403 /** Prevent instances of this class from being copied (As this class contains pointers) */
404 NEElementwiseComparisonStatic(const NEElementwiseComparisonStatic &) = delete;
405 /** Default move constructor */
406 NEElementwiseComparisonStatic(NEElementwiseComparisonStatic &&);
407 /** Prevent instances of this class from being copied (As this class contains pointers) */
408 NEElementwiseComparisonStatic &operator=(const NEElementwiseComparisonStatic &) = delete;
409 /** Default move assignment operator */
410 NEElementwiseComparisonStatic &operator=(NEElementwiseComparisonStatic &&);
George Wortd88590f2018-12-12 17:39:58 +0000411 /** Initialise the kernel's inputs, output and conversion policy.
412 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100413 * @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 +0000414 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
415 * @param[out] output Output tensor. Data types supported: U16/U32.
416 */
417 void configure(ITensor *input1, ITensor *input2, ITensor *output);
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000418 /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuComparisonKernel
George Wortd88590f2018-12-12 17:39:58 +0000419 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100420 * @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 +0000421 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
422 * @param[in] output Output tensor info. Data types supported: U16/U32.
423 *
424 * @return a status
425 */
426 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100427
428 // Inherited methods overridden:
429 void run() override;
430
431private:
432 struct Impl;
433 std::unique_ptr<Impl> _impl;
George Wortd88590f2018-12-12 17:39:58 +0000434};
435
436/** Basic function to run equal comparison. */
437using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>;
438/** Basic function to run not equal comparison. */
439using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>;
440/** Basic function to run greater comparison. */
441using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>;
442/** Basic function to run greater-equal comparison. */
443using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>;
444/** Basic function to run less comparison. */
445using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>;
446/** Basic function to run less-equal comparison. */
447using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>;
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100448
giuros0192fd9432018-12-03 17:30:00 +0000449} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000450#endif /* ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H */