blob: 95274bdb0c56ac1dafa63d61362152f1a4fb6012 [file] [log] [blame]
giuros0192fd9432018-12-03 17:30:00 +00001/*
Sang-Hoon Park63001ac2021-01-18 14:20:27 +00002 * Copyright (c) 2018-2021 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
Sang-Hoon Park63001ac2021-01-18 14:20:27 +000035/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for max
giuros0192fd9432018-12-03 17:30:00 +000036 *
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 *
Sheri Zhang6124ce62021-05-04 14:03:13 +010057 * Valid data layouts:
58 * - All
59 *
60 * Valid data type configurations:
61 * |src0 |src1 |dst |
62 * |:--------------|:--------------|:--------------|
63 * |QASYMM8 |QASYMM8 |QASYMM8 |
64 * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
65 * |S32 |S32 |S32 |
66 * |S16 |S16 |S16 |
67 * |F16 |F16 |F16 |
68 * |F32 |F32 |F32 |
69 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000070 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
71 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
72 * @param[out] output Output tensor. Data types supported: Same as @p input1.
73 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +000074 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000075 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sang-Hoon Park63001ac2021-01-18 14:20:27 +000076 /** 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 +000077 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000078 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
79 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
80 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
81 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +000082 *
83 * @return a status
84 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000085 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +010086
87 // Inherited methods overridden:
88 void run() override;
89
90private:
91 struct Impl;
92 std::unique_ptr<Impl> _impl;
giuros0192fd9432018-12-03 17:30:00 +000093};
94
Sang-Hoon Park63001ac2021-01-18 14:20:27 +000095/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for min
giuros0192fd9432018-12-03 17:30:00 +000096 *
morgolock6427c822020-01-13 11:53:20 +000097 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
98 * @note The function performs a min operation between two tensors.
giuros0192fd9432018-12-03 17:30:00 +000099 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100100class NEElementwiseMin : public IFunction
giuros0192fd9432018-12-03 17:30:00 +0000101{
102public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100103 /** Default Constructor */
104 NEElementwiseMin();
105 /** Default Destructor */
106 ~NEElementwiseMin();
107 /** Prevent instances of this class from being copied (As this class contains pointers) */
108 NEElementwiseMin(const NEElementwiseMin &) = delete;
109 /** Default move constructor */
110 NEElementwiseMin(NEElementwiseMin &&);
111 /** Prevent instances of this class from being copied (As this class contains pointers) */
112 NEElementwiseMin &operator=(const NEElementwiseMin &) = delete;
113 /** Default move assignment operator */
114 NEElementwiseMin &operator=(NEElementwiseMin &&);
giuros0192fd9432018-12-03 17:30:00 +0000115 /** Initialise the kernel's inputs, output and conversion policy.
116 *
Sheri Zhang6124ce62021-05-04 14:03:13 +0100117 * Valid data layouts:
118 * - All
119 *
120 * Valid data type configurations:
121 * |src0 |src1 |dst |
122 * |:--------------|:--------------|:--------------|
123 * |QASYMM8 |QASYMM8 |QASYMM8 |
124 * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
125 * |S32 |S32 |S32 |
126 * |S16 |S16 |S16 |
127 * |F16 |F16 |F16 |
128 * |F32 |F32 |F32 |
129 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000130 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
131 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
132 * @param[out] output Output tensor. Data types supported: Same as @p input1.
133 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000134 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000135 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000136 /** 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 +0000137 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000138 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
139 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
140 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
141 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000142 *
143 * @return a status
144 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000145 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100146
147 // Inherited methods overridden:
148 void run() override;
149
150private:
151 struct Impl;
152 std::unique_ptr<Impl> _impl;
giuros0192fd9432018-12-03 17:30:00 +0000153};
154
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000155/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for squared difference
giuros0192fd9432018-12-03 17:30:00 +0000156 *
morgolock6427c822020-01-13 11:53:20 +0000157 * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
giuros0192fd9432018-12-03 17:30:00 +0000158 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
159 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100160class NEElementwiseSquaredDiff : public IFunction
giuros0192fd9432018-12-03 17:30:00 +0000161{
162public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100163 /** Default Constructor */
164 NEElementwiseSquaredDiff();
165 /** Default Destructor */
166 ~NEElementwiseSquaredDiff();
167 /** Prevent instances of this class from being copied (As this class contains pointers) */
168 NEElementwiseSquaredDiff(const NEElementwiseSquaredDiff &) = delete;
169 /** Default move constructor */
170 NEElementwiseSquaredDiff(NEElementwiseSquaredDiff &&);
171 /** Prevent instances of this class from being copied (As this class contains pointers) */
172 NEElementwiseSquaredDiff &operator=(const NEElementwiseSquaredDiff &) = delete;
173 /** Default move assignment operator */
174 NEElementwiseSquaredDiff &operator=(NEElementwiseSquaredDiff &&);
giuros0192fd9432018-12-03 17:30:00 +0000175 /** Initialise the kernel's inputs, output and conversion policy.
176 *
Sheri Zhang6124ce62021-05-04 14:03:13 +0100177 * Valid data layouts:
178 * - All
179 *
180 * Valid data type configurations:
181 * |src0 |src1 |dst |
182 * |:--------------|:--------------|:--------------|
183 * |QASYMM8 |QASYMM8 |QASYMM8 |
184 * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
185 * |S32 |S32 |S32 |
186 * |S16 |S16 |S16 |
187 * |F16 |F16 |F16 |
188 * |F32 |F32 |F32 |
189 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000190 * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
191 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
192 * @param[out] output Output tensor. Data types supported: Same as @p input1.
193 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros0192fd9432018-12-03 17:30:00 +0000194 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000195 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000196 /** 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 +0000197 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000198 * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32.
199 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
200 * @param[in] output Output tensor info. 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.
giuros0192fd9432018-12-03 17:30:00 +0000202 *
203 * @return a status
204 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000205 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100206
207 // Inherited methods overridden:
208 void run() override;
209
210private:
211 struct Impl;
212 std::unique_ptr<Impl> _impl;
giuros0192fd9432018-12-03 17:30:00 +0000213};
George Wortd88590f2018-12-12 17:39:58 +0000214
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000215/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for division
George Worta1e7e282019-01-15 11:00:29 +0000216 *
217 * @note The tensor data type for the inputs must be F16/F32.
218 * @note The function performs a squared different operation between two tensors (i.e., out[i] = in1[i] / in2[i])
219 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100220class NEElementwiseDivision : public IFunction
George Worta1e7e282019-01-15 11:00:29 +0000221{
222public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100223 /** Default Constructor */
224 NEElementwiseDivision();
225 /** Default Destructor */
226 ~NEElementwiseDivision();
227 /** Prevent instances of this class from being copied (As this class contains pointers) */
228 NEElementwiseDivision(const NEElementwiseDivision &) = delete;
229 /** Default move constructor */
230 NEElementwiseDivision(NEElementwiseDivision &&);
231 /** Prevent instances of this class from being copied (As this class contains pointers) */
232 NEElementwiseDivision &operator=(const NEElementwiseDivision &) = delete;
233 /** Default move assignment operator */
234 NEElementwiseDivision &operator=(NEElementwiseDivision &&);
George Worta1e7e282019-01-15 11:00:29 +0000235 /** Initialise the kernel's inputs, output and conversion policy.
236 *
Sheri Zhang6124ce62021-05-04 14:03:13 +0100237 * Valid data layouts:
238 * - All
239 *
240 * Valid data type configurations:
241 * |src0 |src1 |dst |
242 * |:--------------|:--------------|:--------------|
243 * |F16 |F16 |F16 |
244 * |F32 |F32 |F32 |
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.
George Worta1e7e282019-01-15 11:00:29 +0000250 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000251 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000252 /** 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 +0000253 *
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.
George Worta1e7e282019-01-15 11:00:29 +0000258 *
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;
George Worta1e7e282019-01-15 11:00:29 +0000269};
270
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000271/** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for power
Usama Arif81e671e2019-05-13 13:33:14 +0100272 *
273 * @note The tensor data type for the inputs must be F16/F32.
274 * @note The function performs a elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
275 * @note For an exponent that is a float, this function will only work with a positive base.
276 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100277class NEElementwisePower : public IFunction
Usama Arif81e671e2019-05-13 13:33:14 +0100278{
279public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100280 /** Default Constructor */
281 NEElementwisePower();
282 /** Default Destructor */
283 ~NEElementwisePower();
284 /** Prevent instances of this class from being copied (As this class contains pointers) */
285 NEElementwisePower(const NEElementwisePower &) = delete;
286 /** Default move constructor */
287 NEElementwisePower(NEElementwisePower &&);
288 /** Prevent instances of this class from being copied (As this class contains pointers) */
289 NEElementwisePower &operator=(const NEElementwisePower &) = delete;
290 /** Default move assignment operator */
291 NEElementwisePower &operator=(NEElementwisePower &&);
Usama Arif81e671e2019-05-13 13:33:14 +0100292 /** Initialise the kernel's inputs, output and conversion policy.
293 *
Sheri Zhang6124ce62021-05-04 14:03:13 +0100294 * Valid data layouts:
295 * - All
296 *
297 * Valid data type configurations:
298 * |src0 |src1 |dst |
299 * |:--------------|:--------------|:--------------|
300 * |F16 |F16 |F16 |
301 * |F32 |F32 |F32 |
302 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000303 * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
304 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
305 * @param[out] output Output tensor. Data types supported: Same as @p input1.
306 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Usama Arif81e671e2019-05-13 13:33:14 +0100307 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000308 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000309 /** 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 +0100310 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000311 * @param[in] input1 First tensor input info. Data types supported: F16/F32.
312 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
313 * @param[in] output Output tensor info. Data types supported: Same as @p input1.
314 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Usama Arif81e671e2019-05-13 13:33:14 +0100315 *
316 * @return a status
317 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000318 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100319
320 // Inherited methods overridden:
321 void run() override;
322
323private:
324 struct Impl;
325 std::unique_ptr<Impl> _impl;
Usama Arif81e671e2019-05-13 13:33:14 +0100326};
327
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000328/** Basic function to run @ref cpu::kernels::CpuComparisonKernel.
George Wortd88590f2018-12-12 17:39:58 +0000329 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100330 * @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 +0000331 * @note The function performs a comparison operation between two tensors.
332 */
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100333class NEElementwiseComparison : public IFunction
George Wortd88590f2018-12-12 17:39:58 +0000334{
335public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100336 /** Default Constructor */
337 NEElementwiseComparison();
338 /** Default Destructor */
339 ~NEElementwiseComparison();
340 /** Prevent instances of this class from being copied (As this class contains pointers) */
341 NEElementwiseComparison(const NEElementwiseComparison &) = delete;
342 /** Default move constructor */
343 NEElementwiseComparison(NEElementwiseComparison &&);
344 /** Prevent instances of this class from being copied (As this class contains pointers) */
345 NEElementwiseComparison &operator=(const NEElementwiseComparison &) = delete;
346 /** Default move assignment operator */
347 NEElementwiseComparison &operator=(NEElementwiseComparison &&);
George Wortd88590f2018-12-12 17:39:58 +0000348 /** Initialise the kernel's inputs, output and conversion policy.
349 *
Sheri Zhang6124ce62021-05-04 14:03:13 +0100350 * Valid data layouts:
351 * - All
352 *
353 * Valid data type configurations:
354 * |src0 |src1 |dst |
355 * |:--------------|:--------------|:-----|
356 * |QASYMM8 |QASYMM8 |U8 |
357 * |QASYMM8_SIGNED |QASYMM8_SIGNED |U8 |
358 * |S32 |S32 |U8 |
359 * |U8 |U8 |U8 |
360 * |S16 |S16 |U8 |
361 * |F16 |F16 |U8 |
362 * |F32 |F32 |U8 |
363 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100364 * @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 +0000365 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +0100366 * @param[out] output Output tensor. Data types supported: U8.
George Wortd88590f2018-12-12 17:39:58 +0000367 * @param[in] op Comparison Operation to be performed.
368 */
369 void configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op);
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000370 /** 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 +0000371 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100372 * @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 +0000373 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
Michele Di Giorgiof9b595a2020-07-03 13:34:52 +0100374 * @param[in] output Output tensor info. Data types supported: U8.
George Wortd88590f2018-12-12 17:39:58 +0000375 * @param[in] op Comparison Operation to be performed.
376 *
377 * @return a status
378 */
379 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100380
381 // Inherited methods overridden:
382 void run() override;
383
384private:
385 struct Impl;
386 std::unique_ptr<Impl> _impl;
George Wortd88590f2018-12-12 17:39:58 +0000387};
388
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000389/** Basic function to run @ref cpu::kernels::CpuComparisonKernel
George Wortd88590f2018-12-12 17:39:58 +0000390 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100391 * @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 +0000392 * @note The function performs a comparison operation between two tensors.
393 */
394template <ComparisonOperation op>
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100395class NEElementwiseComparisonStatic : public IFunction
George Wortd88590f2018-12-12 17:39:58 +0000396{
397public:
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100398 /** Default Constructor */
399 NEElementwiseComparisonStatic();
400 /** Default Destructor */
401 ~NEElementwiseComparisonStatic();
402 /** Prevent instances of this class from being copied (As this class contains pointers) */
403 NEElementwiseComparisonStatic(const NEElementwiseComparisonStatic &) = delete;
404 /** Default move constructor */
405 NEElementwiseComparisonStatic(NEElementwiseComparisonStatic &&);
406 /** Prevent instances of this class from being copied (As this class contains pointers) */
407 NEElementwiseComparisonStatic &operator=(const NEElementwiseComparisonStatic &) = delete;
408 /** Default move assignment operator */
409 NEElementwiseComparisonStatic &operator=(NEElementwiseComparisonStatic &&);
George Wortd88590f2018-12-12 17:39:58 +0000410 /** Initialise the kernel's inputs, output and conversion policy.
411 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100412 * @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 +0000413 * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1.
414 * @param[out] output Output tensor. Data types supported: U16/U32.
415 */
416 void configure(ITensor *input1, ITensor *input2, ITensor *output);
Sang-Hoon Park63001ac2021-01-18 14:20:27 +0000417 /** 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 +0000418 *
Michele Di Giorgio1c76c1d2020-08-28 13:25:31 +0100419 * @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 +0000420 * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
421 * @param[in] output Output tensor info. Data types supported: U16/U32.
422 *
423 * @return a status
424 */
425 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output);
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100426
427 // Inherited methods overridden:
428 void run() override;
429
430private:
431 struct Impl;
432 std::unique_ptr<Impl> _impl;
George Wortd88590f2018-12-12 17:39:58 +0000433};
434
435/** Basic function to run equal comparison. */
436using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>;
437/** Basic function to run not equal comparison. */
438using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>;
439/** Basic function to run greater comparison. */
440using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>;
441/** Basic function to run greater-equal comparison. */
442using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>;
443/** Basic function to run less comparison. */
444using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>;
445/** Basic function to run less-equal comparison. */
446using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>;
Michalis Spyrouce0c6752020-06-18 10:14:57 +0100447
giuros0192fd9432018-12-03 17:30:00 +0000448} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000449#endif /* ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H */