giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 1 | /* |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +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_OPERATIONS_FIXTURE |
| 25 | #define ARM_COMPUTE_TEST_ELEMENTWISE_OPERATIONS_FIXTURE |
| 26 | |
| 27 | #include "arm_compute/core/TensorShape.h" |
| 28 | #include "arm_compute/core/Types.h" |
| 29 | #include "tests/AssetsLibrary.h" |
| 30 | #include "tests/Globals.h" |
| 31 | #include "tests/IAccessor.h" |
| 32 | #include "tests/framework/Asserts.h" |
| 33 | #include "tests/framework/Fixture.h" |
| 34 | #include "tests/validation/Helpers.h" |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 35 | #include "tests/validation/reference/ActivationLayer.h" |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 36 | #include "tests/validation/reference/ElementwiseOperations.h" |
| 37 | |
| 38 | namespace arm_compute |
| 39 | { |
| 40 | namespace test |
| 41 | { |
| 42 | namespace validation |
| 43 | { |
| 44 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 45 | class ArithmeticOperationsGenericFixture : public framework::Fixture |
| 46 | { |
| 47 | public: |
| 48 | template <typename...> |
| 49 | void setup(ArithmeticOperation op, const TensorShape &shape0, const TensorShape &shape1, |
| 50 | DataType data_type0, DataType data_type1, DataType output_data_type, |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 51 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, bool use_dyanmic_shape = false) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 52 | { |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 53 | _op = op; |
| 54 | _use_dynamic_shape = use_dyanmic_shape; |
| 55 | |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 56 | _target = compute_target(shape0, shape1, data_type0, data_type1, output_data_type, qinfo0, qinfo1, qinfo_out); |
| 57 | _reference = compute_reference(shape0, shape1, data_type0, data_type1, output_data_type, qinfo0, qinfo1, qinfo_out); |
| 58 | } |
| 59 | |
| 60 | protected: |
| 61 | template <typename U> |
| 62 | void fill(U &&tensor, int i) |
| 63 | { |
Georgios Pinitas | 1813422 | 2020-09-03 21:00:23 +0100 | [diff] [blame] | 64 | if(is_data_type_float(tensor.data_type())) |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 65 | { |
Georgios Pinitas | 1813422 | 2020-09-03 21:00:23 +0100 | [diff] [blame] | 66 | switch(_op) |
| 67 | { |
| 68 | case ArithmeticOperation::DIV: |
| 69 | library->fill_tensor_uniform_ranged(tensor, i, { std::pair<float, float>(-0.001f, 0.001f) }); |
| 70 | break; |
| 71 | case ArithmeticOperation::POWER: |
| 72 | library->fill_tensor_uniform(tensor, i, 0.0f, 5.0f); |
| 73 | break; |
| 74 | default: |
| 75 | library->fill_tensor_uniform(tensor, i); |
| 76 | } |
| 77 | } |
| 78 | else |
| 79 | { |
| 80 | library->fill_tensor_uniform(tensor, i); |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 81 | } |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | TensorType compute_target(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 85 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 86 | { |
| 87 | // Create tensors |
| 88 | TensorType ref_src1 = create_tensor<TensorType>(shape0, data_type0, 1, qinfo0); |
| 89 | TensorType ref_src2 = create_tensor<TensorType>(shape1, data_type1, 1, qinfo1); |
| 90 | TensorType dst = create_tensor<TensorType>(TensorShape::broadcast_shape(shape0, shape1), output_data_type, 1, qinfo_out); |
| 91 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 92 | // if _use_dynamic_shape is true, this fixture will test scenario for dynamic shapes. |
| 93 | // - At configure time, all input tensors are marked as dynamic using set_tensor_dynamic() |
| 94 | // - After configure, tensors are marked as static for run using set_tensor_static() |
| 95 | // - The tensors with static shape are given to run() |
| 96 | if(_use_dynamic_shape) |
| 97 | { |
| 98 | set_tensor_dynamic(ref_src1); |
| 99 | set_tensor_dynamic(ref_src2); |
| 100 | } |
| 101 | |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 102 | // Create and configure function |
| 103 | FunctionType elem_op; |
| 104 | elem_op.configure(&ref_src1, &ref_src2, &dst); |
| 105 | |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 106 | if(_use_dynamic_shape) |
| 107 | { |
| 108 | set_tensor_static(ref_src1); |
| 109 | set_tensor_static(ref_src2); |
| 110 | } |
| 111 | |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 112 | ARM_COMPUTE_EXPECT(ref_src1.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 113 | ARM_COMPUTE_EXPECT(ref_src2.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 114 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 115 | |
| 116 | // Allocate tensors |
| 117 | ref_src1.allocator()->allocate(); |
| 118 | ref_src2.allocator()->allocate(); |
| 119 | dst.allocator()->allocate(); |
| 120 | |
| 121 | ARM_COMPUTE_EXPECT(!ref_src1.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 122 | ARM_COMPUTE_EXPECT(!ref_src2.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 123 | ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 124 | |
| 125 | // Fill tensors |
| 126 | fill(AccessorType(ref_src1), 0); |
| 127 | fill(AccessorType(ref_src2), 1); |
| 128 | |
| 129 | // Compute function |
| 130 | elem_op.run(); |
| 131 | |
| 132 | return dst; |
| 133 | } |
| 134 | |
| 135 | SimpleTensor<T> compute_reference(const TensorShape &shape0, const TensorShape &shape1, |
| 136 | DataType data_type0, DataType data_type1, DataType output_data_type, |
| 137 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 138 | { |
| 139 | // Create reference |
| 140 | SimpleTensor<T> ref_src1{ shape0, data_type0, 1, qinfo0 }; |
| 141 | SimpleTensor<T> ref_src2{ shape1, data_type1, 1, qinfo1 }; |
| 142 | SimpleTensor<T> ref_dst{ TensorShape::broadcast_shape(shape0, shape1), output_data_type, 1, qinfo_out }; |
| 143 | |
| 144 | // Fill reference |
| 145 | fill(ref_src1, 0); |
| 146 | fill(ref_src2, 1); |
| 147 | |
| 148 | return reference::arithmetic_operation<T>(_op, ref_src1, ref_src2, ref_dst); |
| 149 | } |
| 150 | |
| 151 | TensorType _target{}; |
| 152 | SimpleTensor<T> _reference{}; |
| 153 | ArithmeticOperation _op{ ArithmeticOperation::ADD }; |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 154 | bool _use_dynamic_shape{ false }; |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 155 | }; |
| 156 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 157 | // Arithmetic operation fused with activation function |
| 158 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 159 | class ArithmeticOperationsFuseActivationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 160 | { |
| 161 | public: |
| 162 | template <typename...> |
| 163 | void setup(ArithmeticOperation op, const TensorShape &shape0, const TensorShape &shape1, |
| 164 | DataType data_type0, DataType data_type1, DataType output_data_type, |
| 165 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, ActivationLayerInfo act_info) |
| 166 | { |
| 167 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(op, shape0, shape1, |
| 168 | data_type0, data_type1, output_data_type, |
| 169 | qinfo0, qinfo1, qinfo_out); |
| 170 | _act_info = act_info; |
| 171 | } |
| 172 | |
| 173 | protected: |
| 174 | TensorType compute_target(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 175 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 176 | { |
| 177 | // Create tensors |
| 178 | TensorType ref_src1 = create_tensor<TensorType>(shape0, data_type0, 1, qinfo0); |
| 179 | TensorType ref_src2 = create_tensor<TensorType>(shape1, data_type1, 1, qinfo1); |
| 180 | TensorType dst = create_tensor<TensorType>(TensorShape::broadcast_shape(shape0, shape1), output_data_type, 1, qinfo_out); |
| 181 | |
| 182 | // Create and configure function |
| 183 | FunctionType elem_op; |
| 184 | elem_op.configure(&ref_src1, &ref_src2, &dst, _act_info); |
| 185 | |
| 186 | ARM_COMPUTE_EXPECT(ref_src1.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 187 | ARM_COMPUTE_EXPECT(ref_src2.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 188 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 189 | |
| 190 | // Allocate tensors |
| 191 | ref_src1.allocator()->allocate(); |
| 192 | ref_src2.allocator()->allocate(); |
| 193 | dst.allocator()->allocate(); |
| 194 | |
| 195 | ARM_COMPUTE_EXPECT(!ref_src1.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 196 | ARM_COMPUTE_EXPECT(!ref_src2.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 197 | ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 198 | |
| 199 | // Fill tensors |
| 200 | fill(AccessorType(ref_src1), 0); |
| 201 | fill(AccessorType(ref_src2), 1); |
| 202 | |
| 203 | // Compute function |
| 204 | elem_op.run(); |
| 205 | |
| 206 | return dst; |
| 207 | } |
| 208 | |
| 209 | SimpleTensor<T> compute_reference(const TensorShape &shape0, const TensorShape &shape1, |
| 210 | DataType data_type0, DataType data_type1, DataType output_data_type, |
| 211 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 212 | { |
| 213 | auto result = ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::compute_reference(shape0, shape1, data_type0, |
| 214 | data_type1, output_data_type, qinfo0, qinfo1, qinfo_out); |
| 215 | return _act_info.enabled() ? reference::activation_layer(result, _act_info, qinfo_out) : result; |
| 216 | } |
| 217 | |
| 218 | ActivationLayerInfo _act_info{}; |
| 219 | }; |
| 220 | |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 221 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 222 | class ArithmeticDivisionBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 223 | { |
| 224 | public: |
| 225 | template <typename...> |
| 226 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 227 | { |
| 228 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape0, shape1, |
| 229 | data_type0, data_type1, output_data_type, |
| 230 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 231 | } |
| 232 | }; |
| 233 | |
| 234 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 235 | class ArithmeticDivisionValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 236 | { |
| 237 | public: |
| 238 | template <typename...> |
| 239 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 240 | { |
| 241 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape, |
| 242 | data_type0, data_type1, output_data_type, |
| 243 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 244 | } |
| 245 | }; |
| 246 | |
| 247 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Sang-Hoon Park | 668ccdc | 2021-02-03 10:32:59 +0000 | [diff] [blame] | 248 | class ArithmeticDivisionBroadcastDynamicShapeValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 249 | { |
| 250 | public: |
| 251 | template <typename...> |
| 252 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 253 | { |
| 254 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape0, shape1, |
| 255 | data_type0, data_type1, output_data_type, |
| 256 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), true); |
| 257 | } |
| 258 | }; |
| 259 | |
| 260 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 261 | class ArithmeticDivisionDynamicShapeValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 262 | { |
| 263 | public: |
| 264 | template <typename...> |
| 265 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 266 | { |
| 267 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape, |
| 268 | data_type0, data_type1, output_data_type, |
| 269 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), true); |
| 270 | } |
| 271 | }; |
| 272 | |
| 273 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 274 | class ArithmeticDivisionBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 275 | { |
| 276 | public: |
| 277 | template <typename...> |
| 278 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 279 | { |
| 280 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape0, shape1, |
| 281 | data_type0, data_type1, output_data_type, |
| 282 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 283 | } |
| 284 | }; |
| 285 | |
| 286 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 287 | class ArithmeticDivisionValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 288 | { |
| 289 | public: |
| 290 | template <typename...> |
| 291 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 292 | { |
| 293 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape, |
| 294 | data_type0, data_type1, output_data_type, |
| 295 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 296 | } |
| 297 | }; |
| 298 | |
| 299 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Suhail Munshi | ae1c9fe | 2021-04-14 12:16:49 +0100 | [diff] [blame^] | 300 | class ArithmeticDivisionValidationIntegerFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 301 | { |
| 302 | public: |
| 303 | template <typename...> |
| 304 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 305 | { |
| 306 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape, |
| 307 | data_type0, data_type1, output_data_type, |
| 308 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 309 | } |
| 310 | }; |
| 311 | |
| 312 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 313 | class ArithmeticDivisionValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 314 | { |
| 315 | public: |
| 316 | template <typename...> |
| 317 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 318 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 319 | |
| 320 | { |
| 321 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape, |
| 322 | data_type0, data_type1, output_data_type, |
| 323 | qinfo0, qinfo1, qinfo_out); |
| 324 | } |
| 325 | }; |
| 326 | |
| 327 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 328 | class ElementwiseMaxBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 329 | { |
| 330 | public: |
| 331 | template <typename...> |
| 332 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 333 | { |
| 334 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape0, shape1, |
| 335 | data_type0, data_type1, output_data_type, |
| 336 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 337 | } |
| 338 | }; |
| 339 | |
| 340 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 341 | class ElementwiseMaxValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 342 | { |
| 343 | public: |
| 344 | template <typename...> |
| 345 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 346 | { |
| 347 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape, shape, |
| 348 | data_type0, data_type1, output_data_type, |
| 349 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 350 | } |
| 351 | }; |
| 352 | |
| 353 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 354 | class ElementwiseMaxBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 355 | { |
| 356 | public: |
| 357 | template <typename...> |
| 358 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 359 | { |
| 360 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape0, shape1, |
| 361 | data_type0, data_type1, output_data_type, |
| 362 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 363 | } |
| 364 | }; |
| 365 | |
| 366 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 367 | class ElementwiseMaxValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 368 | { |
| 369 | public: |
| 370 | template <typename...> |
| 371 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 372 | { |
| 373 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape, shape, |
| 374 | data_type0, data_type1, output_data_type, |
| 375 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 376 | } |
| 377 | }; |
| 378 | |
| 379 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 380 | class ElementwiseMaxValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 381 | { |
| 382 | public: |
| 383 | template <typename...> |
| 384 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 385 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 386 | |
| 387 | { |
| 388 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape, shape, |
| 389 | data_type0, data_type1, output_data_type, |
| 390 | qinfo0, qinfo1, qinfo_out); |
| 391 | } |
| 392 | }; |
| 393 | |
| 394 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 395 | class ElementwiseMaxQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 396 | { |
| 397 | public: |
| 398 | template <typename...> |
| 399 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 400 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 401 | |
| 402 | { |
| 403 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape0, shape1, |
| 404 | data_type0, data_type1, output_data_type, |
| 405 | qinfo0, qinfo1, qinfo_out); |
| 406 | } |
| 407 | }; |
| 408 | |
| 409 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 410 | class ElementwiseMinBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 411 | { |
| 412 | public: |
| 413 | template <typename...> |
| 414 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 415 | { |
| 416 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape0, shape1, |
| 417 | data_type0, data_type1, output_data_type, |
| 418 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 419 | } |
| 420 | }; |
| 421 | |
| 422 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 423 | class ElementwiseMinValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 424 | { |
| 425 | public: |
| 426 | template <typename...> |
| 427 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 428 | { |
| 429 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape, shape, |
| 430 | data_type0, data_type1, output_data_type, |
| 431 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 432 | } |
| 433 | }; |
| 434 | |
| 435 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 436 | class ElementwiseMinBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 437 | { |
| 438 | public: |
| 439 | template <typename...> |
| 440 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 441 | { |
| 442 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape0, shape1, |
| 443 | data_type0, data_type1, output_data_type, |
| 444 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 445 | } |
| 446 | }; |
| 447 | |
| 448 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 449 | class ElementwiseMinValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 450 | { |
| 451 | public: |
| 452 | template <typename...> |
| 453 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 454 | { |
| 455 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape, shape, |
| 456 | data_type0, data_type1, output_data_type, |
| 457 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 458 | } |
| 459 | }; |
| 460 | |
| 461 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 462 | class ElementwiseMinValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 463 | { |
| 464 | public: |
| 465 | template <typename...> |
| 466 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 467 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 468 | |
| 469 | { |
| 470 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape, shape, |
| 471 | data_type0, data_type1, output_data_type, |
| 472 | qinfo0, qinfo1, qinfo_out); |
| 473 | } |
| 474 | }; |
| 475 | |
| 476 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 477 | class ElementwiseMinQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 478 | { |
| 479 | public: |
| 480 | template <typename...> |
| 481 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 482 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 483 | |
| 484 | { |
| 485 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape0, shape1, |
| 486 | data_type0, data_type1, output_data_type, |
| 487 | qinfo0, qinfo1, qinfo_out); |
| 488 | } |
| 489 | }; |
| 490 | |
| 491 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 492 | class ElementwiseSquaredDiffBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 493 | { |
| 494 | public: |
| 495 | template <typename...> |
| 496 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 497 | { |
| 498 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape0, shape1, |
| 499 | data_type0, data_type1, output_data_type, |
| 500 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 501 | } |
| 502 | }; |
| 503 | |
| 504 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 505 | class ElementwiseSquaredDiffValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 506 | { |
| 507 | public: |
| 508 | template <typename...> |
| 509 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 510 | { |
| 511 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape, shape, |
| 512 | data_type0, data_type1, output_data_type, |
| 513 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 514 | } |
| 515 | }; |
| 516 | |
| 517 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 518 | class ElementwiseSquaredDiffBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 519 | { |
| 520 | public: |
| 521 | template <typename...> |
| 522 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 523 | { |
| 524 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape0, shape1, |
| 525 | data_type0, data_type1, output_data_type, |
| 526 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 527 | } |
| 528 | }; |
| 529 | |
| 530 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 531 | class ElementwiseSquaredDiffValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 532 | { |
| 533 | public: |
| 534 | template <typename...> |
| 535 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 536 | { |
| 537 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape, shape, |
| 538 | data_type0, data_type1, output_data_type, |
| 539 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 540 | } |
| 541 | }; |
| 542 | |
| 543 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 544 | class ElementwiseSquaredDiffValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 545 | { |
| 546 | public: |
| 547 | template <typename...> |
| 548 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 549 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 550 | |
| 551 | { |
| 552 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape, shape, |
| 553 | data_type0, data_type1, output_data_type, |
| 554 | qinfo0, qinfo1, qinfo_out); |
| 555 | } |
| 556 | }; |
giuros01 | 92fd943 | 2018-12-03 17:30:00 +0000 | [diff] [blame] | 557 | |
| 558 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 559 | class ElementwiseSquaredDiffQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 560 | { |
| 561 | public: |
| 562 | template <typename...> |
| 563 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 564 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 565 | |
| 566 | { |
| 567 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape0, shape1, |
| 568 | data_type0, data_type1, output_data_type, |
| 569 | qinfo0, qinfo1, qinfo_out); |
| 570 | } |
| 571 | }; |
George Wort | a1e7e28 | 2019-01-15 11:00:29 +0000 | [diff] [blame] | 572 | |
| 573 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
giuros01 | 1e6e1b8 | 2019-05-14 16:12:53 +0100 | [diff] [blame] | 574 | class PReluLayerBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 575 | { |
| 576 | public: |
| 577 | template <typename...> |
| 578 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 579 | { |
| 580 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape0, shape1, |
| 581 | data_type0, data_type1, output_data_type, |
| 582 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 583 | } |
| 584 | }; |
| 585 | |
| 586 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 587 | class PReluLayerValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 588 | { |
| 589 | public: |
| 590 | template <typename...> |
| 591 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 592 | { |
| 593 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape, shape, |
| 594 | data_type0, data_type1, output_data_type, |
| 595 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 596 | } |
| 597 | }; |
| 598 | |
| 599 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 600 | class PReluLayerValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 601 | { |
| 602 | public: |
| 603 | template <typename...> |
| 604 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 605 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 606 | |
| 607 | { |
| 608 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape, shape, |
| 609 | data_type0, data_type1, output_data_type, |
| 610 | qinfo0, qinfo1, qinfo_out); |
| 611 | } |
| 612 | }; |
| 613 | |
| 614 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 615 | class PReluLayerQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 616 | { |
| 617 | public: |
| 618 | template <typename...> |
| 619 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, |
| 620 | QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out) |
| 621 | |
| 622 | { |
| 623 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape0, shape1, |
| 624 | data_type0, data_type1, output_data_type, |
| 625 | qinfo0, qinfo1, qinfo_out); |
| 626 | } |
| 627 | }; |
| 628 | |
| 629 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Usama Arif | 81e671e | 2019-05-13 13:33:14 +0100 | [diff] [blame] | 630 | class ElementwisePowerBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 631 | { |
| 632 | public: |
| 633 | template <typename...> |
| 634 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 635 | { |
| 636 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape0, shape1, |
| 637 | data_type0, data_type1, output_data_type, |
| 638 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 639 | } |
| 640 | }; |
| 641 | |
| 642 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 643 | class ElementwisePowerValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T> |
| 644 | { |
| 645 | public: |
| 646 | template <typename...> |
| 647 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type) |
| 648 | { |
| 649 | ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape, shape, |
| 650 | data_type0, data_type1, output_data_type, |
| 651 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo()); |
| 652 | } |
| 653 | }; |
| 654 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 655 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 656 | class ElementwisePowerBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 657 | { |
| 658 | public: |
| 659 | template <typename...> |
| 660 | void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 661 | { |
| 662 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape0, shape1, |
| 663 | data_type0, data_type1, output_data_type, |
| 664 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 665 | } |
| 666 | }; |
| 667 | |
| 668 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 669 | class ElementwisePowerValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T> |
| 670 | { |
| 671 | public: |
| 672 | template <typename...> |
| 673 | void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info) |
| 674 | { |
| 675 | ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape, shape, |
| 676 | data_type0, data_type1, output_data_type, |
| 677 | QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info); |
| 678 | } |
| 679 | }; |
| 680 | |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 681 | } // namespace validation |
| 682 | } // namespace test |
| 683 | } // namespace arm_compute |
| 684 | #endif /* ARM_COMPUTE_TEST_ARITHMETIC_OPERATIONS_FIXTURE */ |