blob: a23b789ab54eb846c6a469afe55531f2c5c0398e [file] [log] [blame]
Michele Di Giorgioc9c89052021-01-26 10:20:17 +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_UNARY_H
25#define ARM_COMPUTE_CL_ELEMENTWISE_UNARY_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 Giorgioc9c89052021-01-26 10:20:17 +000029
30namespace arm_compute
31{
32namespace opencl
33{
34/** Basic function to perform inverse square root on an src tensor. */
35class ClRsqrt : public IClOperator
36{
37public:
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000038 /** Initialize the function
39 *
40 * @param[in] compile_context The compile context to be used.
41 * @param[in] src Source tensor info. Data types supported: F16/F32.
42 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
43 */
44 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010045 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000046 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010047 * Similar to @ref ClRsqrt::configure()
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000048 *
49 * @return a status
50 */
51 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
52};
53
54/** Basic function to perform exponential on an src tensor. */
55class ClExp : public IClOperator
56{
57public:
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000058 /** Initialize the function
59 *
60 * @param[in] compile_context The compile context to be used.
61 * @param[in] src Source tensor info. Data types supported: F16/F32.
62 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
63 */
64 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010065 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000066 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010067 * Similar to @ref ClExp::configure()
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000068 *
69 * @return a status
70 */
71 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
72};
73
74/** Basic function to negate an src tensor. */
75class ClNeg : public IClOperator
76{
77public:
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000078 /** Initialize the function
79 *
80 * @param[in] compile_context The compile context to be used.
81 * @param[in] src Source tensor info. Data types supported: F16/F32.
82 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
83 */
84 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010085 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000086 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +010087 * Similar to @ref ClNeg::configure()
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000088 *
89 * @return a status
90 */
91 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
92};
93
94/** Basic function to calculate sine of an src tensor. */
95class ClSin : public IClOperator
96{
97public:
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000098 /** Initialize the function
99 *
100 * @param[in] compile_context The compile context to be used.
101 * @param[in] src Source tensor info. Data types supported: F16/F32.
102 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
103 */
104 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100105 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000106 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100107 * Similar to @ref ClSin::configure()
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000108 *
109 * @return a status
110 */
111 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
112};
113
114/** Basic function to perform elementwise log on an src tensor. */
115class ClLog : public IClOperator
116{
117public:
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000118 /** Initialize the function
119 *
120 * @param[in] compile_context The compile context to be used.
121 * @param[in] src Source tensor info. Data types supported: F16/F32.
122 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
123 */
124 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100125 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000126 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100127 * Similar to @ref ClLog::configure()
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000128 *
129 * @return a status
130 */
131 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
132};
133
134/** Basic function to get the absolute value of an src tensor. */
135class ClAbs : public IClOperator
136{
137public:
138 /** Initialize the function
139 *
140 * @param[in] compile_context The compile context to be used.
141 * @param[in] src Source tensor info. Data types supported: F16/F32.
142 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
143 */
144 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100145 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000146 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100147 * Similar to @ref ClAbs::configure()
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000148 *
149 * @return a status
150 */
151 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
152};
153
154/** Basic function to get the round (to the nearest even) value of an src tensor. */
155class ClRound : public IClOperator
156{
157public:
158 /** Initialize the function
159 *
160 * @param[in] compile_context The compile context to be used.
161 * @param[in] src Source tensor info. Data types supported: F16/F32.
162 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
163 */
164 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100165 /** Static function to check if given info will lead to a valid configuration
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000166 *
Georgios Pinitas2eb5d162021-07-02 09:01:49 +0100167 * Similar to @ref ClRound::configure()
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000168 *
169 * @return a status
170 */
171 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
172};
173} // namespace opencl
174} // namespace arm_compute
175#endif /* ARM_COMPUTE_CL_ELEMENTWISE_UNARY_H */