giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 1 | /* |
Matthew Bentham | f1aeab9 | 2023-05-30 13:35:34 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2018-2021, 2023 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 | |
Matthew Bentham | f1aeab9 | 2023-05-30 13:35:34 +0000 | [diff] [blame^] | 27 | #include "arm_compute/core/ActivationLayerInfo.h" |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 28 | #include "arm_compute/core/Types.h" |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 29 | #include "arm_compute/runtime/IFunction.h" |
| 30 | #include "arm_compute/runtime/NEON/INEOperator.h" |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 31 | |
| 32 | namespace arm_compute |
| 33 | { |
| 34 | class ITensor; |
| 35 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 36 | /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for max |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 37 | * |
morgolock | 6427c82 | 2020-01-13 11:53:20 +0000 | [diff] [blame] | 38 | * @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] | 39 | * @note The function performs a max operation between two tensors. |
| 40 | */ |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 41 | class NEElementwiseMax : public IFunction |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 42 | { |
| 43 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 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 &&); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 56 | /** Initialise the kernel's inputs, output and conversion policy. |
| 57 | * |
Sheri Zhang | 6124ce6 | 2021-05-04 14:03:13 +0100 | [diff] [blame] | 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 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 75 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 76 | 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] | 77 | /** 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] | 78 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 79 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 83 | * |
| 84 | * @return a status |
| 85 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 86 | 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] | 87 | |
| 88 | // Inherited methods overridden: |
| 89 | void run() override; |
| 90 | |
| 91 | private: |
| 92 | struct Impl; |
| 93 | std::unique_ptr<Impl> _impl; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 96 | /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for min |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 97 | * |
morgolock | 6427c82 | 2020-01-13 11:53:20 +0000 | [diff] [blame] | 98 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 100 | */ |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 101 | class NEElementwiseMin : public IFunction |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 102 | { |
| 103 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 104 | /** 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 &&); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 116 | /** Initialise the kernel's inputs, output and conversion policy. |
| 117 | * |
Sheri Zhang | 6124ce6 | 2021-05-04 14:03:13 +0100 | [diff] [blame] | 118 | * 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 Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 131 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 135 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 136 | 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] | 137 | /** 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] | 138 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 139 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 143 | * |
| 144 | * @return a status |
| 145 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 146 | 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] | 147 | |
| 148 | // Inherited methods overridden: |
| 149 | void run() override; |
| 150 | |
| 151 | private: |
| 152 | struct Impl; |
| 153 | std::unique_ptr<Impl> _impl; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 154 | }; |
| 155 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 156 | /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for squared difference |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 157 | * |
morgolock | 6427c82 | 2020-01-13 11:53:20 +0000 | [diff] [blame] | 158 | * @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] | 159 | * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2 |
| 160 | */ |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 161 | class NEElementwiseSquaredDiff : public IFunction |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 162 | { |
| 163 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 164 | /** 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 &&); |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 176 | /** Initialise the kernel's inputs, output and conversion policy. |
| 177 | * |
Sheri Zhang | 6124ce6 | 2021-05-04 14:03:13 +0100 | [diff] [blame] | 178 | * 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 Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 191 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 195 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 196 | 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] | 197 | /** 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] | 198 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 199 | * @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. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 203 | * |
| 204 | * @return a status |
| 205 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 206 | 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] | 207 | |
| 208 | // Inherited methods overridden: |
| 209 | void run() override; |
| 210 | |
| 211 | private: |
| 212 | struct Impl; |
| 213 | std::unique_ptr<Impl> _impl; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 214 | }; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 215 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 216 | /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for division |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 217 | * |
| 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 Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 221 | class NEElementwiseDivision : public IFunction |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 222 | { |
| 223 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 224 | /** 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 Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 236 | /** Initialise the kernel's inputs, output and conversion policy. |
| 237 | * |
Sheri Zhang | 6124ce6 | 2021-05-04 14:03:13 +0100 | [diff] [blame] | 238 | * 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 Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 247 | * @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 Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 251 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 252 | 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] | 253 | /** 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] | 254 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 255 | * @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 Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 259 | * |
| 260 | * @return a status |
| 261 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 262 | 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] | 263 | |
| 264 | // Inherited methods overridden: |
| 265 | void run() override; |
| 266 | |
| 267 | private: |
| 268 | struct Impl; |
| 269 | std::unique_ptr<Impl> _impl; |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 270 | }; |
| 271 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 272 | /** Basic function to run @ref cpu::kernels::CpuArithmeticKernel for power |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 273 | * |
| 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 Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 278 | class NEElementwisePower : public IFunction |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 279 | { |
| 280 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 281 | /** 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 Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 293 | /** Initialise the kernel's inputs, output and conversion policy. |
| 294 | * |
Sheri Zhang | 6124ce6 | 2021-05-04 14:03:13 +0100 | [diff] [blame] | 295 | * 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 Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 304 | * @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 Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 308 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 309 | 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] | 310 | /** 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] | 311 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 312 | * @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 Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 316 | * |
| 317 | * @return a status |
| 318 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 319 | 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] | 320 | |
| 321 | // Inherited methods overridden: |
| 322 | void run() override; |
| 323 | |
| 324 | private: |
| 325 | struct Impl; |
| 326 | std::unique_ptr<Impl> _impl; |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 327 | }; |
| 328 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 329 | /** Basic function to run @ref cpu::kernels::CpuComparisonKernel. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 330 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 331 | * @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] | 332 | * @note The function performs a comparison operation between two tensors. |
| 333 | */ |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 334 | class NEElementwiseComparison : public IFunction |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 335 | { |
| 336 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 337 | /** 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 Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 349 | /** Initialise the kernel's inputs, output and conversion policy. |
| 350 | * |
Sheri Zhang | 6124ce6 | 2021-05-04 14:03:13 +0100 | [diff] [blame] | 351 | * 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 Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 365 | * @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] | 366 | * @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] | 367 | * @param[out] output Output tensor. Data types supported: U8. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 368 | * @param[in] op Comparison Operation to be performed. |
| 369 | */ |
| 370 | void configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op); |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 371 | /** 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] | 372 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 373 | * @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] | 374 | * @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] | 375 | * @param[in] output Output tensor info. Data types supported: U8. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 376 | * @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 Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 381 | |
| 382 | // Inherited methods overridden: |
| 383 | void run() override; |
| 384 | |
| 385 | private: |
| 386 | struct Impl; |
| 387 | std::unique_ptr<Impl> _impl; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 388 | }; |
| 389 | |
Sang-Hoon Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 390 | /** Basic function to run @ref cpu::kernels::CpuComparisonKernel |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 391 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 392 | * @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] | 393 | * @note The function performs a comparison operation between two tensors. |
| 394 | */ |
| 395 | template <ComparisonOperation op> |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 396 | class NEElementwiseComparisonStatic : public IFunction |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 397 | { |
| 398 | public: |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 399 | /** 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 Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 411 | /** Initialise the kernel's inputs, output and conversion policy. |
| 412 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 413 | * @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] | 414 | * @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 Park | 63001ac | 2021-01-18 14:20:27 +0000 | [diff] [blame] | 418 | /** 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] | 419 | * |
Michele Di Giorgio | 1c76c1d | 2020-08-28 13:25:31 +0100 | [diff] [blame] | 420 | * @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] | 421 | * @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 Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 427 | |
| 428 | // Inherited methods overridden: |
| 429 | void run() override; |
| 430 | |
| 431 | private: |
| 432 | struct Impl; |
| 433 | std::unique_ptr<Impl> _impl; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 434 | }; |
| 435 | |
| 436 | /** Basic function to run equal comparison. */ |
| 437 | using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>; |
| 438 | /** Basic function to run not equal comparison. */ |
| 439 | using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>; |
| 440 | /** Basic function to run greater comparison. */ |
| 441 | using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>; |
| 442 | /** Basic function to run greater-equal comparison. */ |
| 443 | using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>; |
| 444 | /** Basic function to run less comparison. */ |
| 445 | using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>; |
| 446 | /** Basic function to run less-equal comparison. */ |
| 447 | using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>; |
Michalis Spyrou | ce0c675 | 2020-06-18 10:14:57 +0100 | [diff] [blame] | 448 | |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 449 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 450 | #endif /* ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H */ |