Compute Library
 22.05
CLElementwiseOperations.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2021 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef ARM_COMPUTE_CLELEMENTWISEOPERATIONS_H
25 #define ARM_COMPUTE_CLELEMENTWISEOPERATIONS_H
26 
29 
30 namespace arm_compute
31 {
32 class ICLTensor;
33 class CLCompileContext;
34 class ITensorInfo;
35 
36 /** Basic function to run @ref opencl::kernels::ClSaturatedArithmeticKernel for addition
37  *
38  * @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
39  * @note The function performs an arithmetic addition between two tensors.
40  */
42 {
43 public:
44  /** Default Constructor */
46  /** Default Destructor */
48  /** Prevent instances of this class from being copied (As this class contains pointers) */
50  /** Default move constructor */
52  /** Prevent instances of this class from being copied (As this class contains pointers) */
54  /** Default move assignment operator */
56  /** Initialise the kernel's inputs, output and conversion policy.
57  *
58  * Valid data layouts:
59  * - All
60  *
61  * Valid data type configurations:
62  * |src0 |src1 |dst |
63  * |:--------------|:--------------|:--------------|
64  * |QASYMM8 |QASYMM8 |QASYMM8 |
65  * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
66  * |QSYMM16 |QSYMM16 |QASYMM16 |
67  * |U8 |U8 |U8 |
68  * |U8 |U8 |S16 |
69  * |U8 |S16 |S16 |
70  * |S16 |U8 |S16 |
71  * |S16 |S16 |S16 |
72  * |S32 |S32 |S32 |
73  * |F16 |F16 |F16 |
74  * |F32 |F32 |F32 |
75  *
76  * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
77  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
78  * @param[in, out] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
79  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
80  * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
81  * @param[in] policy Policy to use to handle overflow.
82  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
83  */
84  void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
85  /** Initialise the kernel's inputs, output and conversion policy.
86  *
87  * Valid configurations (Input1,Input2) -> Output :
88  *
89  * - (U8,U8) -> U8
90  * - (U8,U8) -> S16
91  * - (S16,U8) -> S16
92  * - (U8,S16) -> S16
93  * - (S16,S16) -> S16
94  * - (S32,S32) -> S32
95  * - (F16,F16) -> F16
96  * - (F32,F32) -> F32
97  * - (QASYMM8,QASYMM8) -> QASYMM8
98  * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
99  * - (QSYMM16,QSYMM16) -> QSYMM16
100  *
101  * @param[in] compile_context The compile context to be used.
102  * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
103  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
104  * @param[in, out] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
105  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
106  * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
107  * @param[in] policy Policy to use to handle overflow.
108  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
109  */
110  void configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy,
111  const ActivationLayerInfo &act_info = ActivationLayerInfo());
112  /** Static function to check if given info will lead to a valid configuration of @ref opencl::kernels::ClSaturatedArithmeticKernel for addition
113  *
114  * Valid configurations (Input1,Input2) -> Output :
115  *
116  * - (U8,U8) -> U8
117  * - (U8,U8) -> S16
118  * - (S16,U8) -> S16
119  * - (U8,S16) -> S16
120  * - (S16,S16) -> S16
121  * - (S32,S32) -> S32
122  * - (F16,F16) -> F16
123  * - (F32,F32) -> F32
124  * - (QASYMM8,QASYMM8) -> QASYMM8
125  * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
126  * - (QSYMM16,QSYMM16) -> QSYMM16
127  *
128  * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
129  * @param[in] input2 Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
130  * @param[in] output Output tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
131  * @param[in] policy Policy to use to handle overflow.
132  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
133  *
134  * @return a status
135  */
136  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
137 
138  // Inherited methods overridden:
139  void run() override;
140 
141 private:
142  struct Impl;
143  std::unique_ptr<Impl> _impl;
144 };
145 
146 /** Basic function to run @ref opencl::kernels::ClSaturatedArithmeticKernel for subtraction
147  *
148  * @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/S32/F16/F32.
149  * @note The function performs an arithmetic subtraction between two tensors.
150  */
152 {
153 public:
154  /** Default Constructor */
156  /** Default Destructor */
158  /** Prevent instances of this class from being copied (As this class contains pointers) */
160  /** Default move constructor */
162  /** Prevent instances of this class from being copied (As this class contains pointers) */
164  /** Default move assignment operator */
166  /** Initialise the kernel's inputs, output and conversion policy.
167  *
168  * Valid data layouts:
169  * - All
170  *
171  * Valid data type configurations:
172  * |src0 |src1 |dst |
173  * |:--------------|:--------------|:--------------|
174  * |QASYMM8 |QASYMM8 |QASYMM8 |
175  * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
176  * |QSYMM16 |QSYMM16 |QASYMM16 |
177  * |U8 |U8 |U8 |
178  * |U8 |U8 |S16 |
179  * |U8 |S16 |S16 |
180  * |S16 |U8 |S16 |
181  * |S16 |S16 |S16 |
182  * |S32 |S32 |S32 |
183  * |F16 |F16 |F16 |
184  * |F32 |F32 |F32 |
185  *
186  * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
187  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
188  * @param[in, out] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
189  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
190  * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
191  * @param[in] policy Policy to use to handle overflow.
192  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
193  */
194  void configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
195  /** Initialise the kernel's inputs, output and conversion policy.
196  *
197  * Valid configurations (Input1,Input2) -> Output :
198  *
199  * - (U8,U8) -> U8
200  * - (U8,U8) -> S16
201  * - (S16,U8) -> S16
202  * - (U8,S16) -> S16
203  * - (S16,S16) -> S16
204  * - (S32,S32) -> S32
205  * - (F16,F16) -> F16
206  * - (F32,F32) -> F32
207  * - (QASYMM8,QASYMM8) -> QASYMM8
208  * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
209  * - (QSYMM16,QSYMM16) -> QSYMM16
210  *
211  * @param[in] compile_context The compile context to be used.
212  * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
213  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
214  * @param[in, out] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
215  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
216  * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
217  * @param[in] policy Policy to use to handle overflow.
218  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
219  */
220  void configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy,
221  const ActivationLayerInfo &act_info = ActivationLayerInfo());
222  /** Static function to check if given info will lead to a valid configuration of @ref opencl::kernels::ClSaturatedArithmeticKernel for subtraction
223  *
224  * Valid configurations (Input1,Input2) -> Output :
225  *
226  * - (U8,U8) -> U8
227  * - (U8,U8) -> S16
228  * - (S16,U8) -> S16
229  * - (U8,S16) -> S16
230  * - (S16,S16) -> S16
231  * - (S32,S32) -> S32
232  * - (F16,F16) -> F16
233  * - (F32,F32) -> F32
234  * - (QASYMM8,QASYMM8) -> QASYMM8
235  * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
236  * - (QSYMM16,QSYMM16) -> QSYMM16
237  *
238  * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
239  * @param[in] input2 Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
240  * @param[in] output Output tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32.
241  * @param[in] policy Policy to use to handle overflow.
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, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
247 
248  // Inherited methods overridden:
249  void run() override;
250 
251 private:
252  struct Impl;
253  std::unique_ptr<Impl> _impl;
254 };
255 
256 /** Basic function to run @ref opencl::kernels::ClSaturatedArithmeticKernel for division
257  *
258  * @note The tensor data type for the inputs must be F16/F32.
259  * @note The function performs an arithmetic division between two tensors.
260  */
262 {
263 public:
264  /** Default Constructor */
266  /** Default Destructor */
268  /** Prevent instances of this class from being copied (As this class contains pointers) */
269  CLArithmeticDivision(const CLArithmeticDivision &) = delete;
270  /** Default move constructor */
272  /** Prevent instances of this class from being copied (As this class contains pointers) */
274  /** Default move assignment operator */
276  /** Initialise the kernel's inputs, output.
277  *
278  * Valid data layouts:
279  * - All
280  *
281  * Valid data type configurations:
282  * |src0 |src1 |dst |
283  * |:--------------|:--------------|:--------------|
284  * |F16 |F16 |F16 |
285  * |F32 |F32 |F32 |
286  *
287  * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
288  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
289  * @param[in, out] input2 Second tensor input. Same as @p input1.
290  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
291  * @param[out] output Output tensor. Data types supported: Same as @p input1.
292  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
293  */
294  void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
295  /** Initialise the kernel's inputs, output.
296  *
297  * @param[in] compile_context The compile context to be used.
298  * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
299  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
300  * @param[in, out] input2 Second tensor input. Same as @p input1.
301  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
302  * @param[out] output Output tensor. Data types supported: Same as @p input1.
303  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
304  */
305  void configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
306  /** Static function to check if given info will lead to a valid configuration of @ref CLArithmeticDivision
307  *
308  * @param[in] input1 First tensor input info. Data types supported: F16/F32.
309  * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1.
310  * @param[in] output Output tensor info. Data types supported: Same as @p input1.
311  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
312  *
313  * @return a status
314  */
315  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
316 
317  // Inherited methods overridden:
318  void run() override;
319 
320 private:
321  struct Impl;
322  std::unique_ptr<Impl> _impl;
323 };
324 
325 /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for max
326  *
327  * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
328  * @note The function performs a max operation between two tensors.
329  */
331 {
332 public:
333  /** Default Constructor */
335  /** Default Destructor */
336  ~CLElementwiseMax();
337  /** Prevent instances of this class from being copied (As this class contains pointers) */
338  CLElementwiseMax(const CLElementwiseMax &) = delete;
339  /** Default move constructor */
341  /** Prevent instances of this class from being copied (As this class contains pointers) */
342  CLElementwiseMax &operator=(const CLElementwiseMax &) = delete;
343  /** Default move assignment operator */
345  /** Initialise the kernel's inputs, output and conversion policy.
346  *
347  * Valid data layouts:
348  * - All
349  *
350  * Valid data type configurations:
351  * |src0 |src1 |dst |
352  * |:--------------|:--------------|:--------------|
353  * |QASYMM8 |QASYMM8 |QASYMM8 |
354  * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
355  * |QSYMM16 |QSYMM16 |QASYMM16 |
356  * |U8 |U8 |U8 |
357  * |S16 |S16 |S16 |
358  * |S32 |S32 |S32 |
359  * |U32 |U32 |U32 |
360  * |F16 |F16 |F16 |
361  * |F32 |F32 |F32 |
362  *
363  * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32.
364  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
365  * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1.
366  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
367  * @param[out] output Output tensor. Data types supported: same as @p input1.
368  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
369  */
370  void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
371  /** Initialise the kernel's inputs, output and conversion policy.
372  *
373  * @param[in] compile_context The compile context to be used.
374  * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32.
375  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
376  * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1.
377  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
378  * @param[out] output Output tensor. Data types supported: same as @p input1.
379  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
380  */
381  void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
382  /** Static function to check if given info will lead to a valid configuration of @ref opencl::kernels::ClArithmeticKernel for max
383  *
384  * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32.
385  * @param[in] input2 Second tensor input info. Data types supported: same as @p input1.
386  * @param[in] output Output tensor info. Data types supported: same as @p input1.
387  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
388  *
389  * @return a status
390  */
391  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
392 
393  // Inherited methods overridden:
394  void run() override;
395 
396 private:
397  struct Impl;
398  std::unique_ptr<Impl> _impl;
399 };
400 
401 /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for min
402  *
403  * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
404  * @note The function performs a max operation between two tensors.
405  */
407 {
408 public:
409  /** Default Constructor */
411  /** Default Destructor */
412  ~CLElementwiseMin();
413  /** Prevent instances of this class from being copied (As this class contains pointers) */
414  CLElementwiseMin(const CLElementwiseMin &) = delete;
415  /** Default move constructor */
417  /** Prevent instances of this class from being copied (As this class contains pointers) */
418  CLElementwiseMin &operator=(const CLElementwiseMin &) = delete;
419  /** Default move assignment operator */
421  /** Initialise the kernel's inputs, output and conversion policy.
422  *
423  * Valid data layouts:
424  * - All
425  *
426  * Valid data type configurations:
427  * |src0 |src1 |dst |
428  * |:--------------|:--------------|:--------------|
429  * |QASYMM8 |QASYMM8 |QASYMM8 |
430  * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
431  * |QSYMM16 |QSYMM16 |QASYMM16 |
432  * |U8 |U8 |U8 |
433  * |S16 |S16 |S16 |
434  * |S32 |S32 |S32 |
435  * |U32 |U32 |U32 |
436  * |F16 |F16 |F16 |
437  * |F32 |F32 |F32 |
438  *
439  * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32.
440  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
441  * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1.
442  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
443  * @param[out] output Output tensor. Data types supported: same as @p input1.
444  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
445  */
446  void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
447  /** Initialise the kernel's inputs, output and conversion policy.
448  *
449  * @param[in] compile_context The compile context to be used.
450  * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32.
451  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
452  * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1.
453  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
454  * @param[out] output Output tensor. Data types supported: same as @p input1.
455  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
456  */
457  void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
458  /** Static function to check if given info will lead to a valid configuration of @ref opencl::kernels::ClArithmeticKernel for min
459  *
460  * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32.
461  * @param[in] input2 Second tensor input info. Data types supported: same as @p input1.
462  * @param[in] output Output tensor info. Data types supported: same as @p input1.
463  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
464  *
465  * @return a status
466  */
467  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
468 
469  // Inherited methods overridden:
470  void run() override;
471 
472 private:
473  struct Impl;
474  std::unique_ptr<Impl> _impl;
475 };
476 
477 /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for squared difference
478  *
479  * @note The tensor data type for the inputs must be QASYMM8/U8/S16/QSYMM16/F16/F32.
480  * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
481  */
483 {
484 public:
485  /** Default Constructor */
487  /** Default Destructor */
489  /** Prevent instances of this class from being copied (As this class contains pointers) */
491  /** Default move constructor */
493  /** Prevent instances of this class from being copied (As this class contains pointers) */
495  /** Default move assignment operator */
497  /** Initialise the kernel's inputs, output and conversion policy.
498  *
499  * Valid data layouts:
500  * - All
501  *
502  * Valid data type configurations:
503  * |src0 |src1 |dst |
504  * |:--------------|:--------------|:--------------|
505  * |QASYMM8 |QASYMM8 |QASYMM8 |
506  * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
507  * |QSYMM16 |QSYMM16 |QASYMM16 |
508  * |U8 |U8 |U8 |
509  * |S16 |S16 |S16 |
510  * |F16 |F16 |F16 |
511  * |F32 |F32 |F32 |
512  *
513  * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
514  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
515  * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1.
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[out] output Output tensor. Data types supported: same as @p input1.
518  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
519  */
520  void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
521  /** Initialise the kernel's inputs, output and conversion policy.
522  *
523  * @param[in] compile_context The compile context to be used.
524  * @param[in, out] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
525  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
526  * @param[in, out] input2 Second tensor input. Data types supported: same as @p input1.
527  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
528  * @param[out] output Output tensor. Data types supported: same as @p input1.
529  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
530  */
531  void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
532  /** Static function to check if given info will lead to a valid configuration of @ref opencl::kernels::ClArithmeticKernel for squared difference
533  *
534  * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
535  * @param[in] input2 Second tensor input info. Data types supported: same as @p input1.
536  * @param[in] output Output tensor info. Data types supported: same as @p input1.
537  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
538  *
539  * @return a status
540  */
541  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
542 
543  // Inherited methods overridden:
544  void run() override;
545 
546 private:
547  struct Impl;
548  std::unique_ptr<Impl> _impl;
549 };
550 
551 /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for power
552  *
553  * @note The tensor data type for the inputs must be F16/F32.
554  * @note The function performs an elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
555  */
557 {
558 public:
559  /** Default Constructor */
561  /** Default Destructor */
563  /** Prevent instances of this class from being copied (As this class contains pointers) */
564  CLElementwisePower(const CLElementwisePower &) = delete;
565  /** Default move constructor */
567  /** Prevent instances of this class from being copied (As this class contains pointers) */
569  /** Default move assignment operator */
571  /** Initialise the kernel's inputs, output and conversion policy.
572  *
573  * Valid data layouts:
574  * - All
575  *
576  * Valid data type configurations:
577  * |src0 |src1 |dst |
578  * |:--------------|:--------------|:--------------|
579  * |F16 |F16 |F16 |
580  * |F32 |F32 |F32 |
581  *
582  * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
583  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
584  * @param[in, out] input2 Second tensor input. Data types supported: F16/F32.
585  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
586  * @param[out] output Output tensor. Data types supported:F16/F32.
587  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
588  */
589  void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
590  /** Initialise the kernel's inputs, output and conversion policy.
591  *
592  * @param[in] compile_context The compile context to be used.
593  * @param[in, out] input1 First tensor input. Data types supported: F16/F32.
594  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
595  * @param[in, out] input2 Second tensor input. Data types supported: F16/F32.
596  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
597  * @param[out] output Output tensor. Data types supported:F16/F32.
598  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
599  */
600  void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
601  /** Static function to check if given info will lead to a valid configuration of @ref opencl::kernels::ClArithmeticKernel for power
602  *
603  * @param[in] input1 First tensor input info. Data types supported: F16/F32.
604  * @param[in] input2 Second tensor input info. Data types supported: F16/F32.
605  * @param[in] output Output tensor info. Data types supported: F16/F32.
606  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
607  *
608  * @return a status
609  */
610  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
611 
612  // Inherited methods overridden:
613  void run() override;
614 
615 private:
616  struct Impl;
617  std::unique_ptr<Impl> _impl;
618 };
619 } // namespace arm_compute
620 #endif /* ARM_COMPUTE_CLELEMENTWISEOPERATIONS_H */
Basic function to run opencl::kernels::ClSaturatedArithmeticKernel for division.
Base class for all functions.
Definition: IFunction.h:30
void run() override
Run the kernels contained in the function.
Basic function to run opencl::kernels::ClArithmeticKernel for power.
Basic function to run opencl::kernels::ClArithmeticKernel for min.
Basic function to run opencl::kernels::ClSaturatedArithmeticKernel for addition.
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Activation Layer Information class.
Definition: Types.h:1625
~CLArithmeticAddition()
Default Destructor.
Copyright (c) 2017-2022 Arm Limited.
CLArithmeticAddition & operator=(const CLArithmeticAddition &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration of opencl::kernels::ClSatur...
void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Initialise the kernel&#39;s inputs, output and conversion policy.
CLCompileContext class.
Basic function to run opencl::kernels::ClArithmeticKernel for max.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
Basic function to run opencl::kernels::ClArithmeticKernel for squared difference. ...
Basic function to run opencl::kernels::ClSaturatedArithmeticKernel for subtraction.
ConvertPolicy
Policy to handle integer overflow.
Definition: Types.h:404