blob: e06c8f5ae673d85f6ec87120bf80402480ccee4d [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 Parkbb123bd2020-01-03 10:57:30 +000058/** Align corners, this functionality is supported only by NEON */
59const auto AlignCorners = framework::dataset::make("AlignCorners",
60{
61 false,
62});
63
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010064/** Tolerance */
Manuel Bottini8481d832019-12-10 15:28:40 +000065constexpr AbsoluteTolerance<uint8_t> tolerance_q8(1);
66constexpr AbsoluteTolerance<int8_t> tolerance_qs8(1);
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +010067constexpr AbsoluteTolerance<int16_t> tolerance_s16(1);
Diego Lopez Recas00854292018-02-22 13:08:01 +000068constexpr float tolerance_f32_absolute(0.001f);
69
70RelativeTolerance<float> tolerance_f32(0.05);
71RelativeTolerance<half> tolerance_f16(half(0.1));
Moritz Pflanzerff1c3602017-09-22 12:41:25 +010072
73constexpr float tolerance_num_f32(0.01f);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010074} // namespace
75
76TEST_SUITE(CL)
77TEST_SUITE(Scale)
78
Isabella Gottardi553b9992018-09-03 12:17:47 +010079// *INDENT-OFF*
80// clang-format off
81
82DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
83 framework::dataset::make("InputInfo",{ TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F16),
84 TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F32),
85 TensorInfo(TensorShape(36U, 36U, 2U, 4U), 1, DataType::U8),
86 TensorInfo(TensorShape(40U, 35U, 2U, 4U), 1, DataType::S16),
87 TensorInfo(TensorShape(37U, 37U, 2U), 1, DataType::F32), // window shrink
Isabella Gottardi553b9992018-09-03 12:17:47 +010088 TensorInfo(TensorShape(37U, 37U, 3U, 4U), 1, DataType::F32), // mismatching datatype
89 TensorInfo(TensorShape(28U, 33U, 2U), 1, DataType::F32), // policy area, scale factor not correct
90 }),
91 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 68U, 2U), 1, DataType::F16),
92 TensorInfo(TensorShape(40U, 56U, 2U), 1, DataType::F32),
93 TensorInfo(TensorShape(40U, 76U, 2U, 4U), 1, DataType::U8),
94 TensorInfo(TensorShape(28U, 32U, 2U, 4U), 1, DataType::S16),
95 TensorInfo(TensorShape(39U, 55U, 2U), 1, DataType::F32), // window shrink
Isabella Gottardi553b9992018-09-03 12:17:47 +010096 TensorInfo(TensorShape(39U, 77U, 3U, 4U), 1, DataType::F16), // mismatching datatype
97 TensorInfo(TensorShape(26U, 21U, 2U), 1, DataType::F32), // policy area, scale factor not correct
98 })),
99 framework::dataset::make("Policy",{ InterpolationPolicy::BILINEAR,
100 InterpolationPolicy::BILINEAR,
101 InterpolationPolicy::NEAREST_NEIGHBOR,
102 InterpolationPolicy::NEAREST_NEIGHBOR,
103 InterpolationPolicy::NEAREST_NEIGHBOR,
104 InterpolationPolicy::BILINEAR,
Isabella Gottardi553b9992018-09-03 12:17:47 +0100105 InterpolationPolicy::AREA,
106 })),
107 framework::dataset::make("BorderMode",{ BorderMode::UNDEFINED,
108 BorderMode::UNDEFINED,
109 BorderMode::UNDEFINED,
110 BorderMode::UNDEFINED,
111 BorderMode::UNDEFINED,
112 BorderMode::UNDEFINED,
113 BorderMode::UNDEFINED,
Isabella Gottardi553b9992018-09-03 12:17:47 +0100114 })),
Michalis Spyrou17220e22018-09-12 13:35:38 +0100115 framework::dataset::make("Expected", { true, true, true, true, false, false, false })),
Isabella Gottardi553b9992018-09-03 12:17:47 +0100116input_info, output_info, policy, border_mode, expected)
117{
118 Status status = CLScale::validate(&input_info.clone()->set_is_resizable(false),
119 &output_info.clone()->set_is_resizable(false), policy, border_mode);
120 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
121}
122
123// clang-format on
124// *INDENT-ON*
125
Michalis Spyrou80943252019-01-10 17:19:50 +0000126DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::MediumShapes(), ScaleDataTypes),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700127 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
128 datasets::BorderModes()),
129 datasets::SamplingPolicies()),
130 shape, data_type, policy, border_mode, sampling_policy)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100131{
132 std::mt19937 generator(library->seed());
133 std::uniform_real_distribution<float> distribution_float(0.25, 2);
134 const float scale_x = distribution_float(generator);
135 const float scale_y = distribution_float(generator);
136 std::uniform_int_distribution<uint8_t> distribution_u8(0, 255);
137 uint8_t constant_border_value = distribution_u8(generator);
138
139 // Create tensors
140 CLTensor src = create_tensor<CLTensor>(shape, data_type);
141 TensorShape shape_scaled(shape);
142 shape_scaled.set(0, shape[0] * scale_x);
143 shape_scaled.set(1, shape[1] * scale_y);
144 CLTensor dst = create_tensor<CLTensor>(shape_scaled, data_type);
145
146 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
147 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
148
149 // Create and configure function
150 CLScale clscale;
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700151 clscale.configure(&src, &dst, policy, border_mode, constant_border_value, sampling_policy);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100152
Daniil Efremov7a49c792017-11-14 21:25:34 +0700153 // Get border size depending on border mode
154 const BorderSize border_size(border_mode == BorderMode::UNDEFINED ? 0 : 1);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100155
Daniil Efremov7a49c792017-11-14 21:25:34 +0700156 // Validate valid region
Diego Lopez Recas00854292018-02-22 13:08:01 +0000157 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 +0100158 validate(dst.info()->valid_region(), dst_valid_region);
159
160 // Validate padding
161 PaddingCalculator calculator(shape_scaled.x(), 4);
162 calculator.set_border_mode(border_mode);
163
Daniil Efremov7a49c792017-11-14 21:25:34 +0700164 const PaddingSize read_padding(border_size);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100165 const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER);
166 validate(src.info()->padding(), read_padding);
167 validate(dst.info()->padding(), write_padding);
168}
169
170template <typename T>
171using CLScaleFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T>;
172
Georgios Pinitas583137c2017-08-31 18:12:42 +0100173TEST_SUITE(Float)
174TEST_SUITE(FP32)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000175FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100176 DataType::F32)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100177 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000178 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
179 datasets::BorderModes()),
180 datasets::SamplingPolicies()),
181 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100182{
183 //Create valid region
184 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000185 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 +0100186
187 // Validate output
Diego Lopez Recas00854292018-02-22 13:08:01 +0000188 validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100189}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000190FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100191 DataType::F32)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100192 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700193 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000194 datasets::BorderModes()),
195 datasets::SamplingPolicies()),
196 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100197{
198 //Create valid region
199 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000200 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 +0100201
202 // Validate output
Diego Lopez Recas00854292018-02-22 13:08:01 +0000203 validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100204}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100205TEST_SUITE_END() // FP32
Georgios Pinitas583137c2017-08-31 18:12:42 +0100206TEST_SUITE(FP16)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000207FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100208 DataType::F16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100209 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000210 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
211 datasets::BorderModes()),
212 datasets::SamplingPolicies()),
213 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100214{
215 //Create valid region
216 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000217 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 +0100218
219 // Validate output
220 validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
221}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000222FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700223 DataType::F16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100224 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000225 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
226 datasets::BorderModes()),
227 datasets::SamplingPolicies()),
228 AlignCorners))
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
235 validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
236}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100237TEST_SUITE_END() // FP16
238TEST_SUITE_END() // Float
Georgios Pinitas583137c2017-08-31 18:12:42 +0100239
240TEST_SUITE(Integer)
241TEST_SUITE(U8)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000242FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100243 DataType::U8)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100244 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000245 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
246 datasets::BorderModes()),
247 datasets::SamplingPolicies()),
248 AlignCorners))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100249{
250 //Create valid region
251 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000252 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 +0100253
254 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000255 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100256}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000257FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100258 DataType::U8)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100259 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700260 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000261 datasets::BorderModes()),
262 datasets::SamplingPolicies()),
263 AlignCorners))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100264{
265 //Create valid region
266 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000267 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 +0100268
269 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000270 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100271}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100272TEST_SUITE_END() // U8
Georgios Pinitas583137c2017-08-31 18:12:42 +0100273TEST_SUITE(S16)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000274FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100275 DataType::S16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100276 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000277 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
278 datasets::BorderModes()),
279 datasets::SamplingPolicies()),
280 AlignCorners))
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}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000289FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700290 DataType::S16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100291 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700292 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000293 datasets::BorderModes()),
294 datasets::SamplingPolicies()),
295 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100296{
297 //Create valid region
298 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000299 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 +0100300
301 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100302 validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100303}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100304TEST_SUITE_END() // S16
305TEST_SUITE_END() // Integer
Georgios Pinitas583137c2017-08-31 18:12:42 +0100306
Michalis Spyrou17220e22018-09-12 13:35:38 +0100307template <typename T>
308using CLScaleQuantizedFixture = ScaleValidationQuantizedFixture<CLTensor, CLAccessor, CLScale, T>;
309TEST_SUITE(Quantized)
310TEST_SUITE(QASYMM8)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000311FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(),
Michalis Spyrou17220e22018-09-12 13:35:38 +0100312 framework::dataset::make("DataType",
313 DataType::QASYMM8)),
314 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
315 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
316 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000317 datasets::BorderModes()),
318 datasets::SamplingPolicies()),
319 AlignCorners))
Michalis Spyrou17220e22018-09-12 13:35:38 +0100320{
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
Manuel Bottini8481d832019-12-10 15:28:40 +0000326 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Michalis Spyrou17220e22018-09-12 13:35:38 +0100327}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000328FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(combine(datasets::LargeShapes(),
Michalis Spyrou17220e22018-09-12 13:35:38 +0100329 framework::dataset::make("DataType",
330 DataType::QASYMM8)),
331 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
332 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
333 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
334 datasets::BorderModes()),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000335 datasets::SamplingPolicies()),
336 AlignCorners))
Michalis Spyrou17220e22018-09-12 13:35:38 +0100337{
338 //Create valid region
339 TensorInfo src_info(_shape, 1, _data_type);
340 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
341
342 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000343 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Michalis Spyrou17220e22018-09-12 13:35:38 +0100344}
345TEST_SUITE_END() // QASYMM8
Manuel Bottini8481d832019-12-10 15:28:40 +0000346TEST_SUITE(QASYMM8_SIGNED)
347FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(),
348 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
349 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
350 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
351 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
352 datasets::BorderModes()),
353 datasets::SamplingPolicies()))
354{
355 //Create valid region
356 TensorInfo src_info(_shape, 1, _data_type);
357 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
358
359 // Validate output
360 validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
361}
362FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(),
363 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
364 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
365 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
366 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
367 datasets::BorderModes()),
368 datasets::SamplingPolicies()))
369{
370 //Create valid region
371 TensorInfo src_info(_shape, 1, _data_type);
372 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
373
374 // Validate output
375 validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
376}
377TEST_SUITE_END() // QASYMM8_SIGNED
Michalis Spyrou17220e22018-09-12 13:35:38 +0100378TEST_SUITE_END() // Quantized
379
380TEST_SUITE_END() // Scale
381TEST_SUITE_END() // CL
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100382} // namespace validation
383} // namespace test
384} // namespace arm_compute