blob: d1c0d5ddf1ec282978bd4bb5f0c8effabdef6b16 [file] [log] [blame]
Isabella Gottardi1fab09f2017-07-13 15:55:57 +01001/*
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +00002 * Copyright (c) 2017-2020 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
Sang-Hoon Parkf025a772020-05-26 11:11:32 +010058/** Sampling policy data set */
59const auto SamplingPolicySet = combine(datasets::SamplingPolicies(),
60 framework::dataset::make("AlignCorners", { false }));
61
62/** Sampling policy data set for Aligned Corners which only allows TOP_LEFT poicy.*/
63const auto AlignCornersSamplingPolicySet = combine(framework::dataset::make("SamplingPolicy",
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000064{
Sang-Hoon Parkf025a772020-05-26 11:11:32 +010065 SamplingPolicy::TOP_LEFT,
66}),
67framework::dataset::make("AlignCorners", { true }));
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000068
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010069/** Tolerance */
Manuel Bottini8481d832019-12-10 15:28:40 +000070constexpr AbsoluteTolerance<uint8_t> tolerance_q8(1);
71constexpr AbsoluteTolerance<int8_t> tolerance_qs8(1);
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +010072constexpr AbsoluteTolerance<int16_t> tolerance_s16(1);
Diego Lopez Recas00854292018-02-22 13:08:01 +000073constexpr float tolerance_f32_absolute(0.001f);
74
75RelativeTolerance<float> tolerance_f32(0.05);
76RelativeTolerance<half> tolerance_f16(half(0.1));
Moritz Pflanzerff1c3602017-09-22 12:41:25 +010077
78constexpr float tolerance_num_f32(0.01f);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010079} // namespace
80
81TEST_SUITE(CL)
82TEST_SUITE(Scale)
83
Isabella Gottardi553b9992018-09-03 12:17:47 +010084// *INDENT-OFF*
85// clang-format off
86
87DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
88 framework::dataset::make("InputInfo",{ TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F16),
89 TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F32),
90 TensorInfo(TensorShape(36U, 36U, 2U, 4U), 1, DataType::U8),
91 TensorInfo(TensorShape(40U, 35U, 2U, 4U), 1, DataType::S16),
92 TensorInfo(TensorShape(37U, 37U, 2U), 1, DataType::F32), // window shrink
Isabella Gottardi553b9992018-09-03 12:17:47 +010093 TensorInfo(TensorShape(37U, 37U, 3U, 4U), 1, DataType::F32), // mismatching datatype
94 TensorInfo(TensorShape(28U, 33U, 2U), 1, DataType::F32), // policy area, scale factor not correct
95 }),
96 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 68U, 2U), 1, DataType::F16),
97 TensorInfo(TensorShape(40U, 56U, 2U), 1, DataType::F32),
98 TensorInfo(TensorShape(40U, 76U, 2U, 4U), 1, DataType::U8),
99 TensorInfo(TensorShape(28U, 32U, 2U, 4U), 1, DataType::S16),
100 TensorInfo(TensorShape(39U, 55U, 2U), 1, DataType::F32), // window shrink
Isabella Gottardi553b9992018-09-03 12:17:47 +0100101 TensorInfo(TensorShape(39U, 77U, 3U, 4U), 1, DataType::F16), // mismatching datatype
102 TensorInfo(TensorShape(26U, 21U, 2U), 1, DataType::F32), // policy area, scale factor not correct
103 })),
104 framework::dataset::make("Policy",{ InterpolationPolicy::BILINEAR,
105 InterpolationPolicy::BILINEAR,
106 InterpolationPolicy::NEAREST_NEIGHBOR,
107 InterpolationPolicy::NEAREST_NEIGHBOR,
108 InterpolationPolicy::NEAREST_NEIGHBOR,
109 InterpolationPolicy::BILINEAR,
Isabella Gottardi553b9992018-09-03 12:17:47 +0100110 InterpolationPolicy::AREA,
111 })),
112 framework::dataset::make("BorderMode",{ BorderMode::UNDEFINED,
113 BorderMode::UNDEFINED,
114 BorderMode::UNDEFINED,
115 BorderMode::UNDEFINED,
116 BorderMode::UNDEFINED,
117 BorderMode::UNDEFINED,
118 BorderMode::UNDEFINED,
Isabella Gottardi553b9992018-09-03 12:17:47 +0100119 })),
Michalis Spyrou17220e22018-09-12 13:35:38 +0100120 framework::dataset::make("Expected", { true, true, true, true, false, false, false })),
Isabella Gottardi553b9992018-09-03 12:17:47 +0100121input_info, output_info, policy, border_mode, expected)
122{
123 Status status = CLScale::validate(&input_info.clone()->set_is_resizable(false),
124 &output_info.clone()->set_is_resizable(false), policy, border_mode);
125 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
126}
127
128// clang-format on
129// *INDENT-ON*
130
Michalis Spyrou80943252019-01-10 17:19:50 +0000131DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::MediumShapes(), ScaleDataTypes),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700132 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
133 datasets::BorderModes()),
134 datasets::SamplingPolicies()),
135 shape, data_type, policy, border_mode, sampling_policy)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100136{
137 std::mt19937 generator(library->seed());
138 std::uniform_real_distribution<float> distribution_float(0.25, 2);
139 const float scale_x = distribution_float(generator);
140 const float scale_y = distribution_float(generator);
141 std::uniform_int_distribution<uint8_t> distribution_u8(0, 255);
142 uint8_t constant_border_value = distribution_u8(generator);
143
144 // Create tensors
145 CLTensor src = create_tensor<CLTensor>(shape, data_type);
146 TensorShape shape_scaled(shape);
147 shape_scaled.set(0, shape[0] * scale_x);
148 shape_scaled.set(1, shape[1] * scale_y);
149 CLTensor dst = create_tensor<CLTensor>(shape_scaled, data_type);
150
151 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
152 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
153
154 // Create and configure function
155 CLScale clscale;
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700156 clscale.configure(&src, &dst, policy, border_mode, constant_border_value, sampling_policy);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100157
Daniil Efremov7a49c792017-11-14 21:25:34 +0700158 // Get border size depending on border mode
159 const BorderSize border_size(border_mode == BorderMode::UNDEFINED ? 0 : 1);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100160
Daniil Efremov7a49c792017-11-14 21:25:34 +0700161 // Validate valid region
Diego Lopez Recas00854292018-02-22 13:08:01 +0000162 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 +0100163 validate(dst.info()->valid_region(), dst_valid_region);
164
165 // Validate padding
166 PaddingCalculator calculator(shape_scaled.x(), 4);
167 calculator.set_border_mode(border_mode);
168
Daniil Efremov7a49c792017-11-14 21:25:34 +0700169 const PaddingSize read_padding(border_size);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100170 const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER);
171 validate(src.info()->padding(), read_padding);
172 validate(dst.info()->padding(), write_padding);
173}
174
175template <typename T>
176using CLScaleFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T>;
177
Georgios Pinitas583137c2017-08-31 18:12:42 +0100178TEST_SUITE(Float)
179TEST_SUITE(FP32)
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100180FIXTURE_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 +0100181 DataType::F32)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100182 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100183 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
184 datasets::BorderModes()),
185 SamplingPolicySet))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100186{
187 //Create valid region
188 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000189 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 +0100190
191 // Validate output
Diego Lopez Recas00854292018-02-22 13:08:01 +0000192 validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100193}
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100194FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100195 DataType::F32)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100196 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700197 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000198 datasets::BorderModes()),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100199 AlignCornersSamplingPolicySet))
200{
201 //Create valid region
202 TensorInfo src_info(_shape, 1, _data_type);
203 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
204
205 // Validate output
206 validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
207}
208FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
209 DataType::F32)),
210 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
211 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
212 datasets::BorderModes()),
213 SamplingPolicySet))
214{
215 //Create valid region
216 TensorInfo src_info(_shape, 1, _data_type);
217 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
218
219 // Validate output
220 validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
221}
222FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(),
223 framework::dataset::make("DataType",
224 DataType::F32)),
225 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
226 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
227 datasets::BorderModes()),
228 AlignCornersSamplingPolicySet))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100229{
230 //Create valid region
231 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000232 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 +0100233
234 // Validate output
Diego Lopez Recas00854292018-02-22 13:08:01 +0000235 validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100236}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100237TEST_SUITE_END() // FP32
Georgios Pinitas583137c2017-08-31 18:12:42 +0100238TEST_SUITE(FP16)
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100239FIXTURE_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 +0100240 DataType::F16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100241 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100242 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
243 datasets::BorderModes()),
244 SamplingPolicySet))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100245{
246 //Create valid region
247 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000248 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 +0100249
250 // Validate output
251 validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
252}
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100253FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700254 DataType::F16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100255 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000256 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
257 datasets::BorderModes()),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100258 AlignCornersSamplingPolicySet))
259{
260 //Create valid region
261 TensorInfo src_info(_shape, 1, _data_type);
262 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
263
264 // Validate output
265 validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
266}
267FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
268 DataType::F16)),
269 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
270 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
271 datasets::BorderModes()),
272 SamplingPolicySet))
273{
274 //Create valid region
275 TensorInfo src_info(_shape, 1, _data_type);
276 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
277
278 // Validate output
279 validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
280}
281FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(),
282 framework::dataset::make("DataType",
283 DataType::F16)),
284 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
285 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
286 datasets::BorderModes()),
287 AlignCornersSamplingPolicySet))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100288{
289 //Create valid region
290 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000291 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 +0100292
293 // Validate output
294 validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
295}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100296TEST_SUITE_END() // FP16
297TEST_SUITE_END() // Float
Georgios Pinitas583137c2017-08-31 18:12:42 +0100298
299TEST_SUITE(Integer)
300TEST_SUITE(U8)
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100301FIXTURE_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 +0100302 DataType::U8)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100303 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100304 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
305 datasets::BorderModes()),
306 SamplingPolicySet))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100307{
308 //Create valid region
309 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000310 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 +0100311
312 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000313 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100314}
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100315FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(),
316 framework::dataset::make("DataType",
317 DataType::U8)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100318 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700319 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000320 datasets::BorderModes()),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100321 AlignCornersSamplingPolicySet))
322{
323 //Create valid region
324 TensorInfo src_info(_shape, 1, _data_type);
325 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
326
327 // Validate output
328 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
329}
330FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
331 DataType::U8)),
332 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
333 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
334 datasets::BorderModes()),
335 SamplingPolicySet))
336{
337 //Create valid region
338 TensorInfo src_info(_shape, 1, _data_type);
339 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
340
341 // Validate output
342 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
343}
344FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(),
345 framework::dataset::make("DataType",
346 DataType::U8)),
347 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
348 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
349 datasets::BorderModes()),
350 AlignCornersSamplingPolicySet))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100351{
352 //Create valid region
353 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000354 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 +0100355
356 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000357 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100358}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100359TEST_SUITE_END() // U8
Georgios Pinitas583137c2017-08-31 18:12:42 +0100360TEST_SUITE(S16)
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100361FIXTURE_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 +0100362 DataType::S16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100363 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100364 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
365 datasets::BorderModes()),
366 SamplingPolicySet))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100367{
368 //Create valid region
369 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000370 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 +0100371
372 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100373 validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100374}
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100375FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(),
376 framework::dataset::make("DataType",
377 DataType::S16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100378 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700379 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000380 datasets::BorderModes()),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100381 AlignCornersSamplingPolicySet))
382{
383 //Create valid region
384 TensorInfo src_info(_shape, 1, _data_type);
385 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
386
387 // Validate output
388 validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
389}
390FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
391 DataType::S16)),
392 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
393 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
394 datasets::BorderModes()),
395 SamplingPolicySet))
396{
397 //Create valid region
398 TensorInfo src_info(_shape, 1, _data_type);
399 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
400
401 // Validate output
402 validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
403}
404FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(),
405 framework::dataset::make("DataType",
406 DataType::S16)),
407 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
408 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
409 datasets::BorderModes()),
410 AlignCornersSamplingPolicySet))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100411{
412 //Create valid region
413 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000414 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 +0100415
416 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100417 validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100418}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100419TEST_SUITE_END() // S16
420TEST_SUITE_END() // Integer
Georgios Pinitas583137c2017-08-31 18:12:42 +0100421
Michalis Spyrou17220e22018-09-12 13:35:38 +0100422template <typename T>
423using CLScaleQuantizedFixture = ScaleValidationQuantizedFixture<CLTensor, CLAccessor, CLScale, T>;
424TEST_SUITE(Quantized)
425TEST_SUITE(QASYMM8)
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100426FIXTURE_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 +0100427 framework::dataset::make("DataType",
428 DataType::QASYMM8)),
429 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
430 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
431 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100432 datasets::BorderModes()),
433 SamplingPolicySet))
Michalis Spyrou17220e22018-09-12 13:35:38 +0100434{
435 //Create valid region
436 TensorInfo src_info(_shape, 1, _data_type);
437 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
438
439 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000440 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Michalis Spyrou17220e22018-09-12 13:35:38 +0100441}
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100442FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(),
Michalis Spyrou17220e22018-09-12 13:35:38 +0100443 framework::dataset::make("DataType",
444 DataType::QASYMM8)),
445 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
446 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
447 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
448 datasets::BorderModes()),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100449 AlignCornersSamplingPolicySet))
450{
451 //Create valid region
452 TensorInfo src_info(_shape, 1, _data_type);
453 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
454
455 // Validate output
456 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
457}
458FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(),
459 framework::dataset::make("DataType",
460 DataType::QASYMM8)),
461 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
462 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
463 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
464 datasets::BorderModes()),
465 SamplingPolicySet))
466{
467 //Create valid region
468 TensorInfo src_info(_shape, 1, _data_type);
469 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
470
471 // Validate output
472 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
473}
474FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(),
475 framework::dataset::make("DataType",
476 DataType::QASYMM8)),
477 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
478 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
479 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
480 datasets::BorderModes()),
481 AlignCornersSamplingPolicySet))
Michalis Spyrou17220e22018-09-12 13:35:38 +0100482{
483 //Create valid region
484 TensorInfo src_info(_shape, 1, _data_type);
485 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
486
487 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000488 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Michalis Spyrou17220e22018-09-12 13:35:38 +0100489}
490TEST_SUITE_END() // QASYMM8
Manuel Bottini8481d832019-12-10 15:28:40 +0000491TEST_SUITE(QASYMM8_SIGNED)
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100492FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(),
Manuel Bottini8481d832019-12-10 15:28:40 +0000493 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
494 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
495 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
496 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100497 datasets::BorderModes()),
498 SamplingPolicySet))
Manuel Bottini8481d832019-12-10 15:28:40 +0000499{
500 //Create valid region
501 TensorInfo src_info(_shape, 1, _data_type);
502 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
503
504 // Validate output
505 validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
506}
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100507FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(),
Manuel Bottini8481d832019-12-10 15:28:40 +0000508 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
509 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
510 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
511 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
512 datasets::BorderModes()),
Sang-Hoon Parkf025a772020-05-26 11:11:32 +0100513 AlignCornersSamplingPolicySet))
514{
515 //Create valid region
516 TensorInfo src_info(_shape, 1, _data_type);
517 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
518
519 // Validate output
520 validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
521}
522FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(),
523 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
524 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
525 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
526 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
527 datasets::BorderModes()),
528 SamplingPolicySet))
529{
530 //Create valid region
531 TensorInfo src_info(_shape, 1, _data_type);
532 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
533
534 // Validate output
535 validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
536}
537FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(),
538 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
539 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
540 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
541 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
542 datasets::BorderModes()),
543 AlignCornersSamplingPolicySet))
Manuel Bottini8481d832019-12-10 15:28:40 +0000544{
545 //Create valid region
546 TensorInfo src_info(_shape, 1, _data_type);
547 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
548
549 // Validate output
550 validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
551}
552TEST_SUITE_END() // QASYMM8_SIGNED
Michalis Spyrou17220e22018-09-12 13:35:38 +0100553TEST_SUITE_END() // Quantized
554
555TEST_SUITE_END() // Scale
556TEST_SUITE_END() // CL
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100557} // namespace validation
558} // namespace test
559} // namespace arm_compute