giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2020 Arm Limited. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +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 |
| 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 |
George Wort | 5a97b28 | 2018-12-21 16:21:04 +0000 | [diff] [blame] | 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
giuros01 | 164a272 | 2018-11-20 18:34:46 +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_CLELEMENTWISEOPERATIONS_H |
| 25 | #define ARM_COMPUTE_CLELEMENTWISEOPERATIONS_H |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 26 | |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/CL/kernels/CLFillBorderKernel.h" |
| 28 | #include "arm_compute/runtime/CL/ICLOperator.h" |
| 29 | #include "arm_compute/runtime/IFunction.h" |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | class ICLTensor; |
| 34 | |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 35 | namespace experimental |
| 36 | { |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 37 | /** Basic function to run @ref CLSaturatedArithmeticOperationKernel for addition |
| 38 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 39 | * @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 40 | * @note The function performs an arithmetic addition between two tensors. |
| 41 | */ |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 42 | class CLArithmeticAddition : public ICLOperator |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 43 | { |
| 44 | public: |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 45 | /** Default Constructor */ |
| 46 | CLArithmeticAddition(); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 47 | /** Initialise the kernel's inputs, output and conversion policy. |
| 48 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 49 | * Valid configurations (Input1,Input2) -> Output : |
| 50 | * |
| 51 | * - (U8,U8) -> U8 |
| 52 | * - (U8,U8) -> S16 |
| 53 | * - (S16,U8) -> S16 |
| 54 | * - (U8,S16) -> S16 |
| 55 | * - (S16,S16) -> S16 |
| 56 | * - (S32,S32) -> S32 |
| 57 | * - (F16,F16) -> F16 |
| 58 | * - (F32,F32) -> F32 |
| 59 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 60 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 61 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 62 | * |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 63 | * @param[in] compile_context The compile context to be used. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 64 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 65 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 66 | * @param[in, out] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 67 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 68 | * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 69 | * @param[in] policy Policy to use to handle overflow. |
| 70 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 71 | */ |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 72 | void configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, ConvertPolicy policy, |
| 73 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 74 | /** Static function to check if given info will lead to a valid configuration of @ref CLSaturatedArithmeticOperationKernel for addition |
| 75 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 76 | * Valid configurations (Input1,Input2) -> Output : |
| 77 | * |
| 78 | * - (U8,U8) -> U8 |
| 79 | * - (U8,U8) -> S16 |
| 80 | * - (S16,U8) -> S16 |
| 81 | * - (U8,S16) -> S16 |
| 82 | * - (S16,S16) -> S16 |
| 83 | * - (S32,S32) -> S32 |
| 84 | * - (F16,F16) -> F16 |
| 85 | * - (F32,F32) -> F32 |
| 86 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 87 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 88 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 89 | * |
| 90 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 91 | * @param[in] input2 Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 92 | * @param[in] output Output tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 93 | * @param[in] policy Policy to use to handle overflow. |
| 94 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 95 | * |
| 96 | * @return a status |
| 97 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 98 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 99 | |
| 100 | // Inherited methods overridden: |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 101 | void run(ITensorPack &tensors) override; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 102 | |
| 103 | private: |
| 104 | CLFillBorderKernel _border_handler; |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | /** Basic function to run @ref CLSaturatedArithmeticOperationKernel for subtraction |
| 108 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 109 | * @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/S32/F16/F32. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 110 | * @note The function performs an arithmetic subtraction between two tensors. |
| 111 | */ |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 112 | class CLArithmeticSubtraction : public ICLOperator |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 113 | { |
| 114 | public: |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 115 | /** Default Constructor */ |
| 116 | CLArithmeticSubtraction(); |
| 117 | /** Initialise the kernel's inputs, output and conversion policy. |
| 118 | * |
| 119 | * Valid configurations (Input1,Input2) -> Output : |
| 120 | * |
| 121 | * - (U8,U8) -> U8 |
| 122 | * - (U8,U8) -> S16 |
| 123 | * - (S16,U8) -> S16 |
| 124 | * - (U8,S16) -> S16 |
| 125 | * - (S16,S16) -> S16 |
| 126 | * - (S32,S32) -> S32 |
| 127 | * - (F16,F16) -> F16 |
| 128 | * - (F32,F32) -> F32 |
| 129 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 130 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 131 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 132 | * |
| 133 | * @param[in] compile_context The compile context to be used. |
| 134 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 135 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 136 | * @param[in, out] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 137 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 138 | * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 139 | * @param[in] policy Policy to use to handle overflow. |
| 140 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 141 | */ |
| 142 | void configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, ConvertPolicy policy, |
| 143 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 144 | /** Static function to check if given info will lead to a valid configuration of @ref CLSaturatedArithmeticOperationKernel for subtraction |
| 145 | * |
| 146 | * Valid configurations (Input1,Input2) -> Output : |
| 147 | * |
| 148 | * - (U8,U8) -> U8 |
| 149 | * - (U8,U8) -> S16 |
| 150 | * - (S16,U8) -> S16 |
| 151 | * - (U8,S16) -> S16 |
| 152 | * - (S16,S16) -> S16 |
| 153 | * - (S32,S32) -> S32 |
| 154 | * - (F16,F16) -> F16 |
| 155 | * - (F32,F32) -> F32 |
| 156 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 157 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 158 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 159 | * |
| 160 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 161 | * @param[in] input2 Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 162 | * @param[in] output Output tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 163 | * @param[in] policy Policy to use to handle overflow. |
| 164 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 165 | * |
| 166 | * @return a status |
| 167 | */ |
| 168 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 169 | |
| 170 | // Inherited methods overridden: |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 171 | void run(ITensorPack &tensors) override; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 172 | |
| 173 | private: |
| 174 | CLFillBorderKernel _border_handler; |
| 175 | }; |
| 176 | |
| 177 | /** Basic function to run @ref CLSaturatedArithmeticOperationKernel for division |
| 178 | * |
| 179 | * @note The tensor data type for the inputs must be F16/F32. |
| 180 | * @note The function performs an arithmetic division between two tensors. |
| 181 | */ |
| 182 | class CLArithmeticDivision : public ICLOperator |
| 183 | { |
| 184 | public: |
| 185 | /** Default Constructor */ |
| 186 | CLArithmeticDivision(); |
| 187 | /** Initialise the kernel's inputs, output. |
| 188 | * |
| 189 | * @param[in] compile_context The compile context to be used. |
| 190 | * @param[in, out] input1 First tensor input. Data types supported: F16/F32. |
| 191 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 192 | * @param[in, out] input2 Second tensor input. Same as @p input1. |
| 193 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 194 | * @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 195 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 196 | */ |
| 197 | void configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 198 | /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticDivision |
| 199 | * |
| 200 | * @param[in] input1 First tensor input info. Data types supported: F16/F32. |
| 201 | * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 202 | * @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 203 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 204 | * |
| 205 | * @return a status |
| 206 | */ |
| 207 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 208 | |
| 209 | // Inherited methods overridden: |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 210 | void run(ITensorPack &tensors) override; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 211 | |
| 212 | private: |
| 213 | CLFillBorderKernel _border_handler; |
| 214 | }; |
| 215 | |
| 216 | /** Basic function to run @ref CLArithmeticOperationKernel for max |
| 217 | * |
| 218 | * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32. |
| 219 | * @note The function performs a max operation between two tensors. |
| 220 | */ |
| 221 | class CLElementwiseMax : public ICLOperator |
| 222 | { |
| 223 | public: |
| 224 | /** Default Constructor */ |
| 225 | CLElementwiseMax(); |
| 226 | /** Initialise the kernel's inputs, output and conversion policy. |
| 227 | * |
| 228 | * @param[in] compile_context The compile context to be used. |
| 229 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
| 230 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 231 | * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1. |
| 232 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 233 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
| 234 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 235 | */ |
| 236 | void configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 237 | /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for max |
| 238 | * |
| 239 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
| 240 | * @param[in] input2 Second tensor input info. Data types supported: same as @p input1. |
| 241 | * @param[in] output Output tensor info. Data types supported: same as @p input1. |
| 242 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 243 | * |
| 244 | * @return a status |
| 245 | */ |
| 246 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 247 | |
| 248 | // Inherited methods overridden: |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 249 | void run(ITensorPack &tensors) override; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 250 | |
| 251 | private: |
| 252 | CLFillBorderKernel _border_handler; |
| 253 | }; |
| 254 | |
| 255 | /** Basic function to run @ref CLArithmeticOperationKernel for min |
| 256 | * |
| 257 | * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32. |
| 258 | * @note The function performs a max operation between two tensors. |
| 259 | */ |
| 260 | class CLElementwiseMin : public ICLOperator |
| 261 | { |
| 262 | public: |
| 263 | /** Default Constructor */ |
| 264 | CLElementwiseMin(); |
| 265 | /** Initialise the kernel's inputs, output and conversion policy. |
| 266 | * |
| 267 | * @param[in] compile_context The compile context to be used. |
| 268 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
| 269 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 270 | * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1. |
| 271 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 272 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
| 273 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 274 | */ |
| 275 | void configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 276 | /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for min |
| 277 | * |
| 278 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
| 279 | * @param[in] input2 Second tensor input info. Data types supported: same as @p input1. |
| 280 | * @param[in] output Output tensor info. Data types supported: same as @p input1. |
| 281 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 282 | * |
| 283 | * @return a status |
| 284 | */ |
| 285 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 286 | |
| 287 | // Inherited methods overridden: |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 288 | void run(ITensorPack &tensors) override; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 289 | |
| 290 | private: |
| 291 | CLFillBorderKernel _border_handler; |
| 292 | }; |
| 293 | |
| 294 | /** Basic function to run @ref CLArithmeticOperationKernel for squared difference |
| 295 | * |
| 296 | * @note The tensor data type for the inputs must be QASYMM8/U8/S16/QSYMM16/F16/F32. |
| 297 | * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2 |
| 298 | */ |
| 299 | class CLElementwiseSquaredDiff : public ICLOperator |
| 300 | { |
| 301 | public: |
| 302 | /** Default Constructor */ |
| 303 | CLElementwiseSquaredDiff(); |
| 304 | /** Initialise the kernel's inputs, output and conversion policy. |
| 305 | * |
| 306 | * @param[in] compile_context The compile context to be used. |
| 307 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32. |
| 308 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 309 | * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1. |
| 310 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 311 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
| 312 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 313 | */ |
| 314 | void configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 315 | /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for squared difference |
| 316 | * |
| 317 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32. |
| 318 | * @param[in] input2 Second tensor input info. Data types supported: same as @p input1. |
| 319 | * @param[in] output Output tensor info. Data types supported: same as @p input1. |
| 320 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 321 | * |
| 322 | * @return a status |
| 323 | */ |
| 324 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 325 | |
| 326 | // Inherited methods overridden: |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 327 | void run(ITensorPack &tensors) override; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 328 | |
| 329 | private: |
| 330 | CLFillBorderKernel _border_handler; |
| 331 | }; |
| 332 | |
| 333 | /** Basic function to run @ref CLArithmeticOperationKernel for power |
| 334 | * |
| 335 | * @note The tensor data type for the inputs must be F16/F32. |
| 336 | * @note The function performs an elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i]) |
| 337 | */ |
| 338 | class CLElementwisePower : public ICLOperator |
| 339 | { |
| 340 | public: |
| 341 | /** Default Constructor */ |
| 342 | CLElementwisePower(); |
| 343 | /** Initialise the kernel's inputs, output and conversion policy. |
| 344 | * |
| 345 | * @param[in] compile_context The compile context to be used. |
| 346 | * @param[in, out] input1 First tensor input. Data types supported: F16/F32. |
| 347 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 348 | * @param[in, out] input2 Second tensor input. Data types supported: F16/F32. |
| 349 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 350 | * @param[out] output Output tensor. Data types supported:F16/F32. |
| 351 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 352 | */ |
| 353 | void configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 354 | /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for power |
| 355 | * |
| 356 | * @param[in] input1 First tensor input info. Data types supported: F16/F32. |
| 357 | * @param[in] input2 Second tensor input info. Data types supported: F16/F32. |
| 358 | * @param[in] output Output tensor info. Data types supported: F16/F32. |
| 359 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 360 | * |
| 361 | * @return a status |
| 362 | */ |
| 363 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 364 | |
| 365 | // Inherited methods overridden: |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 366 | void run(ITensorPack &tensors) override; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 367 | |
| 368 | private: |
| 369 | CLFillBorderKernel _border_handler; |
| 370 | }; |
| 371 | } // namespace experimental |
| 372 | |
| 373 | /** Basic function to run @ref CLSaturatedArithmeticOperationKernel for addition |
| 374 | * |
| 375 | * @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 376 | * @note The function performs an arithmetic addition between two tensors. |
| 377 | */ |
| 378 | class CLArithmeticAddition : public IFunction |
| 379 | { |
| 380 | public: |
| 381 | /** Default Constructor */ |
| 382 | CLArithmeticAddition(); |
| 383 | /** Default Destructor */ |
| 384 | ~CLArithmeticAddition(); |
| 385 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 386 | CLArithmeticAddition(const CLArithmeticAddition &) = delete; |
| 387 | /** Default move constructor */ |
| 388 | CLArithmeticAddition(CLArithmeticAddition &&); |
| 389 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 390 | CLArithmeticAddition &operator=(const CLArithmeticAddition &) = delete; |
| 391 | /** Default move assignment operator */ |
| 392 | CLArithmeticAddition &operator=(CLArithmeticAddition &&); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 393 | /** Initialise the kernel's inputs, output and conversion policy. |
| 394 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 395 | * Valid configurations (Input1,Input2) -> Output : |
| 396 | * |
| 397 | * - (U8,U8) -> U8 |
| 398 | * - (U8,U8) -> S16 |
| 399 | * - (S16,U8) -> S16 |
| 400 | * - (U8,S16) -> S16 |
| 401 | * - (S16,S16) -> S16 |
| 402 | * - (S32,S32) -> S32 |
| 403 | * - (F16,F16) -> F16 |
| 404 | * - (F32,F32) -> F32 |
| 405 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 406 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 407 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 408 | * |
| 409 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 410 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 411 | * @param[in, out] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 412 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 413 | * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 414 | * @param[in] policy Policy to use to handle overflow. |
| 415 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 416 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 417 | void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 418 | /** Initialise the kernel's inputs, output and conversion policy. |
| 419 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 420 | * Valid configurations (Input1,Input2) -> Output : |
| 421 | * |
| 422 | * - (U8,U8) -> U8 |
| 423 | * - (U8,U8) -> S16 |
| 424 | * - (S16,U8) -> S16 |
| 425 | * - (U8,S16) -> S16 |
| 426 | * - (S16,S16) -> S16 |
| 427 | * - (S32,S32) -> S32 |
| 428 | * - (F16,F16) -> F16 |
| 429 | * - (F32,F32) -> F32 |
| 430 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 431 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 432 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 433 | * |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 434 | * @param[in] compile_context The compile context to be used. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 435 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 436 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 437 | * @param[in, out] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 438 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 439 | * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 440 | * @param[in] policy Policy to use to handle overflow. |
| 441 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 442 | */ |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 443 | void configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, |
| 444 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 445 | /** Static function to check if given info will lead to a valid configuration of @ref CLSaturatedArithmeticOperationKernel for addition |
| 446 | * |
| 447 | * Valid configurations (Input1,Input2) -> Output : |
| 448 | * |
| 449 | * - (U8,U8) -> U8 |
| 450 | * - (U8,U8) -> S16 |
| 451 | * - (S16,U8) -> S16 |
| 452 | * - (U8,S16) -> S16 |
| 453 | * - (S16,S16) -> S16 |
| 454 | * - (S32,S32) -> S32 |
| 455 | * - (F16,F16) -> F16 |
| 456 | * - (F32,F32) -> F32 |
| 457 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 458 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 459 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 460 | * |
| 461 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 462 | * @param[in] input2 Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 463 | * @param[in] output Output tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 464 | * @param[in] policy Policy to use to handle overflow. |
| 465 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 466 | * |
| 467 | * @return a status |
| 468 | */ |
| 469 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 470 | |
| 471 | // Inherited methods overridden: |
| 472 | void run() override; |
| 473 | |
| 474 | private: |
| 475 | struct Impl; |
| 476 | std::unique_ptr<Impl> _impl; |
| 477 | }; |
| 478 | |
| 479 | /** Basic function to run @ref CLSaturatedArithmeticOperationKernel for subtraction |
| 480 | * |
| 481 | * @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/S32/F16/F32. |
| 482 | * @note The function performs an arithmetic subtraction between two tensors. |
| 483 | */ |
| 484 | class CLArithmeticSubtraction : public IFunction |
| 485 | { |
| 486 | public: |
| 487 | /** Default Constructor */ |
| 488 | CLArithmeticSubtraction(); |
| 489 | /** Default Destructor */ |
| 490 | ~CLArithmeticSubtraction(); |
| 491 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 492 | CLArithmeticSubtraction(const CLArithmeticSubtraction &) = delete; |
| 493 | /** Default move constructor */ |
| 494 | CLArithmeticSubtraction(CLArithmeticSubtraction &&); |
| 495 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 496 | CLArithmeticSubtraction &operator=(const CLArithmeticSubtraction &) = delete; |
| 497 | /** Default move assignment operator */ |
| 498 | CLArithmeticSubtraction &operator=(CLArithmeticSubtraction &&); |
| 499 | /** Initialise the kernel's inputs, output and conversion policy. |
| 500 | * |
| 501 | * Valid configurations (Input1,Input2) -> Output : |
| 502 | * |
| 503 | * - (U8,U8) -> U8 |
| 504 | * - (U8,U8) -> S16 |
| 505 | * - (S16,U8) -> S16 |
| 506 | * - (U8,S16) -> S16 |
| 507 | * - (S16,S16) -> S16 |
| 508 | * - (S32,S32) -> S32 |
| 509 | * - (F16,F16) -> F16 |
| 510 | * - (F32,F32) -> F32 |
| 511 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 512 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 513 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 514 | * |
| 515 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 516 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 517 | * @param[in, out] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 518 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 519 | * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 520 | * @param[in] policy Policy to use to handle overflow. |
| 521 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 522 | */ |
| 523 | void configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 524 | /** Initialise the kernel's inputs, output and conversion policy. |
| 525 | * |
| 526 | * Valid configurations (Input1,Input2) -> Output : |
| 527 | * |
| 528 | * - (U8,U8) -> U8 |
| 529 | * - (U8,U8) -> S16 |
| 530 | * - (S16,U8) -> S16 |
| 531 | * - (U8,S16) -> S16 |
| 532 | * - (S16,S16) -> S16 |
| 533 | * - (S32,S32) -> S32 |
| 534 | * - (F16,F16) -> F16 |
| 535 | * - (F32,F32) -> F32 |
| 536 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 537 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 538 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 539 | * |
| 540 | * @param[in] compile_context The compile context to be used. |
| 541 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 542 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 543 | * @param[in, out] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 544 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 545 | * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 546 | * @param[in] policy Policy to use to handle overflow. |
| 547 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 548 | */ |
| 549 | void configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, |
| 550 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 551 | /** Static function to check if given info will lead to a valid configuration of @ref CLSaturatedArithmeticOperationKernel for subtraction |
| 552 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 553 | * Valid configurations (Input1,Input2) -> Output : |
| 554 | * |
| 555 | * - (U8,U8) -> U8 |
| 556 | * - (U8,U8) -> S16 |
| 557 | * - (S16,U8) -> S16 |
| 558 | * - (U8,S16) -> S16 |
| 559 | * - (S16,S16) -> S16 |
| 560 | * - (S32,S32) -> S32 |
| 561 | * - (F16,F16) -> F16 |
| 562 | * - (F32,F32) -> F32 |
| 563 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 564 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 565 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 566 | * |
| 567 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 568 | * @param[in] input2 Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 569 | * @param[in] output Output tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 570 | * @param[in] policy Policy to use to handle overflow. |
| 571 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 572 | * |
| 573 | * @return a status |
| 574 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 575 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 576 | |
| 577 | // Inherited methods overridden: |
| 578 | void run() override; |
| 579 | |
| 580 | private: |
| 581 | struct Impl; |
| 582 | std::unique_ptr<Impl> _impl; |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 583 | }; |
| 584 | |
| 585 | /** Basic function to run @ref CLSaturatedArithmeticOperationKernel for division |
| 586 | * |
| 587 | * @note The tensor data type for the inputs must be F16/F32. |
| 588 | * @note The function performs an arithmetic division between two tensors. |
| 589 | */ |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 590 | class CLArithmeticDivision : public IFunction |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 591 | { |
| 592 | public: |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 593 | /** Default Constructor */ |
| 594 | CLArithmeticDivision(); |
| 595 | /** Default Destructor */ |
| 596 | ~CLArithmeticDivision(); |
| 597 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 598 | CLArithmeticDivision(const CLArithmeticDivision &) = delete; |
| 599 | /** Default move constructor */ |
| 600 | CLArithmeticDivision(CLArithmeticDivision &&); |
| 601 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 602 | CLArithmeticDivision &operator=(const CLArithmeticDivision &) = delete; |
| 603 | /** Default move assignment operator */ |
| 604 | CLArithmeticDivision &operator=(CLArithmeticDivision &&); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 605 | /** Initialise the kernel's inputs, output. |
| 606 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 607 | * @param[in, out] input1 First tensor input. Data types supported: F16/F32. |
| 608 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 609 | * @param[in, out] input2 Second tensor input. Same as @p input1. |
| 610 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 611 | * @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 612 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 613 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 614 | void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 615 | /** Initialise the kernel's inputs, output. |
| 616 | * |
| 617 | * @param[in] compile_context The compile context to be used. |
| 618 | * @param[in, out] input1 First tensor input. Data types supported: F16/F32. |
| 619 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 620 | * @param[in, out] input2 Second tensor input. Same as @p input1. |
| 621 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 622 | * @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 623 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 624 | */ |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 625 | void configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 626 | /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticDivision |
| 627 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 628 | * @param[in] input1 First tensor input info. Data types supported: F16/F32. |
| 629 | * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 630 | * @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 631 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 632 | * |
| 633 | * @return a status |
| 634 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 635 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 636 | |
| 637 | // Inherited methods overridden: |
| 638 | void run() override; |
| 639 | |
| 640 | private: |
| 641 | struct Impl; |
| 642 | std::unique_ptr<Impl> _impl; |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 643 | }; |
| 644 | |
| 645 | /** Basic function to run @ref CLArithmeticOperationKernel for max |
| 646 | * |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 647 | * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 648 | * @note The function performs a max operation between two tensors. |
| 649 | */ |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 650 | class CLElementwiseMax : public IFunction |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 651 | { |
| 652 | public: |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 653 | /** Default Constructor */ |
| 654 | CLElementwiseMax(); |
| 655 | /** Default Destructor */ |
| 656 | ~CLElementwiseMax(); |
| 657 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 658 | CLElementwiseMax(const CLElementwiseMax &) = delete; |
| 659 | /** Default move constructor */ |
| 660 | CLElementwiseMax(CLElementwiseMax &&); |
| 661 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 662 | CLElementwiseMax &operator=(const CLElementwiseMax &) = delete; |
| 663 | /** Default move assignment operator */ |
| 664 | CLElementwiseMax &operator=(CLElementwiseMax &&); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 665 | /** Initialise the kernel's inputs, output and conversion policy. |
| 666 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 667 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 668 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 669 | * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 670 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 671 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 672 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 673 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 674 | void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 675 | /** Initialise the kernel's inputs, output and conversion policy. |
| 676 | * |
| 677 | * @param[in] compile_context The compile context to be used. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 678 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 679 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 680 | * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 681 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 682 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 683 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 684 | */ |
| 685 | void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 686 | /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for max |
| 687 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 688 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
| 689 | * @param[in] input2 Second tensor input info. Data types supported: same as @p input1. |
| 690 | * @param[in] output Output tensor info. Data types supported: same as @p input1. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 691 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 692 | * |
| 693 | * @return a status |
| 694 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 695 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 696 | |
| 697 | // Inherited methods overridden: |
| 698 | void run() override; |
| 699 | |
| 700 | private: |
| 701 | struct Impl; |
| 702 | std::unique_ptr<Impl> _impl; |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 703 | }; |
| 704 | |
| 705 | /** Basic function to run @ref CLArithmeticOperationKernel for min |
| 706 | * |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 707 | * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 708 | * @note The function performs a max operation between two tensors. |
| 709 | */ |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 710 | class CLElementwiseMin : public IFunction |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 711 | { |
| 712 | public: |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 713 | /** Default Constructor */ |
| 714 | CLElementwiseMin(); |
| 715 | /** Default Destructor */ |
| 716 | ~CLElementwiseMin(); |
| 717 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 718 | CLElementwiseMin(const CLElementwiseMin &) = delete; |
| 719 | /** Default move constructor */ |
| 720 | CLElementwiseMin(CLElementwiseMin &&); |
| 721 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 722 | CLElementwiseMin &operator=(const CLElementwiseMin &) = delete; |
| 723 | /** Default move assignment operator */ |
| 724 | CLElementwiseMin &operator=(CLElementwiseMin &&); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 725 | /** Initialise the kernel's inputs, output and conversion policy. |
| 726 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 727 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 728 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 729 | * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 730 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 731 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 732 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 733 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 734 | void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 735 | /** Initialise the kernel's inputs, output and conversion policy. |
| 736 | * |
| 737 | * @param[in] compile_context The compile context to be used. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 738 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 739 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 740 | * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 741 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 742 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 743 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 744 | */ |
| 745 | void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 746 | /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for min |
| 747 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 748 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
| 749 | * @param[in] input2 Second tensor input info. Data types supported: same as @p input1. |
| 750 | * @param[in] output Output tensor info. Data types supported: same as @p input1. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 751 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 752 | * |
| 753 | * @return a status |
| 754 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 755 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 756 | |
| 757 | // Inherited methods overridden: |
| 758 | void run() override; |
| 759 | |
| 760 | private: |
| 761 | struct Impl; |
| 762 | std::unique_ptr<Impl> _impl; |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 763 | }; |
| 764 | |
| 765 | /** Basic function to run @ref CLArithmeticOperationKernel for squared difference |
| 766 | * |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 767 | * @note The tensor data type for the inputs must be QASYMM8/U8/S16/QSYMM16/F16/F32. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 768 | * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2 |
| 769 | */ |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 770 | class CLElementwiseSquaredDiff : public IFunction |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 771 | { |
| 772 | public: |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 773 | /** Default Constructor */ |
| 774 | CLElementwiseSquaredDiff(); |
| 775 | /** Default Destructor */ |
| 776 | ~CLElementwiseSquaredDiff(); |
| 777 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 778 | CLElementwiseSquaredDiff(const CLElementwiseSquaredDiff &) = delete; |
| 779 | /** Default move constructor */ |
| 780 | CLElementwiseSquaredDiff(CLElementwiseSquaredDiff &&); |
| 781 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 782 | CLElementwiseSquaredDiff &operator=(const CLElementwiseSquaredDiff &) = delete; |
| 783 | /** Default move assignment operator */ |
| 784 | CLElementwiseSquaredDiff &operator=(CLElementwiseSquaredDiff &&); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 785 | /** Initialise the kernel's inputs, output and conversion policy. |
| 786 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 787 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 788 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 789 | * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 790 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 791 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 792 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 793 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 794 | void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 795 | /** Initialise the kernel's inputs, output and conversion policy. |
| 796 | * |
| 797 | * @param[in] compile_context The compile context to be used. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 798 | * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 799 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 800 | * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 801 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 802 | * @param[out] output Output tensor. Data types supported: same as @p input1. |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 803 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 804 | */ |
| 805 | void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 806 | /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for squared difference |
| 807 | * |
Michele Di Giorgio | f6f7876 | 2020-07-06 11:27:21 +0100 | [diff] [blame] | 808 | * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32. |
| 809 | * @param[in] input2 Second tensor input info. Data types supported: same as @p input1. |
| 810 | * @param[in] output Output tensor info. Data types supported: same as @p input1. |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 811 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 812 | * |
| 813 | * @return a status |
| 814 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 815 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 816 | |
| 817 | // Inherited methods overridden: |
| 818 | void run() override; |
| 819 | |
| 820 | private: |
| 821 | struct Impl; |
| 822 | std::unique_ptr<Impl> _impl; |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 823 | }; |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 824 | |
| 825 | /** Basic function to run @ref CLArithmeticOperationKernel for power |
| 826 | * |
| 827 | * @note The tensor data type for the inputs must be F16/F32. |
| 828 | * @note The function performs an elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i]) |
| 829 | */ |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 830 | class CLElementwisePower : public IFunction |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 831 | { |
| 832 | public: |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 833 | /** Default Constructor */ |
| 834 | CLElementwisePower(); |
| 835 | /** Default Destructor */ |
| 836 | ~CLElementwisePower(); |
| 837 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 838 | CLElementwisePower(const CLElementwisePower &) = delete; |
| 839 | /** Default move constructor */ |
| 840 | CLElementwisePower(CLElementwisePower &&); |
| 841 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 842 | CLElementwisePower &operator=(const CLElementwisePower &) = delete; |
| 843 | /** Default move assignment operator */ |
| 844 | CLElementwisePower &operator=(CLElementwisePower &&); |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 845 | /** Initialise the kernel's inputs, output and conversion policy. |
| 846 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 847 | * @param[in, out] input1 First tensor input. Data types supported: F16/F32. |
| 848 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 849 | * @param[in, out] input2 Second tensor input. Data types supported: F16/F32. |
| 850 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 851 | * @param[out] output Output tensor. Data types supported:F16/F32. |
| 852 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 853 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 854 | void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 855 | /** Initialise the kernel's inputs, output and conversion policy. |
| 856 | * |
| 857 | * @param[in] compile_context The compile context to be used. |
| 858 | * @param[in, out] input1 First tensor input. Data types supported: F16/F32. |
| 859 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 860 | * @param[in, out] input2 Second tensor input. Data types supported: F16/F32. |
| 861 | * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 862 | * @param[out] output Output tensor. Data types supported:F16/F32. |
| 863 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 864 | */ |
| 865 | void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 866 | /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticOperationKernel for power |
| 867 | * |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 868 | * @param[in] input1 First tensor input info. Data types supported: F16/F32. |
| 869 | * @param[in] input2 Second tensor input info. Data types supported: F16/F32. |
| 870 | * @param[in] output Output tensor info. Data types supported: F16/F32. |
| 871 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 872 | * |
| 873 | * @return a status |
| 874 | */ |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 875 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 876 | |
| 877 | // Inherited methods overridden: |
| 878 | void run() override; |
| 879 | |
| 880 | private: |
| 881 | struct Impl; |
| 882 | std::unique_ptr<Impl> _impl; |
Usama Arif | 52c54f6 | 2019-05-14 10:22:36 +0100 | [diff] [blame] | 883 | }; |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 884 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 885 | #endif /* ARM_COMPUTE_CLELEMENTWISEOPERATIONS_H */ |