blob: 52d787febbacaa4f67e0d1cdefdbe8dbca4795a1 [file] [log] [blame]
Sanghoon Lee72898fe2017-09-01 11:42:16 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2020 Arm Limited.
Sanghoon Lee72898fe2017-09-01 11:42:16 +01003 *
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,
Georgios Pinitascbf39c62018-09-10 15:07:45 +010021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Sanghoon Lee72898fe2017-09-01 11:42:16 +010022 * SOFTWARE.
23 */
24#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/CL/CLTensor.h"
26#include "arm_compute/runtime/CL/CLTensorAllocator.h"
giuros01164a2722018-11-20 18:34:46 +000027#include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h"
Sanghoon Lee72898fe2017-09-01 11:42:16 +010028#include "tests/CL/CLAccessor.h"
29#include "tests/PaddingCalculator.h"
30#include "tests/datasets/ConvertPolicyDataset.h"
31#include "tests/datasets/ShapeDatasets.h"
32#include "tests/framework/Asserts.h"
33#include "tests/framework/Macros.h"
34#include "tests/framework/datasets/Datasets.h"
35#include "tests/validation/Validation.h"
Georgios Pinitascbf39c62018-09-10 15:07:45 +010036#include "tests/validation/fixtures/ArithmeticOperationsFixture.h"
Sanghoon Lee72898fe2017-09-01 11:42:16 +010037
38namespace arm_compute
39{
40namespace test
41{
42namespace validation
43{
44namespace
45{
giuros01164a2722018-11-20 18:34:46 +000046constexpr unsigned int num_elems_processed_per_iteration = 16;
Sanghoon Lee72898fe2017-09-01 11:42:16 +010047/** Input data sets **/
48const auto ArithmeticSubtractionU8Dataset = combine(combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::U8)),
49 framework::dataset::make("DataType",
50 DataType::U8));
Georgios Pinitascbf39c62018-09-10 15:07:45 +010051const auto ArithmeticSubtractionQASYMM8Dataset = combine(combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::QASYMM8)),
52 framework::dataset::make("DataType",
53 DataType::QASYMM8));
Kurtis Charnockec0c4122019-12-05 14:13:46 +000054const auto ArithmeticSubtractionQASYMM8SignedDataset = combine(combine(framework::dataset::make("DataType", DataType::QASYMM8_SIGNED), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000055 framework::dataset::make("DataType",
56 DataType::QASYMM8_SIGNED));
Michele Di Giorgio6997fc92019-06-18 10:23:22 +010057const auto ArithmeticSubtractionQSYMM16Dataset = combine(combine(framework::dataset::make("DataType", DataType::QSYMM16), framework::dataset::make("DataType", DataType::QSYMM16)),
58 framework::dataset::make("DataType",
59 DataType::QSYMM16));
Georgios Pinitascbf39c62018-09-10 15:07:45 +010060const auto ArithmeticSubtractionS16Dataset = combine(combine(framework::dataset::make("DataType", { DataType::U8, DataType::S16 }), framework::dataset::make("DataType", DataType::S16)),
Sanghoon Lee72898fe2017-09-01 11:42:16 +010061 framework::dataset::make("DataType", DataType::S16));
Sanghoon Lee72898fe2017-09-01 11:42:16 +010062const auto ArithmeticSubtractionFP16Dataset = combine(combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::F16)),
63 framework::dataset::make("DataType", DataType::F16));
64const auto ArithmeticSubtractionFP32Dataset = combine(combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::F32)),
65 framework::dataset::make("DataType", DataType::F32));
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000066const auto EmptyActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
67{ ActivationLayerInfo() });
68const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
69{
70 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.75f, 0.25f),
71 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC, 0.75f, 0.25f)
72});
Georgios Pinitasb2842be2020-06-22 21:27:14 +010073const auto InPlaceDataSet = framework::dataset::make("InPlace", { false, true });
74const auto OutOfPlaceDataSet = framework::dataset::make("InPlace", { false });
Sanghoon Lee72898fe2017-09-01 11:42:16 +010075} // namespace
76
77TEST_SUITE(CL)
78TEST_SUITE(ArithmeticSubtraction)
79
Georgios Pinitasf9d3a0a2017-11-03 19:01:44 +000080// *INDENT-OFF*
81// clang-format off
82DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
giuros01164a2722018-11-20 18:34:46 +000083 framework::dataset::make("Input1Info", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
84 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
85 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Window shrink
86 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Invalid data type combination
87 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Mismatching shapes
88 }),
89 framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
90 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
91 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8),
92 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16),
93 TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
94 })),
95 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16),
96 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
97 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8),
98 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
99 TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
100 })),
101 framework::dataset::make("Expected", { true, true, false, false, false})),
102 input1_info, input2_info, output_info, expected)
Georgios Pinitasf9d3a0a2017-11-03 19:01:44 +0000103{
Giorgio Arena70623822017-11-27 15:50:10 +0000104 ARM_COMPUTE_EXPECT(bool(CLArithmeticSubtraction::validate(&input1_info.clone()->set_is_resizable(false), &input2_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), ConvertPolicy::WRAP)) == expected, framework::LogLevel::ERRORS);
Georgios Pinitasf9d3a0a2017-11-03 19:01:44 +0000105}
106// clang-format on
107// *INDENT-ON*
108
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100109TEST_SUITE(InPlaceValidate)
110TEST_CASE(SingleTensor, framework::DatasetMode::ALL)
111{
112 const auto random_shape = TensorShape{ 9, 9 };
113 const auto single_tensor_info = TensorInfo{ random_shape, 1, DataType::F32 };
114
115 Status result = CLArithmeticSubtraction::validate(&single_tensor_info, &single_tensor_info, &single_tensor_info, ConvertPolicy::WRAP);
116 ARM_COMPUTE_EXPECT(bool(result) == true, framework::LogLevel::ERRORS);
117}
118
119TEST_CASE(ValidBroadCast, framework::DatasetMode::ALL)
120{
121 const auto larger_shape = TensorShape{ 27U, 13U, 2U };
122 const auto smaller_shape = TensorShape{ 1U, 13U, 2U };
123
124 const auto larger_tensor_info = TensorInfo{ larger_shape, 1, DataType::F32 };
125 const auto smaller_tensor_info = TensorInfo{ smaller_shape, 1, DataType::F32 };
126
127 Status result = CLArithmeticSubtraction::validate(&larger_tensor_info, &smaller_tensor_info, &larger_tensor_info, ConvertPolicy::WRAP);
128 ARM_COMPUTE_EXPECT(bool(result) == true, framework::LogLevel::ERRORS);
129}
130
131TEST_CASE(InvalidBroadcastOutput, framework::DatasetMode::ALL)
132{
133 const auto larger_shape = TensorShape{ 27U, 13U, 2U };
134 const auto smaller_shape = TensorShape{ 1U, 13U, 2U };
135
136 const auto larger_tensor_info = TensorInfo{ larger_shape, 1, DataType::F32 };
137 const auto smaller_tensor_info = TensorInfo{ smaller_shape, 1, DataType::F32 };
138
139 Status result = CLArithmeticSubtraction::validate(&larger_tensor_info, &smaller_tensor_info, &smaller_tensor_info, ConvertPolicy::WRAP);
140 ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
141}
142
143TEST_CASE(InvalidBroadcastBoth, framework::DatasetMode::ALL)
144{
145 const auto shape0 = TensorShape{ 9U, 9U };
146 const auto shape1 = TensorShape{ 9U, 1U, 2U };
147
148 const auto info0 = TensorInfo{ shape0, 1, DataType::F32 };
149 const auto info1 = TensorInfo{ shape1, 1, DataType::F32 };
150
151 Status result{};
152
153 result = CLArithmeticSubtraction::validate(&info0, &info1, &info0, ConvertPolicy::WRAP);
154 ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
155
156 result = CLArithmeticSubtraction::validate(&info0, &info1, &info1, ConvertPolicy::WRAP);
157 ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
158}
159TEST_SUITE_END() // InPlaceValidate
160
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100161template <typename T>
162using CLArithmeticSubtractionFixture = ArithmeticSubtractionValidationFixture<CLTensor, CLAccessor, CLArithmeticSubtraction, T>;
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100163
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100164TEST_SUITE(Integer)
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100165TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +0000166DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100167 shape, policy)
168{
169 // Create tensors
170 CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::U8);
171 CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::U8);
172 CLTensor dst = create_tensor<CLTensor>(shape, DataType::U8);
173
174 // Create and Configure function
giuros01164a2722018-11-20 18:34:46 +0000175 CLArithmeticSubtraction add;
176 add.configure(&ref_src1, &ref_src2, &dst, policy);
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100177
178 // Validate valid region
179 const ValidRegion valid_region = shape_to_valid_region(shape);
180 validate(dst.info()->valid_region(), valid_region);
181
182 // Validate padding
giuros01164a2722018-11-20 18:34:46 +0000183 const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding();
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100184 validate(ref_src1.info()->padding(), padding);
185 validate(ref_src2.info()->padding(), padding);
186 validate(dst.info()->padding(), padding);
187}
188
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100189FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ArithmeticSubtractionU8Dataset),
190 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
191 OutOfPlaceDataSet))
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100192{
193 // Validate output
194 validate(CLAccessor(_target), _reference);
195}
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100196TEST_SUITE_END() // U8
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100197
198TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000199DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })),
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100200 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
201 shape, data_type, policy)
202{
203 // Create tensors
204 CLTensor ref_src1 = create_tensor<CLTensor>(shape, data_type);
205 CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::S16);
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100206 CLTensor dst = create_tensor<CLTensor>(shape, DataType::S16);
207
208 // Create and Configure function
giuros01164a2722018-11-20 18:34:46 +0000209 CLArithmeticSubtraction add;
210 add.configure(&ref_src1, &ref_src2, &dst, policy);
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100211
212 // Validate valid region
213 const ValidRegion valid_region = shape_to_valid_region(shape);
214 validate(dst.info()->valid_region(), valid_region);
215
216 // Validate padding
giuros01164a2722018-11-20 18:34:46 +0000217 const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding();
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100218 validate(ref_src1.info()->padding(), padding);
219 validate(ref_src2.info()->padding(), padding);
220 validate(dst.info()->padding(), padding);
221}
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100222
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100223FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ArithmeticSubtractionS16Dataset),
224 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
225 OutOfPlaceDataSet))
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100226{
227 // Validate output
228 validate(CLAccessor(_target), _reference);
229}
230
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100231FIXTURE_DATA_TEST_CASE(RunLarge, CLArithmeticSubtractionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ArithmeticSubtractionS16Dataset),
232 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
233 OutOfPlaceDataSet))
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100234{
235 // Validate output
236 validate(CLAccessor(_target), _reference);
237}
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100238TEST_SUITE_END() // S16
239TEST_SUITE_END() // Integer
240
241template <typename T>
242using CLArithmeticSubtractionQuantizedFixture = ArithmeticSubtractionValidationQuantizedFixture<CLTensor, CLAccessor, CLArithmeticSubtraction, T>;
243
244TEST_SUITE(Quantized)
245TEST_SUITE(QASYMM8)
246DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
247 shape, policy)
248{
249 // Create tensors
250 CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::QASYMM8);
251 CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::QASYMM8);
252 CLTensor dst = create_tensor<CLTensor>(shape, DataType::QASYMM8);
253
254 // Create and Configure function
255 CLArithmeticSubtraction add;
256 add.configure(&ref_src1, &ref_src2, &dst, policy);
257
258 // Validate valid region
259 const ValidRegion valid_region = shape_to_valid_region(shape);
260 validate(dst.info()->valid_region(), valid_region);
261
262 // Validate padding
263 const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding();
264 validate(ref_src1.info()->padding(), padding);
265 validate(ref_src2.info()->padding(), padding);
266 validate(dst.info()->padding(), padding);
267}
268
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100269FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(),
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100270 ArithmeticSubtractionQASYMM8Dataset),
271 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
272 framework::dataset::make("Src0QInfo", { QuantizationInfo(5.f / 255.f, 20) })),
273 framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 255.f, 10) })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100274 framework::dataset::make("OutQInfo", { QuantizationInfo(1.f / 255.f, 5) })),
275 InPlaceDataSet))
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100276{
277 // Validate output
278 validate(CLAccessor(_target), _reference);
279}
280TEST_SUITE_END() // QASYMM8
Kurtis Charnockec0c4122019-12-05 14:13:46 +0000281TEST_SUITE(QASYMM8_SIGNED)
282DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
283 shape, policy)
284{
285 // Create tensors
286 CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::QASYMM8_SIGNED);
287 CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::QASYMM8_SIGNED);
288 CLTensor dst = create_tensor<CLTensor>(shape, DataType::QASYMM8_SIGNED);
289
290 // Create and Configure function
291 CLArithmeticSubtraction sub;
292 sub.configure(&ref_src1, &ref_src2, &dst, policy);
293
294 // Validate valid region
295 const ValidRegion valid_region = shape_to_valid_region(shape);
296 validate(dst.info()->valid_region(), valid_region);
297
298 // Validate padding
299 const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding();
300 validate(ref_src1.info()->padding(), padding);
301 validate(ref_src2.info()->padding(), padding);
302 validate(dst.info()->padding(), padding);
303}
304
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100305FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(),
Kurtis Charnockec0c4122019-12-05 14:13:46 +0000306 ArithmeticSubtractionQASYMM8SignedDataset),
307 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
308 framework::dataset::make("Src0QInfo", { QuantizationInfo(5.f / 255.f, 10) })),
309 framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 255.f, 10) })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100310 framework::dataset::make("OutQInfo", { QuantizationInfo(1.f / 255.f, 5) })),
311 InPlaceDataSet))
Kurtis Charnockec0c4122019-12-05 14:13:46 +0000312{
313 // Validate output
314 validate(CLAccessor(_target), _reference);
315}
316TEST_SUITE_END() // QASYMM8_SIGNED
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100317TEST_SUITE(QSYMM16)
318DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
319 shape, policy)
320{
321 // Create tensors
322 CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::QSYMM16);
323 CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::QSYMM16);
324 CLTensor dst = create_tensor<CLTensor>(shape, DataType::QSYMM16);
325
326 // Create and Configure function
327 CLArithmeticSubtraction sub;
328 sub.configure(&ref_src1, &ref_src2, &dst, policy);
329
330 // Validate valid region
331 const ValidRegion valid_region = shape_to_valid_region(shape);
332 validate(dst.info()->valid_region(), valid_region);
333
334 // Validate padding
335 const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding();
336 validate(ref_src1.info()->padding(), padding);
337 validate(ref_src2.info()->padding(), padding);
338 validate(dst.info()->padding(), padding);
339}
340
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100341FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionQuantizedFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(),
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100342 ArithmeticSubtractionQSYMM16Dataset),
343 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
344 framework::dataset::make("Src0QInfo", { QuantizationInfo(1.f / 32768.f, 0), QuantizationInfo(5.f / 32768.f, 0) })),
345 framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 32768.f, 0), QuantizationInfo(5.f / 32768.f, 0) })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100346 framework::dataset::make("OutQInfo", { QuantizationInfo(5.f / 32768.f, 0) })),
347 OutOfPlaceDataSet))
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100348{
349 // Validate output
350 validate(CLAccessor(_target), _reference);
351}
352TEST_SUITE_END() // QSYMM16
353TEST_SUITE_END() // Quantized
Isabella Gottardib5908c22017-10-30 15:28:13 +0000354
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000355template <typename T>
356using CLArithmeticSubtractionFloatFixture = ArithmeticSubtractionValidationFloatFixture<CLTensor, CLAccessor, CLArithmeticSubtraction, T>;
357
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100358TEST_SUITE(Float)
359TEST_SUITE(FP16)
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100360FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFloatFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallShapes(), ArithmeticSubtractionFP16Dataset),
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000361 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100362 EmptyActivationFunctionsDataset),
363 OutOfPlaceDataSet))
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000364{
365 // Validate output
366 validate(CLAccessor(_target), _reference);
367}
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100368FIXTURE_DATA_TEST_CASE(RunWithActivation, CLArithmeticSubtractionFloatFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::TinyShapes(),
369 ArithmeticSubtractionFP16Dataset),
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000370 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100371 ActivationFunctionsDataset),
372 InPlaceDataSet))
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100373{
374 // Validate output
375 validate(CLAccessor(_target), _reference);
376}
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100377TEST_SUITE_END() // FP16
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100378
379TEST_SUITE(FP32)
Michalis Spyrou80943252019-01-10 17:19:50 +0000380DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100381 shape, policy)
382{
383 // Create tensors
384 CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::F32);
385 CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::F32);
386 CLTensor dst = create_tensor<CLTensor>(shape, DataType::F32);
387
388 // Create and Configure function
giuros01164a2722018-11-20 18:34:46 +0000389 CLArithmeticSubtraction add;
390 add.configure(&ref_src1, &ref_src2, &dst, policy);
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100391
392 // Validate valid region
393 const ValidRegion valid_region = shape_to_valid_region(shape);
394 validate(dst.info()->valid_region(), valid_region);
395
396 // Validate padding
giuros01164a2722018-11-20 18:34:46 +0000397 const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding();
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100398 validate(ref_src1.info()->padding(), padding);
399 validate(ref_src2.info()->padding(), padding);
400 validate(dst.info()->padding(), padding);
401}
402
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100403FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFloatFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(),
404 ArithmeticSubtractionFP32Dataset),
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000405 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100406 EmptyActivationFunctionsDataset),
407 OutOfPlaceDataSet))
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000408{
409 // Validate output
410 validate(CLAccessor(_target), _reference);
411}
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100412FIXTURE_DATA_TEST_CASE(RunWithActivation, CLArithmeticSubtractionFloatFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::TinyShapes(),
413 ArithmeticSubtractionFP32Dataset),
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000414 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100415 ActivationFunctionsDataset),
416 InPlaceDataSet))
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100417{
418 // Validate output
419 validate(CLAccessor(_target), _reference);
420}
421
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100422FIXTURE_DATA_TEST_CASE(RunLarge, CLArithmeticSubtractionFloatFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeShapes(),
423 ArithmeticSubtractionFP32Dataset),
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000424 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100425 EmptyActivationFunctionsDataset),
426 OutOfPlaceDataSet))
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100427{
428 // Validate output
429 validate(CLAccessor(_target), _reference);
430}
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100431
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100432template <typename T>
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000433using CLArithmeticSubtractionBroadcastFloatFixture = ArithmeticSubtractionBroadcastValidationFloatFixture<CLTensor, CLAccessor, CLArithmeticSubtraction, T>;
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100434
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100435FIXTURE_DATA_TEST_CASE(RunSmallBroadcast, CLArithmeticSubtractionBroadcastFloatFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapesBroadcast(),
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100436 ArithmeticSubtractionFP32Dataset),
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000437 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100438 EmptyActivationFunctionsDataset),
439 OutOfPlaceDataSet))
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000440{
441 // Validate output
442 validate(CLAccessor(_target), _reference);
443}
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100444FIXTURE_DATA_TEST_CASE(RunWithActivationBroadcast, CLArithmeticSubtractionBroadcastFloatFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::TinyShapesBroadcast(),
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000445 ArithmeticSubtractionFP32Dataset),
446 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100447 ActivationFunctionsDataset),
448 OutOfPlaceDataSet))
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100449{
450 // Validate output
451 validate(CLAccessor(_target), _reference);
452}
453
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100454FIXTURE_DATA_TEST_CASE(RunLargeBroadcast, CLArithmeticSubtractionBroadcastFloatFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeShapesBroadcast(),
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100455 ArithmeticSubtractionFP32Dataset),
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000456 framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
Georgios Pinitasb2842be2020-06-22 21:27:14 +0100457 EmptyActivationFunctionsDataset),
458 OutOfPlaceDataSet))
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100459{
460 // Validate output
461 validate(CLAccessor(_target), _reference);
462}
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100463TEST_SUITE_END() // FP32
464TEST_SUITE_END() // Float
Georgios Pinitascbf39c62018-09-10 15:07:45 +0100465
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100466TEST_SUITE_END() // ArithmeticSubtraction
467TEST_SUITE_END() // CL
Sanghoon Lee72898fe2017-09-01 11:42:16 +0100468} // namespace validation
469} // namespace test
giuros01164a2722018-11-20 18:34:46 +0000470} // namespace arm_compute