Compute Library
 21.05
ClElementwiseUnary.h
Go to the documentation of this file.
1 /*
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 
29 
30 namespace arm_compute
31 {
32 namespace opencl
33 {
34 /** Basic function to perform inverse square root on an src tensor. */
35 class ClRsqrt : public IClOperator
36 {
37 public:
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. */
58 class ClExp : public IClOperator
59 {
60 public:
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. */
81 class ClNeg : public IClOperator
82 {
83 public:
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. */
104 class ClSin : public IClOperator
105 {
106 public:
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. */
127 class ClLog : public IClOperator
128 {
129 public:
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. */
150 class ClAbs : public IClOperator
151 {
152 public:
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. */
171 class ClRound : public IClOperator
172 {
173 public:
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 */
void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
Initialize the function.
Basic function to calculate sine of an src tensor.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration of ClAbs.
ClExp()=default
Constructor.
Store the tensor's metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
Initialize the function.
SimpleTensor< float > src
Definition: DFT.cpp:155
Copyright (c) 2017-2021 Arm Limited.
void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
Initialize the function.
Basic function to get the round (to the nearest even) value of an src tensor.
void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
Initialize the function.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration of ClSin.
ClSin()=default
Constructor.
ClRsqrt()=default
Constructor.
Basic function to negate an src tensor.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration of ClRsqrt.
Basic function to perform exponential on an src tensor.
void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
Initialize the function.
Basic function to perform elementwise log on an src tensor.
void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
Initialize the function.
ClNeg()=default
Constructor.
Basic function to get the absolute value of an src tensor.
CLCompileContext class.
ClLog()=default
Constructor.
Basic function to perform inverse square root on an src tensor.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration of ClExp.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration of ClRound.
void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
Initialize the function.
Basic interface for functions which have a single async CL kernel.
Definition: ICLOperator.h:41
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration of ClNeg.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration of ClLog.