giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 1 | /* |
morgolock | a359805 | 2019-12-31 12:20:47 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2020 ARM Limited. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 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 |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 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, |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H |
| 25 | #define ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/core/Types.h" |
| 28 | #include "arm_compute/runtime/NEON/INESimpleFunction.h" |
| 29 | |
| 30 | namespace arm_compute |
| 31 | { |
| 32 | class ITensor; |
| 33 | |
| 34 | /** Basic function to run @ref NEArithmeticOperationKernel for max |
| 35 | * |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 36 | * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 37 | * @note The function performs a max operation between two tensors. |
| 38 | */ |
| 39 | class NEElementwiseMax : public INESimpleFunction |
| 40 | { |
| 41 | public: |
| 42 | /** Initialise the kernel's inputs, output and conversion policy. |
| 43 | * |
morgolock | a359805 | 2019-12-31 12:20:47 +0000 | [diff] [blame] | 44 | * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 45 | * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 46 | * @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 47 | */ |
| 48 | void configure(ITensor *input1, ITensor *input2, ITensor *output); |
| 49 | /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for max |
| 50 | * |
morgolock | a359805 | 2019-12-31 12:20:47 +0000 | [diff] [blame] | 51 | * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 52 | * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 53 | * @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 54 | * |
| 55 | * @return a status |
| 56 | */ |
| 57 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output); |
| 58 | }; |
| 59 | |
| 60 | /** Basic function to run @ref NEArithmeticOperationKernel for min |
| 61 | * |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 62 | * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 63 | * @note The function performs a max operation between two tensors. |
| 64 | */ |
| 65 | class NEElementwiseMin : public INESimpleFunction |
| 66 | { |
| 67 | public: |
| 68 | /** Initialise the kernel's inputs, output and conversion policy. |
| 69 | * |
morgolock | 781d727 | 2020-01-10 10:11:14 +0000 | [diff] [blame^] | 70 | * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 71 | * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 72 | * @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 73 | */ |
| 74 | void configure(ITensor *input1, ITensor *input2, ITensor *output); |
| 75 | /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for min |
| 76 | * |
morgolock | 781d727 | 2020-01-10 10:11:14 +0000 | [diff] [blame^] | 77 | * @param[in] input1 First tensor input info. Data types supported: QASYMM8/QASYMM8_SIGNED/S16/F16/S32/F32. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 78 | * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 79 | * @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 80 | * |
| 81 | * @return a status |
| 82 | */ |
| 83 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output); |
| 84 | }; |
| 85 | |
| 86 | /** Basic function to run @ref NEArithmeticOperationKernel for squared difference |
| 87 | * |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 88 | * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32. |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 89 | * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2 |
| 90 | */ |
| 91 | class NEElementwiseSquaredDiff : public INESimpleFunction |
| 92 | { |
| 93 | public: |
| 94 | /** Initialise the kernel's inputs, output and conversion policy. |
| 95 | * |
| 96 | * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/S16/F16/S32/F32. |
| 97 | * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 98 | * @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 99 | */ |
| 100 | void configure(ITensor *input1, ITensor *input2, ITensor *output); |
| 101 | /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for squared difference |
| 102 | * |
| 103 | * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32. |
| 104 | * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 105 | * @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 106 | * |
| 107 | * @return a status |
| 108 | */ |
| 109 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output); |
| 110 | }; |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 111 | |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 112 | /** Basic function to run @ref NEArithmeticOperationKernel for division |
| 113 | * |
| 114 | * @note The tensor data type for the inputs must be F16/F32. |
| 115 | * @note The function performs a squared different operation between two tensors (i.e., out[i] = in1[i] / in2[i]) |
| 116 | */ |
| 117 | class NEElementwiseDivision : public INESimpleFunction |
| 118 | { |
| 119 | public: |
| 120 | /** Initialise the kernel's inputs, output and conversion policy. |
| 121 | * |
| 122 | * @param[in, out] input1 First tensor input. Data types supported: F16/F32. |
| 123 | * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 124 | * @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 125 | */ |
| 126 | void configure(ITensor *input1, ITensor *input2, ITensor *output); |
| 127 | /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for division |
| 128 | * |
| 129 | * @param[in] input1 First tensor input info. Data types supported: F16/F32. |
| 130 | * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 131 | * @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 132 | * |
| 133 | * @return a status |
| 134 | */ |
| 135 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output); |
| 136 | }; |
| 137 | |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 138 | /** Basic function to run @ref NEArithmeticOperationKernel for power |
| 139 | * |
| 140 | * @note The tensor data type for the inputs must be F16/F32. |
| 141 | * @note The function performs a elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i]) |
| 142 | * @note For an exponent that is a float, this function will only work with a positive base. |
| 143 | */ |
| 144 | class NEElementwisePower : public INESimpleFunction |
| 145 | { |
| 146 | public: |
| 147 | /** Initialise the kernel's inputs, output and conversion policy. |
| 148 | * |
| 149 | * @param[in, out] input1 First tensor input. Data types supported: F16/F32. |
| 150 | * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 151 | * @param[out] output Output tensor. Data types supported: Same as @p input1. |
| 152 | */ |
| 153 | void configure(ITensor *input1, ITensor *input2, ITensor *output); |
| 154 | /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticOperationKernel for power |
| 155 | * |
| 156 | * @param[in] input1 First tensor input info. Data types supported: F16/F32. |
| 157 | * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 158 | * @param[in] output Output tensor info. Data types supported: Same as @p input1. |
| 159 | * |
| 160 | * @return a status |
| 161 | */ |
| 162 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output); |
| 163 | }; |
| 164 | |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 165 | /** Basic function to run @ref NEComparisonOperationKernel. |
George Wort | d88590f | 2018-12-12 17:39:58 +0000 | [diff] [blame] | 166 | * |
| 167 | * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32. |
| 168 | * @note The function performs a comparison operation between two tensors. |
| 169 | */ |
| 170 | class NEElementwiseComparison : public INESimpleFunction |
| 171 | { |
| 172 | public: |
| 173 | /** Initialise the kernel's inputs, output and conversion policy. |
| 174 | * |
| 175 | * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/S16/F16/S32/F32. |
| 176 | * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 177 | * @param[out] output Output tensor. Data types supported: U16/U32. |
| 178 | * @param[in] op Comparison Operation to be performed. |
| 179 | */ |
| 180 | void configure(ITensor *input1, ITensor *input2, ITensor *output, ComparisonOperation op); |
| 181 | /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel |
| 182 | * |
| 183 | * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32. |
| 184 | * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 185 | * @param[in] output Output tensor info. Data types supported: U16/U32. |
| 186 | * @param[in] op Comparison Operation to be performed. |
| 187 | * |
| 188 | * @return a status |
| 189 | */ |
| 190 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation op); |
| 191 | }; |
| 192 | |
| 193 | /** Basic function to run @ref NEComparisonOperationKernel |
| 194 | * |
| 195 | * @note The tensor data type for the inputs must be QASYMM8/S16/F16/S32/F32. |
| 196 | * @note The function performs a comparison operation between two tensors. |
| 197 | */ |
| 198 | template <ComparisonOperation op> |
| 199 | class NEElementwiseComparisonStatic : public INESimpleFunction |
| 200 | { |
| 201 | public: |
| 202 | /** Initialise the kernel's inputs, output and conversion policy. |
| 203 | * |
| 204 | * @param[in, out] input1 First tensor input. Data types supported: QASYMM8/S16/F16/S32/F32. |
| 205 | * @param[in, out] input2 Second tensor input. Data types supported: Same as @p input1. |
| 206 | * @param[out] output Output tensor. Data types supported: U16/U32. |
| 207 | */ |
| 208 | void configure(ITensor *input1, ITensor *input2, ITensor *output); |
| 209 | /** Static function to check if given info will lead to a valid configuration of @ref NEComparisonOperationKernel |
| 210 | * |
| 211 | * @param[in] input1 First tensor input info. Data types supported: QASYMM8/S16/F16/S32/F32. |
| 212 | * @param[in] input2 Second tensor input info. Data types supported: Same as @p input1. |
| 213 | * @param[in] output Output tensor info. Data types supported: U16/U32. |
| 214 | * |
| 215 | * @return a status |
| 216 | */ |
| 217 | static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output); |
| 218 | }; |
| 219 | |
| 220 | /** Basic function to run equal comparison. */ |
| 221 | using NEEqual = NEElementwiseComparisonStatic<ComparisonOperation::Equal>; |
| 222 | /** Basic function to run not equal comparison. */ |
| 223 | using NENotEqual = NEElementwiseComparisonStatic<ComparisonOperation::NotEqual>; |
| 224 | /** Basic function to run greater comparison. */ |
| 225 | using NEGreater = NEElementwiseComparisonStatic<ComparisonOperation::Greater>; |
| 226 | /** Basic function to run greater-equal comparison. */ |
| 227 | using NEGreaterEqual = NEElementwiseComparisonStatic<ComparisonOperation::GreaterEqual>; |
| 228 | /** Basic function to run less comparison. */ |
| 229 | using NELess = NEElementwiseComparisonStatic<ComparisonOperation::Less>; |
| 230 | /** Basic function to run less-equal comparison. */ |
| 231 | using NELessEqual = NEElementwiseComparisonStatic<ComparisonOperation::LessEqual>; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 232 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 233 | #endif /* ARM_COMPUTE_NEELEMENTWISEOPERATIONS_H */ |