Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 1 | /* |
Ramy Elgammal | 14d7b53 | 2023-01-30 04:56:47 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, 2023 Arm Limited. |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +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 |
| 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_TEST_ELEMENTWISE_UNARY_FIXTURE |
| 25 | #define ARM_COMPUTE_TEST_ELEMENTWISE_UNARY_FIXTURE |
| 26 | |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 27 | #include "arm_compute/core/QuantizationInfo.h" |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 28 | #include "arm_compute/core/TensorShape.h" |
| 29 | #include "arm_compute/core/Types.h" |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 30 | #include "arm_compute/core/Utils.h" |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 31 | #include "tests/AssetsLibrary.h" |
| 32 | #include "tests/Globals.h" |
| 33 | #include "tests/IAccessor.h" |
| 34 | #include "tests/framework/Asserts.h" |
| 35 | #include "tests/framework/Fixture.h" |
Jakub Sujak | ee301b3 | 2021-06-04 09:46:08 +0100 | [diff] [blame] | 36 | #include "tests/validation/reference/ElementwiseUnary.h" |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 37 | |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 38 | #include <tuple> |
| 39 | #include <limits> |
| 40 | #include <type_traits> |
| 41 | #include <vector> |
| 42 | |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 43 | namespace arm_compute |
| 44 | { |
| 45 | namespace test |
| 46 | { |
| 47 | namespace validation |
| 48 | { |
| 49 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 50 | class ElementWiseUnaryValidationFixture : public framework::Fixture |
| 51 | { |
| 52 | public: |
| 53 | template <typename...> |
Ramy Elgammal | 14d7b53 | 2023-01-30 04:56:47 +0000 | [diff] [blame] | 54 | void setup(TensorShape input_shape, DataType input_data_type, bool in_place, ElementWiseUnary op, |
| 55 | bool use_dynamic_shape = false, QuantizationInfo qinfo = QuantizationInfo(), QuantizationInfo qinfo_out = QuantizationInfo()) |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 56 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 57 | _op = op; |
Ramy Elgammal | 14d7b53 | 2023-01-30 04:56:47 +0000 | [diff] [blame] | 58 | _target = compute_target(input_shape, input_data_type, in_place, qinfo, qinfo_out); |
| 59 | _reference = compute_reference(input_shape, input_data_type, qinfo, qinfo_out); |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 60 | _use_dynamic_shape = use_dynamic_shape; |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | protected: |
| 64 | template <typename U> |
Usama Arif | f6e475c | 2019-05-10 12:06:28 +0100 | [diff] [blame] | 65 | void fill(U &&tensor, int i, DataType data_type) |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 66 | { |
Giorgio Arena | 4bdd177 | 2020-12-17 16:47:07 +0000 | [diff] [blame] | 67 | using FloatType = typename std::conditional < std::is_same<T, half>::value || std::is_floating_point<T>::value, T, float >::type; |
Giorgio Arena | 33b103b | 2021-01-08 10:37:15 +0000 | [diff] [blame] | 68 | using FloatDistributionType = typename std::conditional<std::is_same<T, half>::value, arm_compute::utils::uniform_real_distribution_16bit<T>, std::uniform_real_distribution<FloatType>>::type; |
Giorgio Arena | 4bdd177 | 2020-12-17 16:47:07 +0000 | [diff] [blame] | 69 | |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 70 | switch(_op) |
| 71 | { |
| 72 | case ElementWiseUnary::EXP: |
| 73 | { |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 74 | switch(data_type) |
| 75 | { |
| 76 | case DataType::F32: |
| 77 | { |
| 78 | FloatDistributionType distribution{ FloatType(-86.63f), FloatType(88.36f) }; |
| 79 | library->fill(tensor, distribution, i); |
| 80 | break; |
| 81 | } |
| 82 | |
| 83 | case DataType::F16: |
| 84 | { |
| 85 | FloatDistributionType distribution{ FloatType(-9.00f), FloatType(10.73f) }; |
| 86 | library->fill(tensor, distribution, i); |
| 87 | break; |
| 88 | } |
| 89 | |
| 90 | case DataType::QASYMM8: |
| 91 | case DataType::QASYMM8_SIGNED: |
| 92 | library->fill_tensor_uniform(tensor, i); |
| 93 | break; |
| 94 | |
| 95 | default: |
| 96 | ARM_COMPUTE_ERROR("Not implemented"); |
| 97 | } |
| 98 | |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 99 | break; |
| 100 | } |
| 101 | case ElementWiseUnary::RSQRT: |
Usama Arif | c255aa7 | 2019-05-13 16:26:29 +0100 | [diff] [blame] | 102 | case ElementWiseUnary::LOG: |
| 103 | { |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 104 | // For floating-point data type, the chosen input range is all positive numbers |
| 105 | // (i.e. positive and negative zeros are excluded). |
| 106 | switch(data_type) |
| 107 | { |
| 108 | case DataType::F32: |
| 109 | { |
| 110 | FloatDistributionType distribution{ std::numeric_limits<float>::min(), std::numeric_limits<float>::max() }; |
| 111 | library->fill(tensor, distribution, i); |
| 112 | break; |
| 113 | } |
| 114 | |
| 115 | case DataType::F16: |
| 116 | { |
| 117 | FloatDistributionType distribution{ FloatType(0.00006103515625f), FloatType(65504.0f) }; |
| 118 | library->fill(tensor, distribution, i); |
| 119 | break; |
| 120 | } |
| 121 | |
| 122 | case DataType::QASYMM8: |
| 123 | case DataType::QASYMM8_SIGNED: |
| 124 | library->fill_tensor_uniform(tensor, i); |
| 125 | break; |
| 126 | |
| 127 | default: |
| 128 | ARM_COMPUTE_ERROR("Not implemented"); |
| 129 | } |
| 130 | |
Usama Arif | c255aa7 | 2019-05-13 16:26:29 +0100 | [diff] [blame] | 131 | break; |
| 132 | } |
Michalis Spyrou | 0af4418 | 2019-05-17 14:04:47 +0100 | [diff] [blame] | 133 | case ElementWiseUnary::SIN: |
| 134 | { |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 135 | switch(data_type) |
| 136 | { |
| 137 | case DataType::F32: |
| 138 | case DataType::F16: |
| 139 | { |
| 140 | FloatDistributionType distribution{ FloatType(-100.0f), FloatType(100.0f) }; |
| 141 | library->fill(tensor, distribution, i); |
| 142 | break; |
| 143 | } |
| 144 | |
| 145 | case DataType::S32: |
| 146 | { |
| 147 | std::uniform_int_distribution<int32_t> distribution(std::numeric_limits<int32_t>::lowest(), std::numeric_limits<int32_t>::max()); |
| 148 | library->fill(tensor, distribution, i); |
| 149 | break; |
| 150 | } |
| 151 | |
| 152 | case DataType::QASYMM8: |
| 153 | case DataType::QASYMM8_SIGNED: |
| 154 | library->fill_tensor_uniform(tensor, i); |
| 155 | break; |
| 156 | |
| 157 | default: |
| 158 | ARM_COMPUTE_ERROR("Not implemented"); |
| 159 | } |
| 160 | |
Michalis Spyrou | 0af4418 | 2019-05-17 14:04:47 +0100 | [diff] [blame] | 161 | break; |
| 162 | } |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 163 | case ElementWiseUnary::ABS: |
| 164 | case ElementWiseUnary::NEG: |
Usama Arif | 0a5a57a | 2019-05-23 14:20:33 +0100 | [diff] [blame] | 165 | case ElementWiseUnary::ROUND: |
| 166 | { |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 167 | switch(data_type) |
| 168 | { |
| 169 | case DataType::F32: |
| 170 | { |
| 171 | FloatDistributionType distribution{ std::numeric_limits<float>::lowest() / 2, std::numeric_limits<float>::max() / 2 }; |
| 172 | library->fill(tensor, distribution, i); |
| 173 | break; |
| 174 | } |
| 175 | |
| 176 | case DataType::F16: |
| 177 | { |
| 178 | FloatDistributionType distribution{ FloatType(-65504.0f), FloatType(65504.0f) }; |
| 179 | library->fill(tensor, distribution, i); |
| 180 | break; |
| 181 | } |
| 182 | |
| 183 | case DataType::S32: |
| 184 | { |
| 185 | std::uniform_int_distribution<int32_t> distribution(std::numeric_limits<int32_t>::lowest(), std::numeric_limits<int32_t>::max()); |
| 186 | library->fill(tensor, distribution, i); |
| 187 | break; |
| 188 | } |
| 189 | |
| 190 | case DataType::QASYMM8: |
| 191 | case DataType::QASYMM8_SIGNED: |
| 192 | library->fill_tensor_uniform(tensor, i); |
| 193 | break; |
| 194 | |
| 195 | default: |
| 196 | ARM_COMPUTE_ERROR("Not implemented"); |
| 197 | } |
| 198 | |
Usama Arif | 0a5a57a | 2019-05-23 14:20:33 +0100 | [diff] [blame] | 199 | break; |
| 200 | } |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 201 | default: |
| 202 | ARM_COMPUTE_ERROR("Not implemented"); |
| 203 | } |
| 204 | } |
| 205 | |
Ramy Elgammal | 14d7b53 | 2023-01-30 04:56:47 +0000 | [diff] [blame] | 206 | TensorType compute_target(const TensorShape &shape, DataType data_type, bool in_place, QuantizationInfo qinfo, QuantizationInfo qinfo_out) |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 207 | { |
| 208 | // Create tensors |
Ramy Elgammal | 14d7b53 | 2023-01-30 04:56:47 +0000 | [diff] [blame] | 209 | TensorType src = create_tensor<TensorType>(shape, data_type, 1, qinfo); |
| 210 | TensorType dst = create_tensor<TensorType>(shape, data_type, 1, qinfo_out); |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 211 | TensorType *actual_dst = in_place ? &src : &dst; |
| 212 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 213 | // if _use_dynamic_shape is true, this fixture will test scenario for dynamic shapes. |
| 214 | // - At configure time, all input tensors are marked as dynamic using set_tensor_dynamic() |
| 215 | // - After configure, tensors are marked as static for run using set_tensor_static() |
| 216 | // - The tensors with static shape are given to run() |
| 217 | if(_use_dynamic_shape) |
| 218 | { |
| 219 | set_tensor_dynamic(src); |
| 220 | } |
| 221 | |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 222 | // Create and configure function |
| 223 | FunctionType elwiseunary_layer; |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 224 | elwiseunary_layer.configure(&src, actual_dst); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 225 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 226 | if(_use_dynamic_shape) |
| 227 | { |
| 228 | set_tensor_static(src); |
| 229 | } |
| 230 | |
Michele Di Giorgio | 4fc10b3 | 2021-04-30 18:30:41 +0100 | [diff] [blame] | 231 | ARM_COMPUTE_ASSERT(src.info()->is_resizable()); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 232 | src.allocator()->allocate(); |
Michele Di Giorgio | 4fc10b3 | 2021-04-30 18:30:41 +0100 | [diff] [blame] | 233 | ARM_COMPUTE_ASSERT(!src.info()->is_resizable()); |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 234 | if(!in_place) |
| 235 | { |
Michele Di Giorgio | 4fc10b3 | 2021-04-30 18:30:41 +0100 | [diff] [blame] | 236 | ARM_COMPUTE_ASSERT(dst.info()->is_resizable()); |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 237 | dst.allocator()->allocate(); |
Michele Di Giorgio | 4fc10b3 | 2021-04-30 18:30:41 +0100 | [diff] [blame] | 238 | ARM_COMPUTE_ASSERT(!dst.info()->is_resizable()); |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 239 | } |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 240 | |
| 241 | // Fill tensors |
Usama Arif | f6e475c | 2019-05-10 12:06:28 +0100 | [diff] [blame] | 242 | fill(AccessorType(src), 0, data_type); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 243 | |
| 244 | // Compute function |
| 245 | elwiseunary_layer.run(); |
| 246 | |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 247 | if(in_place) |
| 248 | { |
| 249 | return src; |
| 250 | } |
| 251 | else |
| 252 | { |
| 253 | return dst; |
| 254 | } |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Ramy Elgammal | 14d7b53 | 2023-01-30 04:56:47 +0000 | [diff] [blame] | 257 | SimpleTensor<T> compute_reference(const TensorShape &shape, DataType data_type, QuantizationInfo qinfo, QuantizationInfo qinfo_out) |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 258 | { |
| 259 | // Create reference |
Ramy Elgammal | 14d7b53 | 2023-01-30 04:56:47 +0000 | [diff] [blame] | 260 | SimpleTensor<T> src{ shape, data_type, 1, qinfo }; |
| 261 | SimpleTensor<T> dst{ shape, data_type, 1, qinfo_out }; |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 262 | |
| 263 | // Fill reference |
Usama Arif | f6e475c | 2019-05-10 12:06:28 +0100 | [diff] [blame] | 264 | fill(src, 0, data_type); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 265 | |
Ramy Elgammal | 14d7b53 | 2023-01-30 04:56:47 +0000 | [diff] [blame] | 266 | return reference::elementwise_unary<T>(src, dst, _op); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | TensorType _target{}; |
| 270 | SimpleTensor<T> _reference{}; |
| 271 | ElementWiseUnary _op{}; |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 272 | bool _use_dynamic_shape{ false }; |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 273 | QuantizationInfo _input_qinfo{}; |
| 274 | QuantizationInfo _output_qinfo{}; |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 275 | }; |
Ramy Elgammal | 14d7b53 | 2023-01-30 04:56:47 +0000 | [diff] [blame] | 276 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 277 | class RsqrtQuantizedValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 278 | { |
| 279 | public: |
| 280 | template <typename...> |
| 281 | void setup(const TensorShape &shape, DataType data_type, QuantizationInfo qinfo, QuantizationInfo qinfo_out) |
| 282 | { |
| 283 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::RSQRT, false, qinfo, qinfo_out); |
| 284 | } |
| 285 | }; |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 286 | |
| 287 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 288 | class RsqrtValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 289 | { |
| 290 | public: |
| 291 | template <typename...> |
| 292 | void setup(const TensorShape &shape, DataType data_type) |
| 293 | { |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 294 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::RSQRT); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 295 | } |
| 296 | }; |
| 297 | |
| 298 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 299 | class RsqrtDynamicShapeValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 300 | { |
| 301 | public: |
| 302 | template <typename...> |
| 303 | void setup(const TensorShape &shape, DataType data_type) |
| 304 | { |
| 305 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::RSQRT, true); |
| 306 | } |
| 307 | }; |
| 308 | |
| 309 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 310 | class ExpValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 311 | { |
| 312 | public: |
| 313 | template <typename...> |
| 314 | void setup(const TensorShape &shape, DataType data_type) |
| 315 | { |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 316 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::EXP); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 317 | } |
| 318 | }; |
Usama Arif | f6e475c | 2019-05-10 12:06:28 +0100 | [diff] [blame] | 319 | |
| 320 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 321 | class ExpQuantizedValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 322 | { |
| 323 | public: |
| 324 | template <typename...> |
| 325 | void setup(const TensorShape &shape, DataType data_type, QuantizationInfo iq, QuantizationInfo oq) |
| 326 | { |
| 327 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::EXP, false, iq, oq); |
| 328 | } |
| 329 | }; |
| 330 | |
| 331 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Usama Arif | f6e475c | 2019-05-10 12:06:28 +0100 | [diff] [blame] | 332 | class NegValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 333 | { |
| 334 | public: |
| 335 | template <typename...> |
| 336 | void setup(const TensorShape &shape, DataType data_type) |
| 337 | { |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 338 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::NEG); |
| 339 | } |
| 340 | }; |
| 341 | |
| 342 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 343 | class NegQuantizedValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 344 | { |
| 345 | public: |
| 346 | template <typename...> |
| 347 | void setup(const TensorShape &shape, DataType data_type, QuantizationInfo iq, QuantizationInfo oq) |
| 348 | { |
| 349 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::NEG, false, iq, oq); |
| 350 | } |
| 351 | }; |
| 352 | |
| 353 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 354 | class NegValidationInPlaceFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 355 | { |
| 356 | public: |
| 357 | template <typename...> |
| 358 | void setup(const TensorShape &shape, DataType data_type, bool in_place) |
| 359 | { |
| 360 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, in_place, ElementWiseUnary::NEG); |
Usama Arif | f6e475c | 2019-05-10 12:06:28 +0100 | [diff] [blame] | 361 | } |
| 362 | }; |
Usama Arif | c255aa7 | 2019-05-13 16:26:29 +0100 | [diff] [blame] | 363 | |
| 364 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 365 | class NegQuantizedValidationInPlaceFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 366 | { |
| 367 | public: |
| 368 | template <typename...> |
| 369 | void setup(const TensorShape &shape, DataType data_type, bool in_place, QuantizationInfo iq, QuantizationInfo oq) |
| 370 | { |
| 371 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, in_place, ElementWiseUnary::NEG, false, iq, oq); |
| 372 | } |
| 373 | }; |
| 374 | |
| 375 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Usama Arif | c255aa7 | 2019-05-13 16:26:29 +0100 | [diff] [blame] | 376 | class LogValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 377 | { |
| 378 | public: |
| 379 | template <typename...> |
| 380 | void setup(const TensorShape &shape, DataType data_type) |
| 381 | { |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 382 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::LOG); |
Usama Arif | c255aa7 | 2019-05-13 16:26:29 +0100 | [diff] [blame] | 383 | } |
| 384 | }; |
Manuel Bottini | 6ac5992 | 2019-05-15 14:06:02 +0100 | [diff] [blame] | 385 | |
| 386 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 387 | class LogQuantizedValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 388 | { |
| 389 | public: |
| 390 | template <typename...> |
| 391 | void setup(const TensorShape &shape, DataType data_type, QuantizationInfo iq, QuantizationInfo oq) |
| 392 | { |
| 393 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::LOG, false, iq, oq); |
| 394 | } |
| 395 | }; |
| 396 | |
| 397 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Manuel Bottini | 6ac5992 | 2019-05-15 14:06:02 +0100 | [diff] [blame] | 398 | class AbsValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 399 | { |
| 400 | public: |
| 401 | template <typename...> |
| 402 | void setup(const TensorShape &shape, DataType data_type) |
| 403 | { |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 404 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::ABS); |
Manuel Bottini | 6ac5992 | 2019-05-15 14:06:02 +0100 | [diff] [blame] | 405 | } |
| 406 | }; |
Michalis Spyrou | 0af4418 | 2019-05-17 14:04:47 +0100 | [diff] [blame] | 407 | |
| 408 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 409 | class AbsQuantizedValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 410 | { |
| 411 | public: |
| 412 | template <typename...> |
| 413 | void setup(const TensorShape &shape, DataType data_type, QuantizationInfo iq, QuantizationInfo oq) |
| 414 | { |
| 415 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::ABS, false, iq, oq); |
| 416 | } |
| 417 | }; |
| 418 | |
| 419 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Michalis Spyrou | 0af4418 | 2019-05-17 14:04:47 +0100 | [diff] [blame] | 420 | class SinValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 421 | { |
| 422 | public: |
| 423 | template <typename...> |
| 424 | void setup(const TensorShape &shape, DataType data_type) |
| 425 | { |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 426 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::SIN); |
Michalis Spyrou | 0af4418 | 2019-05-17 14:04:47 +0100 | [diff] [blame] | 427 | } |
| 428 | }; |
Usama Arif | 0a5a57a | 2019-05-23 14:20:33 +0100 | [diff] [blame] | 429 | |
| 430 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 431 | class SinQuantizedValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 432 | { |
| 433 | public: |
| 434 | template <typename...> |
| 435 | void setup(const TensorShape &shape, DataType data_type, QuantizationInfo iq, QuantizationInfo oq) |
| 436 | { |
| 437 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::SIN, false, iq, oq); |
| 438 | } |
| 439 | }; |
| 440 | |
| 441 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Usama Arif | 0a5a57a | 2019-05-23 14:20:33 +0100 | [diff] [blame] | 442 | class RoundValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 443 | { |
| 444 | public: |
| 445 | template <typename...> |
| 446 | void setup(const TensorShape &shape, DataType data_type) |
| 447 | { |
Manuel Bottini | 80feed5 | 2020-06-03 13:20:41 +0100 | [diff] [blame] | 448 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::ROUND); |
Usama Arif | 0a5a57a | 2019-05-23 14:20:33 +0100 | [diff] [blame] | 449 | } |
| 450 | }; |
Viet-Hoa Do | fd472f0 | 2023-03-15 14:05:06 +0000 | [diff] [blame] | 451 | |
| 452 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 453 | class RoundQuantizedValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T> |
| 454 | { |
| 455 | public: |
| 456 | template <typename...> |
| 457 | void setup(const TensorShape &shape, DataType data_type, QuantizationInfo iq, QuantizationInfo oq) |
| 458 | { |
| 459 | ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::ROUND, false, iq, oq); |
| 460 | } |
| 461 | }; |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 462 | } // namespace validation |
| 463 | } // namespace test |
| 464 | } // namespace arm_compute |
| 465 | #endif /* ARM_COMPUTE_TEST_ELEMENTWISE_UNARY_FIXTURE */ |