1 /* 2 * Copyright (c) 2018-2020 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_NEELEMENTWISEUNARYLAYER_H 25 #define ARM_COMPUTE_NEELEMENTWISEUNARYLAYER_H 26 27 #include "arm_compute/core/Error.h" 28 #include "arm_compute/runtime/NEON/INESimpleFunctionNoBorder.h" 29 30 namespace arm_compute 31 { 32 class ITensor; 33 class ITensorInfo; 34 35 /** Basic function to perform inverse square root on an input tensor. */ 36 class NERsqrtLayer : public INESimpleFunctionNoBorder 37 { 38 public: 39 /** Initialize the function 40 * 41 * @param[in] input Input tensor. Data types supported: F16/F32. 42 * @param[out] output Output tensor. Data types supported: same as @p input. 43 */ 44 void configure(const ITensor *input, ITensor *output); 45 /** Static function to check if given info will lead to a valid configuration of @ref NERsqrtLayer 46 * 47 * @param[in] input First tensor input info. Data types supported: F16/F32. 48 * @param[in] output Output tensor info. Data types supported: Same as @p input. 49 * 50 * @return a status 51 */ 52 static Status validate(const ITensorInfo *input, const ITensorInfo *output); 53 }; 54 55 /** Basic function to perform exponential on an input tensor. */ 56 class NEExpLayer : public INESimpleFunctionNoBorder 57 { 58 public: 59 /** Initialize the function 60 * 61 * @param[in] input Input tensor. Data types supported: F16/F32. 62 * @param[out] output Output tensor. Data types supported: same as @p input. 63 */ 64 void configure(const ITensor *input, ITensor *output); 65 /** Static function to check if given info will lead to a valid configuration of @ref NEExpLayer 66 * 67 * @param[in] input First tensor input info. Data types supported: F16/F32. 68 * @param[in] output Output tensor info. Data types supported: Same as @p input. 69 * 70 * @return a status 71 */ 72 static Status validate(const ITensorInfo *input, const ITensorInfo *output); 73 }; 74 75 /** Basic function to negate an input tensor. */ 76 class NENegLayer : public INESimpleFunctionNoBorder 77 { 78 public: 79 /** Initialize the function 80 * 81 * @param[in] input Input tensor. Data types supported: F16/F32/S32. 82 * @param[out] output Output tensor. Data types supported: same as @p input. 83 */ 84 void configure(const ITensor *input, ITensor *output); 85 /** Static function to check if given info will lead to a valid configuration of @ref NENegLayer 86 * 87 * @param[in] input First tensor input info. Data types supported: F16/F32/S32. 88 * @param[in] output Output tensor info. Data types supported: Same as @p input. 89 * 90 * @return a status 91 */ 92 static Status validate(const ITensorInfo *input, const ITensorInfo *output); 93 }; 94 95 /** Basic function to compute the natural logarithm of an input tensor. */ 96 class NELogLayer : public INESimpleFunctionNoBorder 97 { 98 public: 99 /** Initialize the function 100 * 101 * @param[in] input Input tensor. Data types supported: F16/F32. 102 * @param[out] output Output tensor. Data types supported: same as @p input. 103 */ 104 void configure(const ITensor *input, ITensor *output); 105 /** Static function to check if given info will lead to a valid configuration of @ref NELogLayer 106 * 107 * @param[in] input First tensor input info. Data types supported: F16/F32. 108 * @param[in] output Output tensor info. Data types supported: Same as @p input. 109 * 110 * @return a status 111 */ 112 static Status validate(const ITensorInfo *input, const ITensorInfo *output); 113 }; 114 115 /** Basic function to compute the absolute value of an input tensor. */ 116 class NEAbsLayer : public INESimpleFunctionNoBorder 117 { 118 public: 119 /** Initialize the function 120 * 121 * @param[in] input Input tensor. Data types supported: F16/F32/S32. 122 * @param[out] output Output tensor. Data types supported: same as @p input. 123 */ 124 void configure(const ITensor *input, ITensor *output); 125 /** Static function to check if given info will lead to a valid configuration of @ref NEAbsLayer 126 * 127 * @param[in] input First tensor input info. Data types supported: F16/F32/S32. 128 * @param[in] output Output tensor info. Data types supported: Same as @p input. 129 * 130 * @return a status 131 */ 132 static Status validate(const ITensorInfo *input, const ITensorInfo *output); 133 }; 134 135 /** Basic function to compute the round value elementwise of an input tensor. */ 136 class NERoundLayer : public INESimpleFunctionNoBorder 137 { 138 public: 139 /** Initialize the function 140 * 141 * @param[in] input Input tensor. Data types supported: F16/F32. 142 * @param[out] output Output tensor. Data types supported: same as @p input. 143 */ 144 void configure(const ITensor *input, ITensor *output); 145 /** Static function to check if given info will lead to a valid configuration of @ref NERoundLayer 146 * 147 * @param[in] input First tensor input info. Data types supported: F16/F32. 148 * @param[in] output Output tensor info. Data types supported: Same as @p input. 149 * 150 * @return a status 151 */ 152 static Status validate(const ITensorInfo *input, const ITensorInfo *output); 153 }; 154 155 /** Basic function to compute the sine of an input tensor. */ 156 class NESinLayer : public INESimpleFunctionNoBorder 157 { 158 public: 159 /** Initialize the function 160 * 161 * @param[in] input Input tensor. Data types supported: F16/F32. 162 * @param[out] output Output tensor. Data types supported: same as @p input. 163 */ 164 void configure(const ITensor *input, ITensor *output); 165 /** Static function to check if given info will lead to a valid configuration of @ref NESinLayer 166 * 167 * @param[in] input First tensor input info. Data types supported: F16/F32. 168 * @param[in] output Output tensor info. Data types supported: Same as @p input. 169 * 170 * @return a status 171 */ 172 static Status validate(const ITensorInfo *input, const ITensorInfo *output); 173 }; 174 } // namespace arm_compute 175 #endif /* ARM_COMPUTE_NEELEMENTWISEUNARYLAYER_H */ 176