blob: 11ca510842ef60bd4709451d6c5c097039dce68c [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>
Suhail Munshiae1c9fe2021-04-14 12:16:49 +0100300class ArithmeticDivisionValidationIntegerFixture : public ArithmeticOperationsFuseActivationFixture<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, 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
312template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000313class ArithmeticDivisionValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
314{
315public:
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
327template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
328class ElementwiseMaxBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
329{
330public:
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
340template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
341class ElementwiseMaxValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
342{
343public:
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
353template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000354class ElementwiseMaxBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
355{
356public:
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
366template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
367class ElementwiseMaxValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<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, 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
379template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000380class ElementwiseMaxValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
381{
382public:
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
394template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros0192fd9432018-12-03 17:30:00 +0000395class ElementwiseMaxQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
396{
397public:
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
409template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000410class ElementwiseMinBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
411{
412public:
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
422template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
423class ElementwiseMinValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
424{
425public:
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
435template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000436class ElementwiseMinBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
437{
438public:
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
448template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
449class ElementwiseMinValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<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, 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
461template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000462class ElementwiseMinValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
463{
464public:
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
476template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros0192fd9432018-12-03 17:30:00 +0000477class ElementwiseMinQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
478{
479public:
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
491template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000492class ElementwiseSquaredDiffBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
493{
494public:
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
504template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
505class ElementwiseSquaredDiffValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
506{
507public:
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
517template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000518class ElementwiseSquaredDiffBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
519{
520public:
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
530template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
531class ElementwiseSquaredDiffValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<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, 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
543template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros01164a2722018-11-20 18:34:46 +0000544class ElementwiseSquaredDiffValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
545{
546public:
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};
giuros0192fd9432018-12-03 17:30:00 +0000557
558template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
559class ElementwiseSquaredDiffQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
560{
561public:
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 Worta1e7e282019-01-15 11:00:29 +0000572
573template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
giuros011e6e1b82019-05-14 16:12:53 +0100574class PReluLayerBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
575{
576public:
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
586template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
587class PReluLayerValidationFixture : 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 {
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
599template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
600class PReluLayerValidationQuantizedFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
601{
602public:
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
614template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
615class PReluLayerQuantizedBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
616{
617public:
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
629template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
Usama Arif81e671e2019-05-13 13:33:14 +0100630class ElementwisePowerBroadcastValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
631{
632public:
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
642template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
643class ElementwisePowerValidationFixture : public ArithmeticOperationsGenericFixture<TensorType, AccessorType, FunctionType, T>
644{
645public:
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 Arena8b2a7d32020-02-11 17:21:31 +0000655template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
656class ElementwisePowerBroadcastValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
657{
658public:
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
668template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
669class ElementwisePowerValidationFloatFixture : public ArithmeticOperationsFuseActivationFixture<TensorType, AccessorType, FunctionType, T>
670{
671public:
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
giuros01164a2722018-11-20 18:34:46 +0000681} // namespace validation
682} // namespace test
683} // namespace arm_compute
684#endif /* ARM_COMPUTE_TEST_ARITHMETIC_OPERATIONS_FIXTURE */