giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 1 | /* |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 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 |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 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, |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H |
| 25 | #define ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/core/Types.h" |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 28 | #include "arm_compute/runtime/IFunction.h" |
| 29 | #include "arm_compute/runtime/NEON/INEOperator.h" |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | class ITensor; |
| 34 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 35 | /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for max |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 36 | * |
morgolock | 6427c82 | 2020-01-13 11:53:20 +0000 | [diff] [blame] | 37 | * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 38 | * @note The function performs a max operation between two tensors. |
| 39 | */ |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 40 | class NEElementwiseMax : public IFunction |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 41 | { |
| 42 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 43 | /** 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 &&); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 55 | /** Initialise the kernel's inputs, output and conversion policy. |
| 56 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 57 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 61 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 62 | void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 63 | /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for max |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 64 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 65 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 69 | * |
| 70 | * @return a status |
| 71 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 72 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 73 | |
| 74 | // Inherited methods overridden: |
| 75 | void run() override; |
| 76 | |
| 77 | private: |
| 78 | struct Impl; |
| 79 | std::unique_ptr<Impl> _impl; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 82 | /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for min |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 83 | * |
morgolock | 6427c82 | 2020-01-13 11:53:20 +0000 | [diff] [blame] | 84 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 86 | */ |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 87 | class NEElementwiseMin : public IFunction |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 88 | { |
| 89 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 90 | /** 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 &&); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 102 | /** Initialise the kernel's inputs, output and conversion policy. |
| 103 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 104 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 108 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 109 | void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 110 | /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for min |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 111 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 112 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 116 | * |
| 117 | * @return a status |
| 118 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 119 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 120 | |
| 121 | // Inherited methods overridden: |
| 122 | void run() override; |
| 123 | |
| 124 | private: |
| 125 | struct Impl; |
| 126 | std::unique_ptr<Impl> _impl; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 127 | }; |
| 128 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 129 | /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for squared difference |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 130 | * |
morgolock | 6427c82 | 2020-01-13 11:53:20 +0000 | [diff] [blame] | 131 | * @note The tensor data type for the inputs must be QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 132 | * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2 |
| 133 | */ |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 134 | class NEElementwiseSquaredDiff : public IFunction |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 135 | { |
| 136 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 137 | /** 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 &&); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 149 | /** Initialise the kernel's inputs, output and conversion policy. |
| 150 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 151 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 155 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 156 | void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 157 | /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for squared difference |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 158 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 159 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 163 | * |
| 164 | * @return a status |
| 165 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 166 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 167 | |
| 168 | // Inherited methods overridden: |
| 169 | void run() override; |
| 170 | |
| 171 | private: |
| 172 | struct Impl; |
| 173 | std::unique_ptr<Impl> _impl; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 174 | }; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 175 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 176 | /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for division |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 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 Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 181 | class NEElementwiseDivision : public IFunction |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 182 | { |
| 183 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 184 | /** 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 Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 196 | /** Initialise the kernel's inputs, output and conversion policy. |
| 197 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 198 | * @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 Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 202 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 203 | void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 204 | /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for division |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 205 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 206 | * @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 Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 210 | * |
| 211 | * @return a status |
| 212 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 213 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 214 | |
| 215 | // Inherited methods overridden: |
| 216 | void run() override; |
| 217 | |
| 218 | private: |
| 219 | struct Impl; |
| 220 | std::unique_ptr<Impl> _impl; |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 221 | }; |
| 222 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 223 | /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for power |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 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 Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 229 | class NEElementwisePower : public IFunction |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 230 | { |
| 231 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 232 | /** 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 Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 244 | /** Initialise the kernel's inputs, output and conversion policy. |
| 245 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 246 | * @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 Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 250 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 251 | void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 252 | /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuArithmeticKernel for power |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 253 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 254 | * @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 Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 258 | * |
| 259 | * @return a status |
| 260 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 261 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 262 | |
| 263 | // Inherited methods overridden: |
| 264 | void run() override; |
| 265 | |
| 266 | private: |
| 267 | struct Impl; |
| 268 | std::unique_ptr<Impl> _impl; |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 269 | }; |
| 270 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 271 | /** Basic function to run @ref cpu::kernels::CpuComparisonKernel. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 272 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 273 | * @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 274 | * @note The function performs a comparison operation between two tensors. |
| 275 | */ |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 276 | class NEElementwiseComparison : public IFunction |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 277 | { |
| 278 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 279 | /** 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 Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 291 | /** Initialise the kernel's inputs, output and conversion policy. |
| 292 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 293 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 294 | * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
Michele Di Giorgio | f9b595a | 2020-07-03 13:34:52 +0100 | [diff] [blame] | 295 | * @param[out] output Output tensor. Data types supported: U8. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 296 | * @param[in] op Comparison Operation to be performed. |
| 297 | */ |
| 298 | void configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 299 | /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuComparisonKernel |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 300 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 301 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 302 | * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
Michele Di Giorgio | f9b595a | 2020-07-03 13:34:52 +0100 | [diff] [blame] | 303 | * @param[in] output Output tensor info. Data types supported: U8. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 304 | * @param[in] op Comparison Operation to be performed. |
| 305 | * |
| 306 | * @return a status |
| 307 | */ |
| 308 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op); |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 309 | |
| 310 | // Inherited methods overridden: |
| 311 | void run() override; |
| 312 | |
| 313 | private: |
| 314 | struct Impl; |
| 315 | std::unique_ptr<Impl> _impl; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 316 | }; |
| 317 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 318 | /** Basic function to run @ref cpu::kernels::CpuComparisonKernel |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 319 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 320 | * @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 321 | * @note The function performs a comparison operation between two tensors. |
| 322 | */ |
| 323 | template <ComparisonOperation op> |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 324 | class NEElementwiseComparisonStatic : public IFunction |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 325 | { |
| 326 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 327 | /** 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 Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 339 | /** Initialise the kernel's inputs, output and conversion policy. |
| 340 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 341 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 342 | * @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); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame^] | 346 | /** Static function to check if given info will lead to a valid configuration of @ref cpu::kernels::CpuComparisonKernel |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 347 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 348 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 349 | * @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 Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 355 | |
| 356 | // Inherited methods overridden: |
| 357 | void run() override; |
| 358 | |
| 359 | private: |
| 360 | struct Impl; |
| 361 | std::unique_ptr<Impl> _impl; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 362 | }; |
| 363 | |
| 364 | /** Basic function to run equal comparison. */ |
| 365 | using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>; |
| 366 | /** Basic function to run not equal comparison. */ |
| 367 | using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>; |
| 368 | /** Basic function to run greater comparison. */ |
| 369 | using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>; |
| 370 | /** Basic function to run greater-equal comparison. */ |
| 371 | using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>; |
| 372 | /** Basic function to run less comparison. */ |
| 373 | using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>; |
| 374 | /** Basic function to run less-equal comparison. */ |
| 375 | using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>; |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 376 | |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 377 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 378 | #endif /* ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H */ |