Compute Library
 23.08
ClElementwiseOperations.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021, 2023 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_CL_ELEMENTWISE_OPERATIONS_H
25 #define ARM_COMPUTE_CL_ELEMENTWISE_OPERATIONS_H
26 
29 #include "src/gpu/cl/IClOperator.h"
30 
31 namespace arm_compute
32 {
33 namespace opencl
34 {
35 /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for division
36  *
37  * @note The tensor data type for the inputs must be F16/F32.
38  * @note The function performs an arithmetic division between two tensors.
39  */
41 {
42 public:
43  /** Configure function for a given list of arguments.
44  *
45  * @param[in] compile_context The compile context to be used.
46  * @param[in] src1 First source tensor info. Data types supported: F16/F32.
47  * @param[in] src2 Second source tensor info. same as @p src1.
48  * @param[out] dst Destination tensor info. Data types supported: same as @p src1.
49  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
50  */
51  void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
52  /** Static function to check if given info will lead to a valid configuration
53  *
54  * Similar to @ref ClElementwiseDivision::configure()
55  *
56  * @return a status
57  */
58  static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
59 };
60 
61 /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for max
62  *
63  * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
64  * @note The function performs a max operation between two tensors.
65  */
67 {
68 public:
69  /** Configure function for a given list of arguments.
70  *
71  * @param[in] compile_context The compile context to be used.
72  * @param[in] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32.
73  * @param[in] src2 Second source tensor info. Data types supported: same as @p src1.
74  * @param[out] dst Destination tensor info. Data types supported: same as @p src1.
75  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
76  */
77  void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
78  /** Static function to check if given info will lead to a valid configuration
79  *
80  * Similar to @ref ClElementwiseMax::configure()
81  *
82  * @return a status
83  */
84  static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
85 };
86 
87 /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for min
88  *
89  * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
90  * @note The function performs a max operation between two tensors.
91  */
93 {
94 public:
95  /** Configure function for a given list of arguments.
96  *
97  * @param[in] compile_context The compile context to be used.
98  * @param[in] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32.
99  * @param[in] src2 Second source tensor info. Data types supported: same as @p src1.
100  * @param[out] dst Destination tensor info. Data types supported: same as @p src1.
101  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
102  */
103  void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
104  /** Static function to check if given info will lead to a valid configuration
105  *
106  * Similar to @ref ClElementwiseMin::configure()
107  *
108  * @return a status
109  */
110  static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
111 };
112 
113 /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for squared difference
114  *
115  * @note The tensor data type for the inputs must be QASYMM8/U8/S16/QSYMM16/F16/F32.
116  * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
117  */
119 {
120 public:
121  /** Configure function for a given list of arguments.
122  *
123  * @param[in] compile_context The compile context to be used.
124  * @param[in] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
125  * @param[in] src2 Second source tensor info. Data types supported: same as @p src1.
126  * @param[out] dst Destination tensor info. Data types supported: same as @p src1.
127  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
128  */
129  void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
130  /** Static function to check if given info will lead to a valid configuration
131  *
132  * Similar to @ref ClElementwiseSquaredDiff::configure()
133  *
134  * @return a status
135  */
136  static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
137 };
138 
139 /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for power
140  *
141  * @note The tensor data type for the inputs must be F16/F32.
142  * @note The function performs an elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
143  */
145 {
146 public:
147  /** Configure function for a given list of arguments.
148  *
149  * @param[in] compile_context The compile context to be used.
150  * @param[in] src1 First source tensor info. Data types supported: F16/F32.
151  * @param[in] src2 Second source tensor info. Data types supported: F16/F32.
152  * @param[out] dst Destination tensor info. Data types supported:F16/F32.
153  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
154  */
155  void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
156  /** Static function to check if given info will lead to a valid configuration
157  *
158  * Similar to @ref ClElementwisePower::configure()
159  *
160  * @return a status
161  */
162  static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
163 };
164 } // namespace opencl
165 } // namespace arm_compute
166 #endif /* ARM_COMPUTE_CL_ELEMENTWISE_OPERATIONS_H */
arm_compute::opencl::ClElementwiseSquaredDiff
Basic function to run opencl::kernels::ClArithmeticKernel for squared difference.
Definition: ClElementwiseOperations.h:118
arm_compute::opencl::ClElementwiseSquaredDiff::configure
void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Configure function for a given list of arguments.
Definition: ClElementwiseOperations.cpp:73
arm_compute::opencl::ClElementwiseDivision::configure
void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Configure function for a given list of arguments.
Definition: ClElementwiseOperations.cpp:34
arm_compute::opencl::ClElementwiseMax::validate
static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
Definition: ClElementwiseOperations.cpp:55
arm_compute::test::validation::dst
auto dst
Definition: DFT.cpp:170
ActivationLayerInfo.h
arm_compute::opencl::ClElementwiseMin::validate
static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
Definition: ClElementwiseOperations.cpp:68
arm_compute::opencl::ClElementwisePower::validate
static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
Definition: ClElementwiseOperations.cpp:94
arm_compute::opencl::ClElementwisePower::configure
void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Configure function for a given list of arguments.
Definition: ClElementwiseOperations.cpp:86
arm_compute::ActivationLayerInfo
Activation Layer Information class.
Definition: ActivationLayerInfo.h:55
arm_compute::test::validation::act_info
act_info
Definition: DirectConvolutionLayer.cpp:547
IClOperator.h
arm_compute::experimental::ICLOperator
Basic interface for functions which have a single async CL kernel.
Definition: ICLOperator.h:41
arm_compute::opencl::ClElementwiseDivision
Basic function to run opencl::kernels::ClArithmeticKernel for division.
Definition: ClElementwiseOperations.h:40
arm_compute::CLCompileContext
CLCompileContext class.
Definition: CLCompileContext.h:204
ClCompileContext.h
arm_compute::opencl::ClElementwiseMin
Basic function to run opencl::kernels::ClArithmeticKernel for min.
Definition: ClElementwiseOperations.h:92
arm_compute::Status
Status class.
Definition: Error.h:52
arm_compute::opencl::ClElementwiseMin::configure
void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Configure function for a given list of arguments.
Definition: ClElementwiseOperations.cpp:60
arm_compute::opencl::ClElementwisePower
Basic function to run opencl::kernels::ClArithmeticKernel for power.
Definition: ClElementwiseOperations.h:144
arm_compute
Copyright (c) 2017-2023 Arm Limited.
Definition: introduction.dox:24
arm_compute::opencl::ClElementwiseDivision::validate
static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
Definition: ClElementwiseOperations.cpp:42
arm_compute::opencl::ClElementwiseMax::configure
void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Configure function for a given list of arguments.
Definition: ClElementwiseOperations.cpp:47
arm_compute::opencl::ClElementwiseSquaredDiff::validate
static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
Definition: ClElementwiseOperations.cpp:81
arm_compute::ITensorInfo
Store the tensor's metadata.
Definition: ITensorInfo.h:43
arm_compute::opencl::ClElementwiseMax
Basic function to run opencl::kernels::ClArithmeticKernel for max.
Definition: ClElementwiseOperations.h:66