blob: 304b250d668d32057a1fb8fc3305822f73536b05 [file] [log] [blame]
Michele Di Giorgio237be032021-01-25 15:44:02 +00001/*
2 * Copyright (c) 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_CL_ELEMENTWISE_OPERATIONS_H
25#define ARM_COMPUTE_CL_ELEMENTWISE_OPERATIONS_H
26
Georgios Pinitas7891a732021-08-20 21:39:25 +010027#include "src/gpu/cl/ClCompileContext.h"
28#include "src/gpu/cl/IClOperator.h"
Michele Di Giorgio237be032021-01-25 15:44:02 +000029
30namespace arm_compute
31{
32namespace opencl
33{
34/** Basic function to run @ref opencl::kernels::ClArithmeticKernel for division
35 *
36 * @note The tensor data type for the inputs must be F16/F32.
37 * @note The function performs an arithmetic division between two tensors.
38 */
39class ClElementwiseDivision : public IClOperator
40{
41public:
Michele Di Giorgio237be032021-01-25 15:44:02 +000042 /** Configure function for a given list of arguments.
43 *
44 * @param[in] compile_context The compile context to be used.
45 * @param[in] src1 First source tensor info. Data types supported: F16/F32.
46 * @param[in] src2 Second source tensor info. same as @p src1.
47 * @param[out] dst Destination tensor info. Data types supported: same as @p src1.
48 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
49 */
50 void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010051 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgio237be032021-01-25 15:44:02 +000052 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010053 * Similar to @ref ClElementwiseDivision::configure()
Michele Di Giorgio237be032021-01-25 15:44:02 +000054 *
55 * @return a status
56 */
57 static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
58};
59
60/** Basic function to run @ref opencl::kernels::ClArithmeticKernel for max
61 *
62 * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
63 * @note The function performs a max operation between two tensors.
64 */
65class ClElementwiseMax : public IClOperator
66{
67public:
Michele Di Giorgio237be032021-01-25 15:44:02 +000068 /** Configure function for a given list of arguments.
69 *
70 * @param[in] compile_context The compile context to be used.
71 * @param[in] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32.
72 * @param[in] src2 Second source tensor info. Data types supported: same as @p src1.
73 * @param[out] dst Destination tensor info. Data types supported: same as @p src1.
74 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
75 */
76 void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010077 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgio237be032021-01-25 15:44:02 +000078 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010079 * Similar to @ref ClElementwiseMax::configure()
Michele Di Giorgio237be032021-01-25 15:44:02 +000080 *
81 * @return a status
82 */
83 static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
84};
85
86/** Basic function to run @ref opencl::kernels::ClArithmeticKernel for min
87 *
88 * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32.
89 * @note The function performs a max operation between two tensors.
90 */
91class ClElementwiseMin : public IClOperator
92{
93public:
Michele Di Giorgio237be032021-01-25 15:44:02 +000094 /** Configure function for a given list of arguments.
95 *
96 * @param[in] compile_context The compile context to be used.
97 * @param[in] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32.
98 * @param[in] src2 Second source tensor info. Data types supported: same as @p src1.
99 * @param[out] dst Destination tensor info. Data types supported: same as @p src1.
100 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
101 */
102 void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100103 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgio237be032021-01-25 15:44:02 +0000104 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100105 * Similar to @ref ClElementwiseMin::configure()
Michele Di Giorgio237be032021-01-25 15:44:02 +0000106 *
107 * @return a status
108 */
109 static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
110};
111
112/** Basic function to run @ref opencl::kernels::ClArithmeticKernel for squared difference
113 *
114 * @note The tensor data type for the inputs must be QASYMM8/U8/S16/QSYMM16/F16/F32.
115 * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2
116 */
117class ClElementwiseSquaredDiff : public IClOperator
118{
119public:
Michele Di Giorgio237be032021-01-25 15:44:02 +0000120 /** Configure function for a given list of arguments.
121 *
122 * @param[in] compile_context The compile context to be used.
123 * @param[in] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
124 * @param[in] src2 Second source tensor info. Data types supported: same as @p src1.
125 * @param[out] dst Destination tensor info. Data types supported: same as @p src1.
126 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
127 */
128 void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100129 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgio237be032021-01-25 15:44:02 +0000130 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100131 * Similar to @ref ClElementwiseSquaredDiff::configure()
Michele Di Giorgio237be032021-01-25 15:44:02 +0000132 *
133 * @return a status
134 */
135 static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
136};
137
138/** Basic function to run @ref opencl::kernels::ClArithmeticKernel for power
139 *
140 * @note The tensor data type for the inputs must be F16/F32.
141 * @note The function performs an elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i])
142 */
143class ClElementwisePower : public IClOperator
144{
145public:
Michele Di Giorgio237be032021-01-25 15:44:02 +0000146 /** Configure function for a given list of arguments.
147 *
148 * @param[in] compile_context The compile context to be used.
149 * @param[in] src1 First source tensor info. Data types supported: F16/F32.
150 * @param[in] src2 Second source tensor info. Data types supported: F16/F32.
151 * @param[out] dst Destination tensor info. Data types supported:F16/F32.
152 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
153 */
154 void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100155 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgio237be032021-01-25 15:44:02 +0000156 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100157 * Similar to @ref ClElementwisePower::configure()
Michele Di Giorgio237be032021-01-25 15:44:02 +0000158 *
159 * @return a status
160 */
161 static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
162};
163} // namespace opencl
164} // namespace arm_compute
165#endif /* ARM_COMPUTE_CL_ELEMENTWISE_OPERATIONS_H */