blob: b40e3e9a3b18f7b9a6265fdce914512dcde3b0b3 [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
27#include "src/core/gpu/cl/ClCompileContext.h"
28#include "src/runtime/gpu/cl/IClOperator.h"
29
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:
38 /** Constructor */
39 ClRsqrt() = default;
40 /** Initialize the function
41 *
42 * @param[in] compile_context The compile context to be used.
43 * @param[in] src Source tensor info. Data types supported: F16/F32.
44 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
45 */
46 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
47 /** Static function to check if given info will lead to a valid configuration of @ref ClRsqrt
48 *
49 * @param[in] src First source tensor info. Data types supported: F16/F32.
50 * @param[in] dst Destination tensor info. Data types supported: same as @p src.
51 *
52 * @return a status
53 */
54 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
55};
56
57/** Basic function to perform exponential on an src tensor. */
58class ClExp : public IClOperator
59{
60public:
61 /** Constructor */
62 ClExp() = default;
63 /** Initialize the function
64 *
65 * @param[in] compile_context The compile context to be used.
66 * @param[in] src Source tensor info. Data types supported: F16/F32.
67 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
68 */
69 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
70 /** Static function to check if given info will lead to a valid configuration of @ref ClExp
71 *
72 * @param[in] src First source tensor info. Data types supported: F16/F32.
73 * @param[in] dst Destination tensor info. Data types supported: same as @p src.
74 *
75 * @return a status
76 */
77 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
78};
79
80/** Basic function to negate an src tensor. */
81class ClNeg : public IClOperator
82{
83public:
84 /** Constructor */
85 ClNeg() = default;
86 /** Initialize the function
87 *
88 * @param[in] compile_context The compile context to be used.
89 * @param[in] src Source tensor info. Data types supported: F16/F32.
90 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
91 */
92 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
93 /** Static function to check if given info will lead to a valid configuration of @ref ClNeg
94 *
95 * @param[in] src First source tensor info. Data types supported: F16/F32.
96 * @param[in] dst Destination tensor info. Data types supported: same as @p src.
97 *
98 * @return a status
99 */
100 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
101};
102
103/** Basic function to calculate sine of an src tensor. */
104class ClSin : public IClOperator
105{
106public:
107 /** Constructor */
108 ClSin() = default;
109 /** Initialize the function
110 *
111 * @param[in] compile_context The compile context to be used.
112 * @param[in] src Source tensor info. Data types supported: F16/F32.
113 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
114 */
115 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
116 /** Static function to check if given info will lead to a valid configuration of @ref ClSin
117 *
118 * @param[in] src First source tensor info. Data types supported: F16/F32.
119 * @param[in] dst Destination tensor info. Data types supported: same as @p src.
120 *
121 * @return a status
122 */
123 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
124};
125
126/** Basic function to perform elementwise log on an src tensor. */
127class ClLog : public IClOperator
128{
129public:
130 /** Constructor */
131 ClLog() = default;
132 /** Initialize the function
133 *
134 * @param[in] compile_context The compile context to be used.
135 * @param[in] src Source tensor info. Data types supported: F16/F32.
136 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
137 */
138 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
139 /** Static function to check if given info will lead to a valid configuration of @ref ClLog
140 *
141 * @param[in] src First source tensor info. Data types supported: F16/F32.
142 * @param[in] dst Destination tensor info. Data types supported: same as @p src.
143 *
144 * @return a status
145 */
146 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
147};
148
149/** Basic function to get the absolute value of an src tensor. */
150class ClAbs : public IClOperator
151{
152public:
153 /** Initialize the function
154 *
155 * @param[in] compile_context The compile context to be used.
156 * @param[in] src Source tensor info. Data types supported: F16/F32.
157 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
158 */
159 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
160 /** Static function to check if given info will lead to a valid configuration of @ref ClAbs
161 *
162 * @param[in] src First source tensor info. Data types supported: F16/F32.
163 * @param[in] dst Destination tensor info. Data types supported: same as @p src.
164 *
165 * @return a status
166 */
167 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
168};
169
170/** Basic function to get the round (to the nearest even) value of an src tensor. */
171class ClRound : public IClOperator
172{
173public:
174 /** Initialize the function
175 *
176 * @param[in] compile_context The compile context to be used.
177 * @param[in] src Source tensor info. Data types supported: F16/F32.
178 * @param[out] dst Destination tensor info. Data types supported: same as @p src.
179 */
180 void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst);
181 /** Static function to check if given info will lead to a valid configuration of @ref ClRound
182 *
183 * @param[in] src First source tensor info. Data types supported: F16/F32.
184 * @param[in] dst Destination tensor info. Data types supported: same as @p src.
185 *
186 * @return a status
187 */
188 static Status validate(const ITensorInfo *src, const ITensorInfo *dst);
189};
190} // namespace opencl
191} // namespace arm_compute
192#endif /* ARM_COMPUTE_CL_ELEMENTWISE_UNARY_H */