| 1 |
/* |
| 2 |
* Copyright (c) 2018-2021, 2023-2024 Arm Limited. |
| 3 |
* |
| 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 |
| 17 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 |
* 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, |
| 21 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 |
* SOFTWARE. |
| 23 |
*/ |
| 24 |
#ifndef ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEELEMENTWISEOPERATIONS_H |
| 25 |
#define ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEELEMENTWISEOPERATIONS_H |
| 26 |
|
| 27 |
#include "arm_compute/core/Types.h" |
| 28 |
#include "arm_compute/function_info/ActivationLayerInfo.h" |
| 29 |
#include "arm_compute/runtime/IFunction.h" |
| 30 |
#include "arm_compute/runtime/NEON/INEOperator.h" |
| 31 |
|
| 32 |
namespace arm_compute |
| 33 |
{ |
| 34 |
class ITensor; |
| 35 |
|
| 36 |
/** Basic function to run cpu::kernels::CpuArithmeticKernel for max |
| 37 |
* |
| 38 |
* @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 39 |
* @note The function performs a max operation between two tensors. |
| 40 |
*/ |
| 41 |
class NEElementwiseMax : public IFunction |
| 42 |
{ |
| 43 |
public: |
| 44 |
/** 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 &&); |
| 56 |
/** Initialise the kernel's inputs, output and conversion policy. |
| 57 |
* |
| 58 |
* 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 |
* |
| 71 |
* @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. |
| 75 |
*/ |
| 76 |
void configure(ITensor *input1, |
| 77 |
ITensor *input2, |
| 78 |
ITensor *output, |
| 79 |
const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 80 |
/** Static function to check if given info will lead to a valid configuration of cpu::kernels::CpuArithmeticKernel for max |
| 81 |
* |
| 82 |
* @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 83 |
* @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 84 |
* @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 85 |
* @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. |
| 86 |
* |
| 87 |
* @return a status |
| 88 |
*/ |
| 89 |
static Status validate(const ITensorInfo *input1, |
| 90 |
const ITensorInfo *input2, |
| 91 |
const ITensorInfo *output, |
| 92 |
const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 93 |
|
| 94 |
// Inherited methods overridden: |
| 95 |
void run() override; |
| 96 |
|
| 97 |
private: |
| 98 |
struct Impl; |
| 99 |
std::unique_ptr<Impl> _impl; |
| 100 |
}; |
| 101 |
|
| 102 |
/** Basic function to run cpu::kernels::CpuArithmeticKernel for min |
| 103 |
* |
| 104 |
* @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 105 |
* @note The function performs a min operation between two tensors. |
| 106 |
*/ |
| 107 |
class NEElementwiseMin : public IFunction |
| 108 |
{ |
| 109 |
public: |
| 110 |
/** Default Constructor */ |
| 111 |
NEElementwiseMin(); |
| 112 |
/** Default Destructor */ |
| 113 |
~NEElementwiseMin(); |
| 114 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 115 |
NEElementwiseMin(const NEElementwiseMin &) = delete; |
| 116 |
/** Default move constructor */ |
| 117 |
NEElementwiseMin(NEElementwiseMin &&); |
| 118 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 119 |
NEElementwiseMin &operator=(const NEElementwiseMin &) = delete; |
| 120 |
/** Default move assignment operator */ |
| 121 |
NEElementwiseMin &operator=(NEElementwiseMin &&); |
| 122 |
/** Initialise the kernel's inputs, output and conversion policy. |
| 123 |
* |
| 124 |
* Valid data layouts: |
| 125 |
* - All |
| 126 |
* |
| 127 |
* Valid data type configurations: |
| 128 |
* |src0 |src1 |dst | |
| 129 |
* |:--------------|:--------------|:--------------| |
| 130 |
* |QASYMM8 |QASYMM8 |QASYMM8 | |
| 131 |
* |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED | |
| 132 |
* |S32 |S32 |S32 | |
| 133 |
* |S16 |S16 |S16 | |
| 134 |
* |F16 |F16 |F16 | |
| 135 |
* |F32 |F32 |F32 | |
| 136 |
* |
| 137 |
* @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 138 |
* @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 139 |
* @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 140 |
* @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. |
| 141 |
*/ |
| 142 |
void configure(ITensor *input1, |
| 143 |
ITensor *input2, |
| 144 |
ITensor *output, |
| 145 |
const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 146 |
/** Static function to check if given info will lead to a valid configuration of cpu::kernels::CpuArithmeticKernel for min |
| 147 |
* |
| 148 |
* @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 149 |
* @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 150 |
* @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 151 |
* @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. |
| 152 |
* |
| 153 |
* @return a status |
| 154 |
*/ |
| 155 |
static Status validate(const ITensorInfo *input1, |
| 156 |
const ITensorInfo *input2, |
| 157 |
const ITensorInfo *output, |
| 158 |
const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 159 |
|
| 160 |
// Inherited methods overridden: |
| 161 |
void run() override; |
| 162 |
|
| 163 |
private: |
| 164 |
struct Impl; |
| 165 |
std::unique_ptr<Impl> _impl; |
| 166 |
}; |
| 167 |
|
| 168 |
/** Basic function to run cpu::kernels::CpuArithmeticKernel for squared difference |
| 169 |
* |
| 170 |
* @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 171 |
* @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2 |
| 172 |
*/ |
| 173 |
class NEElementwiseSquaredDiff : public IFunction |
| 174 |
{ |
| 175 |
public: |
| 176 |
/** Default Constructor */ |
| 177 |
NEElementwiseSquaredDiff(); |
| 178 |
/** Default Destructor */ |
| 179 |
~NEElementwiseSquaredDiff(); |
| 180 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 181 |
NEElementwiseSquaredDiff(const NEElementwiseSquaredDiff &) = delete; |
| 182 |
/** Default move constructor */ |
| 183 |
NEElementwiseSquaredDiff(NEElementwiseSquaredDiff &&); |
| 184 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 185 |
NEElementwiseSquaredDiff &operator=(const NEElementwiseSquaredDiff &) = delete; |
| 186 |
/** Default move assignment operator */ |
| 187 |
NEElementwiseSquaredDiff &operator=(NEElementwiseSquaredDiff &&); |
| 188 |
/** Initialise the kernel's inputs, output and conversion policy. |
| 189 |
* |
| 190 |
* Valid data layouts: |
| 191 |
* - All |
| 192 |
* |
| 193 |
* Valid data type configurations: |
| 194 |
* |src0 |src1 |dst | |
| 195 |
* |:--------------|:--------------|:--------------| |
| 196 |
* |QASYMM8 |QASYMM8 |QASYMM8 | |
| 197 |
* |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED | |
| 198 |
* |S32 |S32 |S32 | |
| 199 |
* |S16 |S16 |S16 | |
| 200 |
* |F16 |F16 |F16 | |
| 201 |
* |F32 |F32 |F32 | |
| 202 |
* |
| 203 |
* @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 204 |
* @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 205 |
* @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 206 |
* @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. |
| 207 |
*/ |
| 208 |
void configure(ITensor *input1, |
| 209 |
ITensor *input2, |
| 210 |
ITensor *output, |
| 211 |
const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 212 |
/** Static function to check if given info will lead to a valid configuration of cpu::kernels::CpuArithmeticKernel for squared difference |
| 213 |
* |
| 214 |
* @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 215 |
* @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 216 |
* @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 217 |
* @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. |
| 218 |
* |
| 219 |
* @return a status |
| 220 |
*/ |
| 221 |
static Status validate(const ITensorInfo *input1, |
| 222 |
const ITensorInfo *input2, |
| 223 |
const ITensorInfo *output, |
| 224 |
const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 225 |
|
| 226 |
// Inherited methods overridden: |
| 227 |
void run() override; |
| 228 |
|
| 229 |
private: |
| 230 |
struct Impl; |
| 231 |
std::unique_ptr<Impl> _impl; |
| 232 |
}; |
| 233 |
|
| 234 |
/** Basic function to run cpu::kernels::CpuArithmeticKernel for division |
| 235 |
* |
| 236 |
* @note The tensor data type for the inputs must be F16/F32. |
| 237 |
* @note The function performs a squared different operation between two tensors (i.e., out[i] = in1[i] / in2[i]) |
| 238 |
*/ |
| 239 |
class NEElementwiseDivision : public IFunction |
| 240 |
{ |
| 241 |
public: |
| 242 |
/** Default Constructor */ |
| 243 |
NEElementwiseDivision(); |
| 244 |
/** Default Destructor */ |
| 245 |
~NEElementwiseDivision(); |
| 246 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 247 |
NEElementwiseDivision(const NEElementwiseDivision &) = delete; |
| 248 |
/** Default move constructor */ |
| 249 |
NEElementwiseDivision(NEElementwiseDivision &&); |
| 250 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 251 |
NEElementwiseDivision &operator=(const NEElementwiseDivision &) = delete; |
| 252 |
/** Default move assignment operator */ |
| 253 |
NEElementwiseDivision &operator=(NEElementwiseDivision &&); |
| 254 |
/** Initialise the kernel's inputs, output and conversion policy. |
| 255 |
* |
| 256 |
* Valid data layouts: |
| 257 |
* - All |
| 258 |
* |
| 259 |
* Valid data type configurations: |
| 260 |
* |src0 |src1 |dst | |
| 261 |
* |:--------------|:--------------|:--------------| |
| 262 |
* |F16 |F16 |F16 | |
| 263 |
* |F32 |F32 |F32 | |
| 264 |
* |
| 265 |
* @param[in, out] input1 First tensor input. Data types supported: F16/F32. |
| 266 |
* @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 267 |
* @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 268 |
* @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. |
| 269 |
*/ |
| 270 |
void configure(ITensor *input1, |
| 271 |
ITensor *input2, |
| 272 |
ITensor *output, |
| 273 |
const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 274 |
/** Static function to check if given info will lead to a valid configuration of cpu::kernels::CpuArithmeticKernel for division |
| 275 |
* |
| 276 |
* @param[in] input1 First tensor input info. Data types supported: F16/F32. |
| 277 |
* @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 278 |
* @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 279 |
* @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. |
| 280 |
* |
| 281 |
* @return a status |
| 282 |
*/ |
| 283 |
static Status validate(const ITensorInfo *input1, |
| 284 |
const ITensorInfo *input2, |
| 285 |
const ITensorInfo *output, |
| 286 |
const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 287 |
|
| 288 |
// Inherited methods overridden: |
| 289 |
void run() override; |
| 290 |
|
| 291 |
private: |
| 292 |
struct Impl; |
| 293 |
std::unique_ptr<Impl> _impl; |
| 294 |
}; |
| 295 |
|
| 296 |
/** Basic function to run cpu::kernels::CpuArithmeticKernel for power |
| 297 |
* |
| 298 |
* @note The tensor data type for the inputs must be F16/F32. |
| 299 |
* @note The function performs a elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i]) |
| 300 |
* @note For an exponent that is a float, this function will only work with a positive base. |
| 301 |
*/ |
| 302 |
class NEElementwisePower : public IFunction |
| 303 |
{ |
| 304 |
public: |
| 305 |
/** Default Constructor */ |
| 306 |
NEElementwisePower(); |
| 307 |
/** Default Destructor */ |
| 308 |
~NEElementwisePower(); |
| 309 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 310 |
NEElementwisePower(const NEElementwisePower &) = delete; |
| 311 |
/** Default move constructor */ |
| 312 |
NEElementwisePower(NEElementwisePower &&); |
| 313 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 314 |
NEElementwisePower &operator=(const NEElementwisePower &) = delete; |
| 315 |
/** Default move assignment operator */ |
| 316 |
NEElementwisePower &operator=(NEElementwisePower &&); |
| 317 |
/** Initialise the kernel's inputs, output and conversion policy. |
| 318 |
* |
| 319 |
* Valid data layouts: |
| 320 |
* - All |
| 321 |
* |
| 322 |
* Valid data type configurations: |
| 323 |
* |src0 |src1 |dst | |
| 324 |
* |:--------------|:--------------|:--------------| |
| 325 |
* |F16 |F16 |F16 | |
| 326 |
* |F32 |F32 |F32 | |
| 327 |
* |
| 328 |
* @param[in, out] input1 First tensor input. Data types supported: F16/F32. |
| 329 |
* @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 330 |
* @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 331 |
* @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. |
| 332 |
*/ |
| 333 |
void configure(ITensor *input1, |
| 334 |
ITensor *input2, |
| 335 |
ITensor *output, |
| 336 |
const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 337 |
/** Static function to check if given info will lead to a valid configuration of cpu::kernels::CpuArithmeticKernel for power |
| 338 |
* |
| 339 |
* @param[in] input1 First tensor input info. Data types supported: F16/F32. |
| 340 |
* @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 341 |
* @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 342 |
* @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. |
| 343 |
* |
| 344 |
* @return a status |
| 345 |
*/ |
| 346 |
static Status validate(const ITensorInfo *input1, |
| 347 |
const ITensorInfo *input2, |
| 348 |
const ITensorInfo *output, |
| 349 |
const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 350 |
|
| 351 |
// Inherited methods overridden: |
| 352 |
void run() override; |
| 353 |
|
| 354 |
private: |
| 355 |
struct Impl; |
| 356 |
std::unique_ptr<Impl> _impl; |
| 357 |
}; |
| 358 |
|
| 359 |
/** Basic function to run cpu::kernels::CpuComparisonKernel. |
| 360 |
* |
| 361 |
* @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 362 |
* @note The function performs a comparison operation between two tensors. |
| 363 |
*/ |
| 364 |
class NEElementwiseComparison : public IFunction |
| 365 |
{ |
| 366 |
public: |
| 367 |
/** Default Constructor */ |
| 368 |
NEElementwiseComparison(); |
| 369 |
/** Default Destructor */ |
| 370 |
~NEElementwiseComparison(); |
| 371 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 372 |
NEElementwiseComparison(const NEElementwiseComparison &) = delete; |
| 373 |
/** Default move constructor */ |
| 374 |
NEElementwiseComparison(NEElementwiseComparison &&); |
| 375 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 376 |
NEElementwiseComparison &operator=(const NEElementwiseComparison &) = delete; |
| 377 |
/** Default move assignment operator */ |
| 378 |
NEElementwiseComparison &operator=(NEElementwiseComparison &&); |
| 379 |
/** Initialise the kernel's inputs, output and conversion policy. |
| 380 |
* |
| 381 |
* Valid data layouts: |
| 382 |
* - All |
| 383 |
* |
| 384 |
* Valid data type configurations: |
| 385 |
* |src0 |src1 |dst | |
| 386 |
* |:--------------|:--------------|:-----| |
| 387 |
* |QASYMM8 |QASYMM8 |U8 | |
| 388 |
* |QASYMM8_SIGNED |QASYMM8_SIGNED |U8 | |
| 389 |
* |S32 |S32 |U8 | |
| 390 |
* |U8 |U8 |U8 | |
| 391 |
* |S16 |S16 |U8 | |
| 392 |
* |F16 |F16 |U8 | |
| 393 |
* |F32 |F32 |U8 | |
| 394 |
* |
| 395 |
* @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 396 |
* @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 397 |
* @param[out] output Output tensor. Data types supported: U8. |
| 398 |
* @param[in] op Comparison Operation to be performed. |
| 399 |
*/ |
| 400 |
void configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op); |
| 401 |
/** Static function to check if given info will lead to a valid configuration of cpu::kernels::CpuComparisonKernel |
| 402 |
* |
| 403 |
* @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 404 |
* @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 405 |
* @param[in] output Output tensor info. Data types supported: U8. |
| 406 |
* @param[in] op Comparison Operation to be performed. |
| 407 |
* |
| 408 |
* @return a status |
| 409 |
*/ |
| 410 |
static Status |
| 411 |
validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op); |
| 412 |
|
| 413 |
// Inherited methods overridden: |
| 414 |
void run() override; |
| 415 |
|
| 416 |
private: |
| 417 |
struct Impl; |
| 418 |
std::unique_ptr<Impl> _impl; |
| 419 |
}; |
| 420 |
|
| 421 |
/** Basic function to run cpu::kernels::CpuComparisonKernel |
| 422 |
* |
| 423 |
* @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 424 |
* @note The function performs a comparison operation between two tensors. |
| 425 |
*/ |
| 426 |
template <ComparisonOperation op> |
| 427 |
class NEElementwiseComparisonStatic : public IFunction |
| 428 |
{ |
| 429 |
public: |
| 430 |
/** Default Constructor */ |
| 431 |
NEElementwiseComparisonStatic(); |
| 432 |
/** Default Destructor */ |
| 433 |
~NEElementwiseComparisonStatic(); |
| 434 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 435 |
NEElementwiseComparisonStatic(const NEElementwiseComparisonStatic &) = delete; |
| 436 |
/** Default move constructor */ |
| 437 |
NEElementwiseComparisonStatic(NEElementwiseComparisonStatic &&); |
| 438 |
/** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 439 |
NEElementwiseComparisonStatic &operator=(const NEElementwiseComparisonStatic &) = delete; |
| 440 |
/** Default move assignment operator */ |
| 441 |
NEElementwiseComparisonStatic &operator=(NEElementwiseComparisonStatic &&); |
| 442 |
/** Initialise the kernel's inputs, output and conversion policy. |
| 443 |
* |
| 444 |
* @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 445 |
* @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 446 |
* @param[out] output Output tensor. Data types supported: U16/U32. |
| 447 |
*/ |
| 448 |
void configure(ITensor *input1, ITensor *input2, ITensor *output); |
| 449 |
/** Static function to check if given info will lead to a valid configuration of cpu::kernels::CpuComparisonKernel |
| 450 |
* |
| 451 |
* @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
| 452 |
* @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 453 |
* @param[in] output Output tensor info. Data types supported: U16/U32. |
| 454 |
* |
| 455 |
* @return a status |
| 456 |
*/ |
| 457 |
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output); |
| 458 |
|
| 459 |
// Inherited methods overridden: |
| 460 |
void run() override; |
| 461 |
|
| 462 |
private: |
| 463 |
struct Impl; |
| 464 |
std::unique_ptr<Impl> _impl; |
| 465 |
}; |
| 466 |
|
| 467 |
/** Basic function to run equal comparison. */ |
| 468 |
using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>; |
| 469 |
/** Basic function to run not equal comparison. */ |
| 470 |
using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>; |
| 471 |
/** Basic function to run greater comparison. */ |
| 472 |
using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>; |
| 473 |
/** Basic function to run greater-equal comparison. */ |
| 474 |
using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>; |
| 475 |
/** Basic function to run less comparison. */ |
| 476 |
using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>; |
| 477 |
/** Basic function to run less-equal comparison. */ |
| 478 |
using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>; |
| 479 |
|
| 480 |
} // namespace arm_compute |
| 481 |
#endif // ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEELEMENTWISEOPERATIONS_H |