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 27 #include "src/gpu/cl/ClCompileContext.h" 28 #include "src/gpu/cl/IClOperator.h" 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 /** 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); 45 /** Static function to check if given info will lead to a valid configuration 46 * 47 * Similar to @ref ClRsqrt::configure() 48 * 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. */ 55 class ClExp : public IClOperator 56 { 57 public: 58 /** 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); 65 /** Static function to check if given info will lead to a valid configuration 66 * 67 * Similar to @ref ClExp::configure() 68 * 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. */ 75 class ClNeg : public IClOperator 76 { 77 public: 78 /** 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); 85 /** Static function to check if given info will lead to a valid configuration 86 * 87 * Similar to @ref ClNeg::configure() 88 * 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. */ 95 class ClSin : public IClOperator 96 { 97 public: 98 /** 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); 105 /** Static function to check if given info will lead to a valid configuration 106 * 107 * Similar to @ref ClSin::configure() 108 * 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. */ 115 class ClLog : public IClOperator 116 { 117 public: 118 /** 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); 125 /** Static function to check if given info will lead to a valid configuration 126 * 127 * Similar to @ref ClLog::configure() 128 * 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. */ 135 class ClAbs : public IClOperator 136 { 137 public: 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); 145 /** Static function to check if given info will lead to a valid configuration 146 * 147 * Similar to @ref ClAbs::configure() 148 * 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. */ 155 class ClRound : public IClOperator 156 { 157 public: 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); 165 /** Static function to check if given info will lead to a valid configuration 166 * 167 * Similar to @ref ClRound::configure() 168 * 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 */ 176