blob: bf51c7e69b7a4dfcf9abfc01d22013540a8da46e [file] [log] [blame]
giuros01164a2722018-11-20 18:34:46 +00001/*
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +00002 * Copyright (c) 2018-2021 Arm Limited.
giuros01164a2722018-11-20 18:34:46 +00003 *
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 Arena8b2a7d32020-02-11 17:21:31 +000035#include "tests/validation/reference/ActivationLayer.h"
giuros01164a2722018-11-20 18:34:46 +000036#include "tests/validation/reference/ElementwiseOperations.h"
37
38namespace arm_compute
39{
40namespace test
41{
42namespace validation
43{
44template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
45class ArithmeticOperationsGenericFixture : public framework::Fixture
46{
47public:
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 Park668ccdc2021-02-03 10:32:59 +000051 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, bool use_dyanmic_shape = false)
giuros01164a2722018-11-20 18:34:46 +000052 {
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +000053 _op = op;
54 _use_dynamic_shape = use_dyanmic_shape;
55
giuros01164a2722018-11-20 18:34:46 +000056 _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
60protected:
61 template <typename U>
62 void fill(U &&tensor, int i)
63 {
Georgios Pinitas18134222020-09-03 21:00:23 +010064 if(is_data_type_float(tensor.data_type()))
Usama Arif81e671e2019-05-13 13:33:14 +010065 {
Georgios Pinitas18134222020-09-03 21:00:23 +010066 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 Arif81e671e2019-05-13 13:33:14 +010081 }
giuros01164a2722018-11-20 18:34:46 +000082 }
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 Park668ccdc2021-02-03 10:32:59 +000092 // 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
giuros01164a2722018-11-20 18:34:46 +0000102 // Create and configure function
103 FunctionType elem_op;
104 elem_op.configure(&ref_src1, &ref_src2, &dst);
105
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +0000106 if(_use_dynamic_shape)
107 {
108 set_tensor_static(ref_src1);
109 set_tensor_static(ref_src2);
110 }
111
giuros01164a2722018-11-20 18:34:46 +0000112 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 Park668ccdc2021-02-03 10:32:59 +0000154 bool _use_dynamic_shape{ false };
giuros01164a2722018-11-20 18:34:46 +0000155};
156
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000157// Arithmetic operation fused with activation function
158template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
159class ArithmeticOperationsFuseActivationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
160{
161public:
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
173protected:
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
giuros01164a2722018-11-20 18:34:46 +0000221template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
222class ArithmeticDivisionBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
223{
224public:
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
234template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
235class ArithmeticDivisionValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
236{
237public:
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
247template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +0000248class ArithmeticDivisionBroadcastDynamicShapeValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
249{
250public:
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
260template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
261class ArithmeticDivisionDynamicShapeValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
262{
263public:
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
273template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000274class ArithmeticDivisionBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
275{
276public:
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
286template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
287class ArithmeticDivisionValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
288{
289public:
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
299template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000300class ArithmeticDivisionValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
301{
302public:
303 template <typename...>
304 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type,
305 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
306
307 {
308 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape,
309 data_type0, data_type1, output_data_type,
310 qinfo0, qinfo1, qinfo_out);
311 }
312};
313
314template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
315class ElementwiseMaxBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
316{
317public:
318 template <typename...>
319 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
320 {
321 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape0, shape1,
322 data_type0, data_type1, output_data_type,
323 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
324 }
325};
326
327template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
328class ElementwiseMaxValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
329{
330public:
331 template <typename...>
332 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
333 {
334 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape, shape,
335 data_type0, data_type1, output_data_type,
336 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
337 }
338};
339
340template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000341class ElementwiseMaxBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
342{
343public:
344 template <typename...>
345 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
346 {
347 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape0, shape1,
348 data_type0, data_type1, output_data_type,
349 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
350 }
351};
352
353template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
354class ElementwiseMaxValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
355{
356public:
357 template <typename...>
358 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
359 {
360 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape, shape,
361 data_type0, data_type1, output_data_type,
362 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
363 }
364};
365
366template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000367class ElementwiseMaxValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
368{
369public:
370 template <typename...>
371 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type,
372 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
373
374 {
375 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape, shape,
376 data_type0, data_type1, output_data_type,
377 qinfo0, qinfo1, qinfo_out);
378 }
379};
380
381template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros0192fd9432018-12-03 17:30:00 +0000382class ElementwiseMaxQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
383{
384public:
385 template <typename...>
386 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type,
387 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
388
389 {
390 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape0, shape1,
391 data_type0, data_type1, output_data_type,
392 qinfo0, qinfo1, qinfo_out);
393 }
394};
395
396template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000397class ElementwiseMinBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
398{
399public:
400 template <typename...>
401 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
402 {
403 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape0, shape1,
404 data_type0, data_type1, output_data_type,
405 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
406 }
407};
408
409template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
410class ElementwiseMinValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
411{
412public:
413 template <typename...>
414 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
415 {
416 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape, shape,
417 data_type0, data_type1, output_data_type,
418 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
419 }
420};
421
422template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000423class ElementwiseMinBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
424{
425public:
426 template <typename...>
427 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
428 {
429 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape0, shape1,
430 data_type0, data_type1, output_data_type,
431 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
432 }
433};
434
435template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
436class ElementwiseMinValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
437{
438public:
439 template <typename...>
440 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
441 {
442 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape, shape,
443 data_type0, data_type1, output_data_type,
444 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
445 }
446};
447
448template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000449class ElementwiseMinValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
450{
451public:
452 template <typename...>
453 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type,
454 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
455
456 {
457 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape, shape,
458 data_type0, data_type1, output_data_type,
459 qinfo0, qinfo1, qinfo_out);
460 }
461};
462
463template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros0192fd9432018-12-03 17:30:00 +0000464class ElementwiseMinQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
465{
466public:
467 template <typename...>
468 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type,
469 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
470
471 {
472 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape0, shape1,
473 data_type0, data_type1, output_data_type,
474 qinfo0, qinfo1, qinfo_out);
475 }
476};
477
478template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000479class ElementwiseSquaredDiffBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
480{
481public:
482 template <typename...>
483 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
484 {
485 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape0, shape1,
486 data_type0, data_type1, output_data_type,
487 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
488 }
489};
490
491template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
492class ElementwiseSquaredDiffValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
493{
494public:
495 template <typename...>
496 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
497 {
498 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape, shape,
499 data_type0, data_type1, output_data_type,
500 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
501 }
502};
503
504template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000505class ElementwiseSquaredDiffBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
506{
507public:
508 template <typename...>
509 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
510 {
511 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape0, shape1,
512 data_type0, data_type1, output_data_type,
513 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
514 }
515};
516
517template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
518class ElementwiseSquaredDiffValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
519{
520public:
521 template <typename...>
522 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
523 {
524 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape, shape,
525 data_type0, data_type1, output_data_type,
526 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
527 }
528};
529
530template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000531class ElementwiseSquaredDiffValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
532{
533public:
534 template <typename...>
535 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type,
536 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
537
538 {
539 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape, shape,
540 data_type0, data_type1, output_data_type,
541 qinfo0, qinfo1, qinfo_out);
542 }
543};
giuros0192fd9432018-12-03 17:30:00 +0000544
545template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
546class ElementwiseSquaredDiffQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
547{
548public:
549 template <typename...>
550 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type,
551 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
552
553 {
554 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape0, shape1,
555 data_type0, data_type1, output_data_type,
556 qinfo0, qinfo1, qinfo_out);
557 }
558};
George Worta1e7e282019-01-15 11:00:29 +0000559
560template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros011e6e1b82019-05-14 16:12:53 +0100561class PReluLayerBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
562{
563public:
564 template <typename...>
565 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
566 {
567 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape0, shape1,
568 data_type0, data_type1, output_data_type,
569 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
570 }
571};
572
573template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
574class PReluLayerValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
575{
576public:
577 template <typename...>
578 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
579 {
580 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape, shape,
581 data_type0, data_type1, output_data_type,
582 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
583 }
584};
585
586template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
587class PReluLayerValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
588{
589public:
590 template <typename...>
591 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type,
592 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
593
594 {
595 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape, shape,
596 data_type0, data_type1, output_data_type,
597 qinfo0, qinfo1, qinfo_out);
598 }
599};
600
601template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
602class PReluLayerQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
603{
604public:
605 template <typename...>
606 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type,
607 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
608
609 {
610 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape0, shape1,
611 data_type0, data_type1, output_data_type,
612 qinfo0, qinfo1, qinfo_out);
613 }
614};
615
616template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Usama Arif81e671e2019-05-13 13:33:14 +0100617class ElementwisePowerBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
618{
619public:
620 template <typename...>
621 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
622 {
623 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape0, shape1,
624 data_type0, data_type1, output_data_type,
625 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
626 }
627};
628
629template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
630class ElementwisePowerValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
631{
632public:
633 template <typename...>
634 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
635 {
636 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape, shape,
637 data_type0, data_type1, output_data_type,
638 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
639 }
640};
641
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000642template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
643class ElementwisePowerBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
644{
645public:
646 template <typename...>
647 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
648 {
649 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape0, shape1,
650 data_type0, data_type1, output_data_type,
651 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
652 }
653};
654
655template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
656class ElementwisePowerValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
657{
658public:
659 template <typename...>
660 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
661 {
662 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape, shape,
663 data_type0, data_type1, output_data_type,
664 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
665 }
666};
667
giuros01164a2722018-11-20 18:34:46 +0000668} // namespace validation
669} // namespace test
670} // namespace arm_compute
671#endif /* ARM_COMPUTE_TEST_ARITHMETIC_OPERATIONS_FIXTURE */