blob: 66618623424cb5d31189915dede919965dfe2297 [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"
Sheri Zhang1d359272021-06-10 13:56:11 +010029#include "arm_compute/core/Validate.h"
giuros01164a2722018-11-20 18:34:46 +000030#include "tests/AssetsLibrary.h"
31#include "tests/Globals.h"
32#include "tests/IAccessor.h"
33#include "tests/framework/Asserts.h"
34#include "tests/framework/Fixture.h"
35#include "tests/validation/Helpers.h"
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000036#include "tests/validation/reference/ActivationLayer.h"
giuros01164a2722018-11-20 18:34:46 +000037#include "tests/validation/reference/ElementwiseOperations.h"
38
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
45template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
46class ArithmeticOperationsGenericFixture : public framework::Fixture
47{
48public:
49 template <typename...>
50 void setup(ArithmeticOperation op, const TensorShape &shape0, const TensorShape &shape1,
51 DataType data_type0, DataType data_type1, DataType output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +010052 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, bool in_place = false, bool use_dynamic_shape = false)
giuros01164a2722018-11-20 18:34:46 +000053 {
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +000054 _op = op;
Sheri Zhang1d359272021-06-10 13:56:11 +010055 _use_dynamic_shape = use_dynamic_shape;
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +000056
Sheri Zhang1d359272021-06-10 13:56:11 +010057 _target = compute_target(shape0, shape1, data_type0, data_type1, output_data_type, qinfo0, qinfo1, qinfo_out, in_place);
giuros01164a2722018-11-20 18:34:46 +000058 _reference = compute_reference(shape0, shape1, data_type0, data_type1, output_data_type, qinfo0, qinfo1, qinfo_out);
59 }
60
61protected:
62 template <typename U>
63 void fill(U &&tensor, int i)
64 {
Georgios Pinitas18134222020-09-03 21:00:23 +010065 if(is_data_type_float(tensor.data_type()))
Usama Arif81e671e2019-05-13 13:33:14 +010066 {
Georgios Pinitas18134222020-09-03 21:00:23 +010067 switch(_op)
68 {
69 case ArithmeticOperation::DIV:
70 library->fill_tensor_uniform_ranged(tensor, i, { std::pair<float, float>(-0.001f, 0.001f) });
71 break;
72 case ArithmeticOperation::POWER:
73 library->fill_tensor_uniform(tensor, i, 0.0f, 5.0f);
74 break;
75 default:
76 library->fill_tensor_uniform(tensor, i);
77 }
78 }
79 else
80 {
81 library->fill_tensor_uniform(tensor, i);
Usama Arif81e671e2019-05-13 13:33:14 +010082 }
giuros01164a2722018-11-20 18:34:46 +000083 }
84
85 TensorType compute_target(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +010086 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, bool in_place = false)
giuros01164a2722018-11-20 18:34:46 +000087 {
88 // Create tensors
Sheri Zhang1d359272021-06-10 13:56:11 +010089 const TensorShape out_shape = TensorShape::broadcast_shape(shape0, shape1);
90 TensorType ref_src1 = create_tensor<TensorType>(shape0, data_type0, 1, qinfo0);
91 TensorType ref_src2 = create_tensor<TensorType>(shape1, data_type1, 1, qinfo1);
92 TensorType dst = create_tensor<TensorType>(out_shape, output_data_type, 1, qinfo_out);
93
94 // Check whether do in-place computation and whether inputs are broadcast compatible
95 TensorType *actual_dst = &dst;
96 bool src1_can_in_place = !arm_compute::detail::have_different_dimensions(out_shape, shape0, 0) && (qinfo0 == qinfo_out);
97 bool src2_can_in_place = !arm_compute::detail::have_different_dimensions(out_shape, shape1, 0) && (qinfo1 == qinfo_out);
98 bool do_in_place = in_place && out_shape.total_size() != 0 && (src1_can_in_place || src2_can_in_place);
99 if(do_in_place)
100 {
101 if(src1_can_in_place)
102 {
103 actual_dst = &ref_src1;
104 }
105 else if(src2_can_in_place)
106 {
107 actual_dst = &ref_src2;
108 }
109 }
giuros01164a2722018-11-20 18:34:46 +0000110
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +0000111 // if _use_dynamic_shape is true, this fixture will test scenario for dynamic shapes.
112 // - At configure time, all input tensors are marked as dynamic using set_tensor_dynamic()
113 // - After configure, tensors are marked as static for run using set_tensor_static()
114 // - The tensors with static shape are given to run()
115 if(_use_dynamic_shape)
116 {
117 set_tensor_dynamic(ref_src1);
118 set_tensor_dynamic(ref_src2);
119 }
120
giuros01164a2722018-11-20 18:34:46 +0000121 // Create and configure function
122 FunctionType elem_op;
Sheri Zhang1d359272021-06-10 13:56:11 +0100123 elem_op.configure(&ref_src1, &ref_src2, actual_dst);
giuros01164a2722018-11-20 18:34:46 +0000124
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +0000125 if(_use_dynamic_shape)
126 {
127 set_tensor_static(ref_src1);
128 set_tensor_static(ref_src2);
129 }
130
Michele Di Giorgio4fc10b32021-04-30 18:30:41 +0100131 ARM_COMPUTE_ASSERT(ref_src1.info()->is_resizable());
132 ARM_COMPUTE_ASSERT(ref_src2.info()->is_resizable());
giuros01164a2722018-11-20 18:34:46 +0000133
134 // Allocate tensors
135 ref_src1.allocator()->allocate();
136 ref_src2.allocator()->allocate();
Sheri Zhang1d359272021-06-10 13:56:11 +0100137
138 // If in-place computation is not supported, still need to allocate original dst
139 if(!do_in_place)
140 {
141 ARM_COMPUTE_ASSERT(dst.info()->is_resizable());
142 dst.allocator()->allocate();
143 ARM_COMPUTE_ASSERT(!dst.info()->is_resizable());
144 }
giuros01164a2722018-11-20 18:34:46 +0000145
Michele Di Giorgio4fc10b32021-04-30 18:30:41 +0100146 ARM_COMPUTE_ASSERT(!ref_src1.info()->is_resizable());
147 ARM_COMPUTE_ASSERT(!ref_src2.info()->is_resizable());
giuros01164a2722018-11-20 18:34:46 +0000148
149 // Fill tensors
150 fill(AccessorType(ref_src1), 0);
151 fill(AccessorType(ref_src2), 1);
152
153 // Compute function
154 elem_op.run();
155
Sheri Zhang1d359272021-06-10 13:56:11 +0100156 return std::move(*actual_dst);
giuros01164a2722018-11-20 18:34:46 +0000157 }
158
159 SimpleTensor<T> compute_reference(const TensorShape &shape0, const TensorShape &shape1,
160 DataType data_type0, DataType data_type1, DataType output_data_type,
161 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
162 {
163 // Create reference
164 SimpleTensor<T> ref_src1{ shape0, data_type0, 1, qinfo0 };
165 SimpleTensor<T> ref_src2{ shape1, data_type1, 1, qinfo1 };
166 SimpleTensor<T> ref_dst{ TensorShape::broadcast_shape(shape0, shape1), output_data_type, 1, qinfo_out };
167
168 // Fill reference
169 fill(ref_src1, 0);
170 fill(ref_src2, 1);
171
172 return reference::arithmetic_operation<T>(_op, ref_src1, ref_src2, ref_dst);
173 }
174
175 TensorType _target{};
176 SimpleTensor<T> _reference{};
177 ArithmeticOperation _op{ ArithmeticOperation::ADD };
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +0000178 bool _use_dynamic_shape{ false };
giuros01164a2722018-11-20 18:34:46 +0000179};
180
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000181// Arithmetic operation fused with activation function
182template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
183class ArithmeticOperationsFuseActivationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
184{
185public:
186 template <typename...>
187 void setup(ArithmeticOperation op, const TensorShape &shape0, const TensorShape &shape1,
188 DataType data_type0, DataType data_type1, DataType output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100189 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out, ActivationLayerInfo act_info, bool in_place = false)
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000190 {
191 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(op, shape0, shape1,
192 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100193 qinfo0, qinfo1, qinfo_out, in_place);
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000194 _act_info = act_info;
195 }
196
197protected:
198 TensorType compute_target(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type,
199 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
200 {
201 // Create tensors
202 TensorType ref_src1 = create_tensor<TensorType>(shape0, data_type0, 1, qinfo0);
203 TensorType ref_src2 = create_tensor<TensorType>(shape1, data_type1, 1, qinfo1);
204 TensorType dst = create_tensor<TensorType>(TensorShape::broadcast_shape(shape0, shape1), output_data_type, 1, qinfo_out);
205
206 // Create and configure function
207 FunctionType elem_op;
208 elem_op.configure(&ref_src1, &ref_src2, &dst, _act_info);
209
Michele Di Giorgio4fc10b32021-04-30 18:30:41 +0100210 ARM_COMPUTE_ASSERT(ref_src1.info()->is_resizable());
211 ARM_COMPUTE_ASSERT(ref_src2.info()->is_resizable());
212 ARM_COMPUTE_ASSERT(dst.info()->is_resizable());
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000213
214 // Allocate tensors
215 ref_src1.allocator()->allocate();
216 ref_src2.allocator()->allocate();
217 dst.allocator()->allocate();
218
Michele Di Giorgio4fc10b32021-04-30 18:30:41 +0100219 ARM_COMPUTE_ASSERT(!ref_src1.info()->is_resizable());
220 ARM_COMPUTE_ASSERT(!ref_src2.info()->is_resizable());
221 ARM_COMPUTE_ASSERT(!dst.info()->is_resizable());
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000222
223 // Fill tensors
224 fill(AccessorType(ref_src1), 0);
225 fill(AccessorType(ref_src2), 1);
226
227 // Compute function
228 elem_op.run();
229
230 return dst;
231 }
232
233 SimpleTensor<T> compute_reference(const TensorShape &shape0, const TensorShape &shape1,
234 DataType data_type0, DataType data_type1, DataType output_data_type,
235 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
236 {
237 auto result = ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::compute_reference(shape0, shape1, data_type0,
238 data_type1, output_data_type, qinfo0, qinfo1, qinfo_out);
239 return _act_info.enabled() ? reference::activation_layer(result, _act_info, qinfo_out) : result;
240 }
241
242 ActivationLayerInfo _act_info{};
243};
244
giuros01164a2722018-11-20 18:34:46 +0000245template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
246class ArithmeticDivisionBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
247{
248public:
249 template <typename...>
250 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
251 {
252 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape0, shape1,
253 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100254 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), true);
giuros01164a2722018-11-20 18:34:46 +0000255 }
256};
257
258template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
259class ArithmeticDivisionValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
260{
261public:
262 template <typename...>
263 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
264 {
265 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape,
266 data_type0, data_type1, output_data_type,
267 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
268 }
269};
270
271template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +0000272class ArithmeticDivisionBroadcastDynamicShapeValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
273{
274public:
275 template <typename...>
276 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
277 {
278 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape0, shape1,
279 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100280 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), true, true);
Sang-Hoon Park668ccdc2021-02-03 10:32:59 +0000281 }
282};
283
284template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
285class ArithmeticDivisionDynamicShapeValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
286{
287public:
288 template <typename...>
289 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
290 {
291 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape,
292 data_type0, data_type1, output_data_type,
293 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), true);
294 }
295};
296
297template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000298class ArithmeticDivisionBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
299{
300public:
301 template <typename...>
302 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
303 {
304 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape0, shape1,
305 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100306 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info, true);
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000307 }
308};
309
310template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
311class ArithmeticDivisionValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
312{
313public:
314 template <typename...>
315 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
316 {
317 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape,
318 data_type0, data_type1, output_data_type,
319 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
320 }
321};
322
323template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Suhail Munshiae1c9fe2021-04-14 12:16:49 +0100324class ArithmeticDivisionValidationIntegerFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
325{
326public:
327 template <typename...>
328 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
329 {
330 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape,
331 data_type0, data_type1, output_data_type,
332 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
333 }
334};
335
336template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000337class ArithmeticDivisionValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
338{
339public:
340 template <typename...>
341 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type,
342 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
343
344 {
345 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::DIV, shape, shape,
346 data_type0, data_type1, output_data_type,
347 qinfo0, qinfo1, qinfo_out);
348 }
349};
350
351template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
352class ElementwiseMaxBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
353{
354public:
355 template <typename...>
356 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
357 {
358 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape0, shape1,
359 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100360 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), true);
giuros01164a2722018-11-20 18:34:46 +0000361 }
362};
363
364template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
365class ElementwiseMaxValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
366{
367public:
368 template <typename...>
369 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
370 {
371 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape, shape,
372 data_type0, data_type1, output_data_type,
373 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
374 }
375};
376
377template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000378class ElementwiseMaxBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
379{
380public:
381 template <typename...>
382 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
383 {
384 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape0, shape1,
385 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100386 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info, true);
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000387 }
388};
389
390template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
391class ElementwiseMaxValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
392{
393public:
394 template <typename...>
395 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
396 {
397 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape, shape,
398 data_type0, data_type1, output_data_type,
399 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
400 }
401};
402
403template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000404class ElementwiseMaxValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
405{
406public:
407 template <typename...>
408 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type,
409 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
410
411 {
412 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape, shape,
413 data_type0, data_type1, output_data_type,
414 qinfo0, qinfo1, qinfo_out);
415 }
416};
417
418template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros0192fd9432018-12-03 17:30:00 +0000419class ElementwiseMaxQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
420{
421public:
422 template <typename...>
423 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type,
424 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
425
426 {
427 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MAX, shape0, shape1,
428 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100429 qinfo0, qinfo1, qinfo_out, true);
giuros0192fd9432018-12-03 17:30:00 +0000430 }
431};
432
433template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000434class ElementwiseMinBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
435{
436public:
437 template <typename...>
438 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
439 {
440 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape0, shape1,
441 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100442 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), true);
giuros01164a2722018-11-20 18:34:46 +0000443 }
444};
445
446template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
447class ElementwiseMinValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
448{
449public:
450 template <typename...>
451 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
452 {
453 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape, shape,
454 data_type0, data_type1, output_data_type,
455 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
456 }
457};
458
459template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000460class ElementwiseMinBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
461{
462public:
463 template <typename...>
464 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
465 {
466 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape0, shape1,
467 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100468 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info, true);
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000469 }
470};
471
472template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
473class ElementwiseMinValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
474{
475public:
476 template <typename...>
477 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
478 {
479 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape, shape,
480 data_type0, data_type1, output_data_type,
481 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
482 }
483};
484
485template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000486class ElementwiseMinValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
487{
488public:
489 template <typename...>
490 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type,
491 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
492
493 {
494 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape, shape,
495 data_type0, data_type1, output_data_type,
496 qinfo0, qinfo1, qinfo_out);
497 }
498};
499
500template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros0192fd9432018-12-03 17:30:00 +0000501class ElementwiseMinQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
502{
503public:
504 template <typename...>
505 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type,
506 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
507
508 {
509 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::MIN, shape0, shape1,
510 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100511 qinfo0, qinfo1, qinfo_out, true);
giuros0192fd9432018-12-03 17:30:00 +0000512 }
513};
514
515template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000516class ElementwiseSquaredDiffBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
517{
518public:
519 template <typename...>
520 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
521 {
522 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape0, shape1,
523 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100524 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), true);
giuros01164a2722018-11-20 18:34:46 +0000525 }
526};
527
528template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
529class ElementwiseSquaredDiffValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
530{
531public:
532 template <typename...>
533 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
534 {
535 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape, shape,
536 data_type0, data_type1, output_data_type,
537 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
538 }
539};
540
541template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000542class ElementwiseSquaredDiffBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
543{
544public:
545 template <typename...>
546 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
547 {
548 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape0, shape1,
549 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100550 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info, true);
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000551 }
552};
553
554template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
555class ElementwiseSquaredDiffValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
556{
557public:
558 template <typename...>
559 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
560 {
561 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape, shape,
562 data_type0, data_type1, output_data_type,
563 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
564 }
565};
566
567template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000568class ElementwiseSquaredDiffValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
569{
570public:
571 template <typename...>
572 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type,
573 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
574
575 {
576 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape, shape,
577 data_type0, data_type1, output_data_type,
578 qinfo0, qinfo1, qinfo_out);
579 }
580};
giuros0192fd9432018-12-03 17:30:00 +0000581
582template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
583class ElementwiseSquaredDiffQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
584{
585public:
586 template <typename...>
587 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type,
588 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
589
590 {
591 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::SQUARED_DIFF, shape0, shape1,
592 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100593 qinfo0, qinfo1, qinfo_out, true);
giuros0192fd9432018-12-03 17:30:00 +0000594 }
595};
George Worta1e7e282019-01-15 11:00:29 +0000596
597template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros011e6e1b82019-05-14 16:12:53 +0100598class PReluLayerBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
599{
600public:
601 template <typename...>
602 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
603 {
604 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape0, shape1,
605 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100606 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), true);
giuros011e6e1b82019-05-14 16:12:53 +0100607 }
608};
609
610template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
611class PReluLayerValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
612{
613public:
614 template <typename...>
615 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
616 {
617 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape, shape,
618 data_type0, data_type1, output_data_type,
619 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
620 }
621};
622
623template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
624class PReluLayerValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
625{
626public:
627 template <typename...>
628 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type,
629 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
630
631 {
632 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape, shape,
633 data_type0, data_type1, output_data_type,
634 qinfo0, qinfo1, qinfo_out);
635 }
636};
637
638template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
639class PReluLayerQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
640{
641public:
642 template <typename...>
643 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type,
644 QuantizationInfo qinfo0, QuantizationInfo qinfo1, QuantizationInfo qinfo_out)
645
646 {
647 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::PRELU, shape0, shape1,
648 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100649 qinfo0, qinfo1, qinfo_out, true);
giuros011e6e1b82019-05-14 16:12:53 +0100650 }
651};
652
653template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Usama Arif81e671e2019-05-13 13:33:14 +0100654class ElementwisePowerBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
655{
656public:
657 template <typename...>
658 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type)
659 {
660 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape0, shape1,
661 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100662 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), true);
Usama Arif81e671e2019-05-13 13:33:14 +0100663 }
664};
665
666template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
667class ElementwisePowerValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
668{
669public:
670 template <typename...>
671 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type)
672 {
673 ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape, shape,
674 data_type0, data_type1, output_data_type,
675 QuantizationInfo(), QuantizationInfo(), QuantizationInfo());
676 }
677};
678
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000679template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
680class ElementwisePowerBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
681{
682public:
683 template <typename...>
684 void setup(const TensorShape &shape0, const TensorShape &shape1, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
685 {
686 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape0, shape1,
687 data_type0, data_type1, output_data_type,
Sheri Zhang1d359272021-06-10 13:56:11 +0100688 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info, true);
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000689 }
690};
691
692template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
693class ElementwisePowerValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
694{
695public:
696 template <typename...>
697 void setup(const TensorShape &shape, DataType data_type0, DataType data_type1, DataType output_data_type, ActivationLayerInfo act_info)
698 {
699 ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>::setup(ArithmeticOperation::POWER, shape, shape,
700 data_type0, data_type1, output_data_type,
701 QuantizationInfo(), QuantizationInfo(), QuantizationInfo(), act_info);
702 }
703};
704
giuros01164a2722018-11-20 18:34:46 +0000705} // namespace validation
706} // namespace test
707} // namespace arm_compute
708#endif /* ARM_COMPUTE_TEST_ARITHMETIC_OPERATIONS_FIXTURE */