blob: 848656a8d1f8a03d17a8e65e3a7b63d0b13d467d [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,
Sang-Hoon Park5b7fd872020-01-09 15:27:51 +000062 true,
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000063});
64
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010065/** Tolerance */
Manuel Bottini8481d832019-12-10 15:28:40 +000066constexpr AbsoluteTolerance<uint8_t> tolerance_q8(1);
67constexpr AbsoluteTolerance<int8_t> tolerance_qs8(1);
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +010068constexpr AbsoluteTolerance<int16_t> tolerance_s16(1);
Diego Lopez Recas00854292018-02-22 13:08:01 +000069constexpr float tolerance_f32_absolute(0.001f);
70
71RelativeTolerance<float> tolerance_f32(0.05);
72RelativeTolerance<half> tolerance_f16(half(0.1));
Moritz Pflanzerff1c3602017-09-22 12:41:25 +010073
74constexpr float tolerance_num_f32(0.01f);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010075} // namespace
76
77TEST_SUITE(CL)
78TEST_SUITE(Scale)
79
Isabella Gottardi553b9992018-09-03 12:17:47 +010080// *INDENT-OFF*
81// clang-format off
82
83DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
84 framework::dataset::make("InputInfo",{ TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F16),
85 TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F32),
86 TensorInfo(TensorShape(36U, 36U, 2U, 4U), 1, DataType::U8),
87 TensorInfo(TensorShape(40U, 35U, 2U, 4U), 1, DataType::S16),
88 TensorInfo(TensorShape(37U, 37U, 2U), 1, DataType::F32), // window shrink
Isabella Gottardi553b9992018-09-03 12:17:47 +010089 TensorInfo(TensorShape(37U, 37U, 3U, 4U), 1, DataType::F32), // mismatching datatype
90 TensorInfo(TensorShape(28U, 33U, 2U), 1, DataType::F32), // policy area, scale factor not correct
91 }),
92 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 68U, 2U), 1, DataType::F16),
93 TensorInfo(TensorShape(40U, 56U, 2U), 1, DataType::F32),
94 TensorInfo(TensorShape(40U, 76U, 2U, 4U), 1, DataType::U8),
95 TensorInfo(TensorShape(28U, 32U, 2U, 4U), 1, DataType::S16),
96 TensorInfo(TensorShape(39U, 55U, 2U), 1, DataType::F32), // window shrink
Isabella Gottardi553b9992018-09-03 12:17:47 +010097 TensorInfo(TensorShape(39U, 77U, 3U, 4U), 1, DataType::F16), // mismatching datatype
98 TensorInfo(TensorShape(26U, 21U, 2U), 1, DataType::F32), // policy area, scale factor not correct
99 })),
100 framework::dataset::make("Policy",{ InterpolationPolicy::BILINEAR,
101 InterpolationPolicy::BILINEAR,
102 InterpolationPolicy::NEAREST_NEIGHBOR,
103 InterpolationPolicy::NEAREST_NEIGHBOR,
104 InterpolationPolicy::NEAREST_NEIGHBOR,
105 InterpolationPolicy::BILINEAR,
Isabella Gottardi553b9992018-09-03 12:17:47 +0100106 InterpolationPolicy::AREA,
107 })),
108 framework::dataset::make("BorderMode",{ BorderMode::UNDEFINED,
109 BorderMode::UNDEFINED,
110 BorderMode::UNDEFINED,
111 BorderMode::UNDEFINED,
112 BorderMode::UNDEFINED,
113 BorderMode::UNDEFINED,
114 BorderMode::UNDEFINED,
Isabella Gottardi553b9992018-09-03 12:17:47 +0100115 })),
Michalis Spyrou17220e22018-09-12 13:35:38 +0100116 framework::dataset::make("Expected", { true, true, true, true, false, false, false })),
Isabella Gottardi553b9992018-09-03 12:17:47 +0100117input_info, output_info, policy, border_mode, expected)
118{
119 Status status = CLScale::validate(&input_info.clone()->set_is_resizable(false),
120 &output_info.clone()->set_is_resizable(false), policy, border_mode);
121 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
122}
123
124// clang-format on
125// *INDENT-ON*
126
Michalis Spyrou80943252019-01-10 17:19:50 +0000127DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::MediumShapes(), ScaleDataTypes),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700128 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
129 datasets::BorderModes()),
130 datasets::SamplingPolicies()),
131 shape, data_type, policy, border_mode, sampling_policy)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100132{
133 std::mt19937 generator(library->seed());
134 std::uniform_real_distribution<float> distribution_float(0.25, 2);
135 const float scale_x = distribution_float(generator);
136 const float scale_y = distribution_float(generator);
137 std::uniform_int_distribution<uint8_t> distribution_u8(0, 255);
138 uint8_t constant_border_value = distribution_u8(generator);
139
140 // Create tensors
141 CLTensor src = create_tensor<CLTensor>(shape, data_type);
142 TensorShape shape_scaled(shape);
143 shape_scaled.set(0, shape[0] * scale_x);
144 shape_scaled.set(1, shape[1] * scale_y);
145 CLTensor dst = create_tensor<CLTensor>(shape_scaled, data_type);
146
147 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
148 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
149
150 // Create and configure function
151 CLScale clscale;
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700152 clscale.configure(&src, &dst, policy, border_mode, constant_border_value, sampling_policy);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100153
Daniil Efremov7a49c792017-11-14 21:25:34 +0700154 // Get border size depending on border mode
155 const BorderSize border_size(border_mode == BorderMode::UNDEFINED ? 0 : 1);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100156
Daniil Efremov7a49c792017-11-14 21:25:34 +0700157 // Validate valid region
Diego Lopez Recas00854292018-02-22 13:08:01 +0000158 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 +0100159 validate(dst.info()->valid_region(), dst_valid_region);
160
161 // Validate padding
162 PaddingCalculator calculator(shape_scaled.x(), 4);
163 calculator.set_border_mode(border_mode);
164
Daniil Efremov7a49c792017-11-14 21:25:34 +0700165 const PaddingSize read_padding(border_size);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100166 const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER);
167 validate(src.info()->padding(), read_padding);
168 validate(dst.info()->padding(), write_padding);
169}
170
171template <typename T>
172using CLScaleFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T>;
173
Georgios Pinitas583137c2017-08-31 18:12:42 +0100174TEST_SUITE(Float)
175TEST_SUITE(FP32)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000176FIXTURE_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 +0100177 DataType::F32)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100178 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000179 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
180 datasets::BorderModes()),
181 datasets::SamplingPolicies()),
182 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100183{
184 //Create valid region
185 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000186 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 +0100187
188 // Validate output
Diego Lopez Recas00854292018-02-22 13:08:01 +0000189 validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100190}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000191FIXTURE_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 +0100192 DataType::F32)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100193 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700194 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000195 datasets::BorderModes()),
196 datasets::SamplingPolicies()),
197 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100198{
199 //Create valid region
200 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000201 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 +0100202
203 // Validate output
Diego Lopez Recas00854292018-02-22 13:08:01 +0000204 validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100205}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100206TEST_SUITE_END() // FP32
Georgios Pinitas583137c2017-08-31 18:12:42 +0100207TEST_SUITE(FP16)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000208FIXTURE_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 +0100209 DataType::F16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100210 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000211 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
212 datasets::BorderModes()),
213 datasets::SamplingPolicies()),
214 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100215{
216 //Create valid region
217 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000218 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 +0100219
220 // Validate output
221 validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
222}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000223FIXTURE_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 +0700224 DataType::F16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100225 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000226 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
227 datasets::BorderModes()),
228 datasets::SamplingPolicies()),
229 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100230{
231 //Create valid region
232 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000233 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 +0100234
235 // Validate output
236 validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
237}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100238TEST_SUITE_END() // FP16
239TEST_SUITE_END() // Float
Georgios Pinitas583137c2017-08-31 18:12:42 +0100240
241TEST_SUITE(Integer)
242TEST_SUITE(U8)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000243FIXTURE_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 +0100244 DataType::U8)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100245 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000246 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
247 datasets::BorderModes()),
248 datasets::SamplingPolicies()),
249 AlignCorners))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100250{
251 //Create valid region
252 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000253 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 +0100254
255 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000256 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100257}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000258FIXTURE_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 +0100259 DataType::U8)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100260 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700261 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000262 datasets::BorderModes()),
263 datasets::SamplingPolicies()),
264 AlignCorners))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100265{
266 //Create valid region
267 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000268 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 +0100269
270 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000271 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100272}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100273TEST_SUITE_END() // U8
Georgios Pinitas583137c2017-08-31 18:12:42 +0100274TEST_SUITE(S16)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000275FIXTURE_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 +0100276 DataType::S16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100277 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000278 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
279 datasets::BorderModes()),
280 datasets::SamplingPolicies()),
281 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100282{
283 //Create valid region
284 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000285 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 +0100286
287 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100288 validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100289}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000290FIXTURE_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 +0700291 DataType::S16)),
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100292 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700293 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000294 datasets::BorderModes()),
295 datasets::SamplingPolicies()),
296 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100297{
298 //Create valid region
299 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000300 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 +0100301
302 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100303 validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100304}
Michalis Spyrou17220e22018-09-12 13:35:38 +0100305TEST_SUITE_END() // S16
306TEST_SUITE_END() // Integer
Georgios Pinitas583137c2017-08-31 18:12:42 +0100307
Michalis Spyrou17220e22018-09-12 13:35:38 +0100308template <typename T>
309using CLScaleQuantizedFixture = ScaleValidationQuantizedFixture<CLTensor, CLAccessor, CLScale, T>;
310TEST_SUITE(Quantized)
311TEST_SUITE(QASYMM8)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000312FIXTURE_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 +0100313 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 })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000318 datasets::BorderModes()),
319 datasets::SamplingPolicies()),
320 AlignCorners))
Michalis Spyrou17220e22018-09-12 13:35:38 +0100321{
322 //Create valid region
323 TensorInfo src_info(_shape, 1, _data_type);
324 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
325
326 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000327 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Michalis Spyrou17220e22018-09-12 13:35:38 +0100328}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000329FIXTURE_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 +0100330 framework::dataset::make("DataType",
331 DataType::QASYMM8)),
332 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
333 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
334 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
335 datasets::BorderModes()),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000336 datasets::SamplingPolicies()),
337 AlignCorners))
Michalis Spyrou17220e22018-09-12 13:35:38 +0100338{
339 //Create valid region
340 TensorInfo src_info(_shape, 1, _data_type);
341 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
342
343 // Validate output
Manuel Bottini8481d832019-12-10 15:28:40 +0000344 validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
Michalis Spyrou17220e22018-09-12 13:35:38 +0100345}
346TEST_SUITE_END() // QASYMM8
Manuel Bottini8481d832019-12-10 15:28:40 +0000347TEST_SUITE(QASYMM8_SIGNED)
morgolockdceacdc2020-01-09 15:16:05 +0000348FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(),
Manuel Bottini8481d832019-12-10 15:28:40 +0000349 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
350 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
351 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
352 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
morgolockdceacdc2020-01-09 15:16:05 +0000353 datasets::BorderModes()),
354 datasets::SamplingPolicies()),
355 AlignCorners))
Manuel Bottini8481d832019-12-10 15:28:40 +0000356{
357 //Create valid region
358 TensorInfo src_info(_shape, 1, _data_type);
359 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
360
361 // Validate output
362 validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
363}
morgolockdceacdc2020-01-09 15:16:05 +0000364FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(combine(datasets::LargeShapes(),
Manuel Bottini8481d832019-12-10 15:28:40 +0000365 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
366 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })),
367 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
368 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
369 datasets::BorderModes()),
morgolockdceacdc2020-01-09 15:16:05 +0000370 datasets::SamplingPolicies()),
371 AlignCorners))
Manuel Bottini8481d832019-12-10 15:28:40 +0000372{
373 //Create valid region
374 TensorInfo src_info(_shape, 1, _data_type);
375 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
376
377 // Validate output
378 validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
379}
380TEST_SUITE_END() // QASYMM8_SIGNED
Michalis Spyrou17220e22018-09-12 13:35:38 +0100381TEST_SUITE_END() // Quantized
382
383TEST_SUITE_END() // Scale
384TEST_SUITE_END() // CL
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100385} // namespace validation
386} // namespace test
387} // namespace arm_compute