blob: 93cf26802d0376d0ec4009ac95770e14db1a0cb8 [file] [log] [blame]
Isabella Gottardi1fab09f2017-07-13 15:55:57 +01001/*
Michalis Spyrou80943252019-01-10 17:19:50 +00002 * Copyright (c) 2017-2019 ARM Limited.
Isabella Gottardi1fab09f2017-07-13 15:55:57 +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,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/Helpers.h"
25#include "arm_compute/core/Types.h"
26#include "arm_compute/runtime/CL/functions/CLScale.h"
27#include "arm_compute/runtime/Tensor.h"
28#include "arm_compute/runtime/TensorAllocator.h"
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010029#include "tests/CL/CLAccessor.h"
30#include "tests/PaddingCalculator.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010031#include "tests/datasets/BorderModeDataset.h"
Daniil Efremov02bf80d2017-11-22 00:26:51 +070032#include "tests/datasets/SamplingPolicyDataset.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010033#include "tests/datasets/ShapeDatasets.h"
34#include "tests/framework/Asserts.h"
35#include "tests/framework/Macros.h"
36#include "tests/framework/datasets/Datasets.h"
37#include "tests/validation/Helpers.h"
38#include "tests/validation/Validation.h"
39#include "tests/validation/fixtures/ScaleFixture.h"
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010040
41namespace arm_compute
42{
43namespace test
44{
45namespace validation
46{
47namespace
48{
Georgios Pinitas583137c2017-08-31 18:12:42 +010049/** CNN data types */
50const auto ScaleDataTypes = framework::dataset::make("DataType",
51{
52 DataType::U8,
53 DataType::S16,
54 DataType::F16,
55 DataType::F32,
56});
57
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010058/** Tolerance */
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +010059constexpr AbsoluteTolerance<uint8_t> tolerance_u8(1);
60constexpr AbsoluteTolerance<int16_t> tolerance_s16(1);
Diego Lopez Recas00854292018-02-22 13:08:01 +000061constexpr float tolerance_f32_absolute(0.001f);
62
63RelativeTolerance<float> tolerance_f32(0.05);
64RelativeTolerance<half> tolerance_f16(half(0.1));
Moritz Pflanzerff1c3602017-09-22 12:41:25 +010065
66constexpr float tolerance_num_f32(0.01f);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010067} // namespace
68
69TEST_SUITE(CL)
70TEST_SUITE(Scale)
71
Isabella Gottardi553b9992018-09-03 12:17:47 +010072// *INDENT-OFF*
73// clang-format off
74
75DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
76 framework::dataset::make("InputInfo",{ TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F16),
77 TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F32),
78 TensorInfo(TensorShape(36U, 36U, 2U, 4U), 1, DataType::U8),
79 TensorInfo(TensorShape(40U, 35U, 2U, 4U), 1, DataType::S16),
80 TensorInfo(TensorShape(37U, 37U, 2U), 1, DataType::F32), // window shrink
Isabella Gottardi553b9992018-09-03 12:17:47 +010081 TensorInfo(TensorShape(37U, 37U, 3U, 4U), 1, DataType::F32), // mismatching datatype
82 TensorInfo(TensorShape(28U, 33U, 2U), 1, DataType::F32), // policy area, scale factor not correct
83 }),
84 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 68U, 2U), 1, DataType::F16),
85 TensorInfo(TensorShape(40U, 56U, 2U), 1, DataType::F32),
86 TensorInfo(TensorShape(40U, 76U, 2U, 4U), 1, DataType::U8),
87 TensorInfo(TensorShape(28U, 32U, 2U, 4U), 1, DataType::S16),
88 TensorInfo(TensorShape(39U, 55U, 2U), 1, DataType::F32), // window shrink
Isabella Gottardi553b9992018-09-03 12:17:47 +010089 TensorInfo(TensorShape(39U, 77U, 3U, 4U), 1, DataType::F16), // mismatching datatype
90 TensorInfo(TensorShape(26U, 21U, 2U), 1, DataType::F32), // policy area, scale factor not correct
91 })),
92 framework::dataset::make("Policy",{ InterpolationPolicy::BILINEAR,
93 InterpolationPolicy::BILINEAR,
94 InterpolationPolicy::NEAREST_NEIGHBOR,
95 InterpolationPolicy::NEAREST_NEIGHBOR,
96 InterpolationPolicy::NEAREST_NEIGHBOR,
97 InterpolationPolicy::BILINEAR,
Isabella Gottardi553b9992018-09-03 12:17:47 +010098 InterpolationPolicy::AREA,
99 })),
100 framework::dataset::make("BorderMode",{ BorderMode::UNDEFINED,
101 BorderMode::UNDEFINED,
102 BorderMode::UNDEFINED,
103 BorderMode::UNDEFINED,
104 BorderMode::UNDEFINED,
105 BorderMode::UNDEFINED,
106 BorderMode::UNDEFINED,
Isabella Gottardi553b9992018-09-03 12:17:47 +0100107 })),
Michalis Spyrou17220e22018-09-12 13:35:38 +0100108 framework::dataset::make("Expected", { true, true, true, true, false, false, false })),
Isabella Gottardi553b9992018-09-03 12:17:47 +0100109input_info, output_info, policy, border_mode, expected)
110{
111 Status status = CLScale::validate(&input_info.clone()->set_is_resizable(false),
112 &output_info.clone()->set_is_resizable(false), policy, border_mode);
113 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
114}
115
116// clang-format on
117// *INDENT-ON*
118
Michalis Spyrou80943252019-01-10 17:19:50 +0000119DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::MediumShapes(), ScaleDataTypes),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700120 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
121 datasets::BorderModes()),
122 datasets::SamplingPolicies()),
123 shape, data_type, policy, border_mode, sampling_policy)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100124{
125 std::mt19937 generator(library->seed());
126 std::uniform_real_distribution<float> distribution_float(0.25, 2);
127 const float scale_x = distribution_float(generator);
128 const float scale_y = distribution_float(generator);
129 std::uniform_int_distribution<uint8_t> distribution_u8(0, 255);
130 uint8_t constant_border_value = distribution_u8(generator);
131
132 // Create tensors
133 CLTensor src = create_tensor<CLTensor>(shape, data_type);
134 TensorShape shape_scaled(shape);
135 shape_scaled.set(0, shape[0] * scale_x);
136 shape_scaled.set(1, shape[1] * scale_y);
137 CLTensor dst = create_tensor<CLTensor>(shape_scaled, data_type);
138
139 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
140 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
141
142 // Create and configure function
143 CLScale clscale;
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700144 clscale.configure(&src, &dst, policy, border_mode, constant_border_value, sampling_policy);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100145
Daniil Efremov7a49c792017-11-14 21:25:34 +0700146 // Get border size depending on border mode
147 const BorderSize border_size(border_mode == BorderMode::UNDEFINED ? 0 : 1);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100148
Daniil Efremov7a49c792017-11-14 21:25:34 +0700149 // Validate valid region
Diego Lopez Recas00854292018-02-22 13:08:01 +0000150 const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, sampling_policy, (border_mode == BorderMode::UNDEFINED));
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100151 validate(dst.info()->valid_region(), dst_valid_region);
152
153 // Validate padding
154 PaddingCalculator calculator(shape_scaled.x(), 4);
155 calculator.set_border_mode(border_mode);
156
Daniil Efremov7a49c792017-11-14 21:25:34 +0700157 const PaddingSize read_padding(border_size);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100158 const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER);
159 validate(src.info()->padding(), read_padding);
160 validate(dst.info()->padding(), write_padding);
161}
162
163template <typename T>
164using CLScaleFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T>;
165
Georgios Pinitas583137c2017-08-31 18:12:42 +0100166TEST_SUITE(Float)
167TEST_SUITE(FP32)
Michalis Spyrou80943252019-01-10 17:19:50 +0000168FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100169 DataType::F32)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100170 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700171 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
172 datasets::BorderModes()),
173 datasets::SamplingPolicies()))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100174{
175 //Create valid region
176 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000177 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
Georgios Pinitas583137c2017-08-31 18:12:42 +0100178
179 // Validate output
Diego Lopez Recas00854292018-02-22 13:08:01 +0000180 validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100181}
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100182FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
183 DataType::F32)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100184 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700185 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
186 datasets::BorderModes()),
187 datasets::SamplingPolicies()))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100188{
189 //Create valid region
190 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000191 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
Georgios Pinitas583137c2017-08-31 18:12:42 +0100192
193 // Validate output
Diego Lopez Recas00854292018-02-22 13:08:01 +0000194 validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100195}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100196TEST_SUITE_END() // FP32
Georgios Pinitas583137c2017-08-31 18:12:42 +0100197TEST_SUITE(FP16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000198FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100199 DataType::F16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100200 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700201 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
202 datasets::BorderModes()),
203 datasets::SamplingPolicies()))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100204{
205 //Create valid region
206 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000207 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
Georgios Pinitas583137c2017-08-31 18:12:42 +0100208
209 // Validate output
210 validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
211}
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100212FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700213 DataType::F16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100214 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700215 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
216 datasets::BorderModes()),
217 datasets::SamplingPolicies()))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100218{
219 //Create valid region
220 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000221 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
Georgios Pinitas583137c2017-08-31 18:12:42 +0100222
223 // Validate output
224 validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
225}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100226TEST_SUITE_END() // FP16
227TEST_SUITE_END() // Float
Georgios Pinitas583137c2017-08-31 18:12:42 +0100228
229TEST_SUITE(Integer)
230TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +0000231FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100232 DataType::U8)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100233 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700234 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
235 datasets::BorderModes()),
236 datasets::SamplingPolicies()))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100237{
238 //Create valid region
239 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000240 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100241
242 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100243 validate(CLAccessor(_target), _reference, valid_region, tolerance_u8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100244}
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100245FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
246 DataType::U8)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100247 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700248 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
249 datasets::BorderModes()),
250 datasets::SamplingPolicies()))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100251{
252 //Create valid region
253 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000254 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100255
256 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100257 validate(CLAccessor(_target), _reference, valid_region, tolerance_u8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100258}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100259TEST_SUITE_END() // U8
Georgios Pinitas583137c2017-08-31 18:12:42 +0100260TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +0000261FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100262 DataType::S16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100263 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700264 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
265 datasets::BorderModes()),
266 datasets::SamplingPolicies()))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100267{
268 //Create valid region
269 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000270 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
Georgios Pinitas583137c2017-08-31 18:12:42 +0100271
272 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100273 validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100274}
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100275FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700276 DataType::S16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100277 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700278 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
279 datasets::BorderModes()),
280 datasets::SamplingPolicies()))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100281{
282 //Create valid region
283 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000284 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
Georgios Pinitas583137c2017-08-31 18:12:42 +0100285
286 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100287 validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100288}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100289TEST_SUITE_END() // S16
290TEST_SUITE_END() // Integer
Georgios Pinitas583137c2017-08-31 18:12:42 +0100291
Michalis Spyrou17220e22018-09-12 13:35:38 +0100292template <typename T>
293using CLScaleQuantizedFixture = ScaleValidationQuantizedFixture<CLTensor, CLAccessor, CLScale, T>;
294TEST_SUITE(Quantized)
295TEST_SUITE(QASYMM8)
Michalis Spyrou80943252019-01-10 17:19:50 +0000296FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(),
Michalis Spyrou17220e22018-09-12 13:35:38 +0100297 framework::dataset::make("DataType",
298 DataType::QASYMM8)),
299 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
300 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
301 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
302 datasets::BorderModes()),
303 datasets::SamplingPolicies()))
304{
305 //Create valid region
306 TensorInfo src_info(_shape, 1, _data_type);
307 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
308
309 // Validate output
310 validate(CLAccessor(_target), _reference, valid_region, tolerance_u8);
311}
312FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(),
313 framework::dataset::make("DataType",
314 DataType::QASYMM8)),
315 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
316 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
317 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
318 datasets::BorderModes()),
319 datasets::SamplingPolicies()))
320{
321 //Create valid region
322 TensorInfo src_info(_shape, 1, _data_type);
323 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
324
325 // Validate output
326 validate(CLAccessor(_target), _reference, valid_region, tolerance_u8);
327}
328TEST_SUITE_END() // QASYMM8
329TEST_SUITE_END() // Quantized
330
331TEST_SUITE_END() // Scale
332TEST_SUITE_END() // CL
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100333} // namespace validation
334} // namespace test
335} // namespace arm_compute