blob: ce1b249f888ee4e9cc559fb8d530252d7620b912 [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/NEON/functions/NEScale.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/NEON/Accessor.h"
30#include "tests/PaddingCalculator.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010031#include "tests/datasets/BorderModeDataset.h"
32#include "tests/datasets/InterpolationPolicyDataset.h"
Daniil Efremov02bf80d2017-11-22 00:26:51 +070033#include "tests/datasets/SamplingPolicyDataset.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010034#include "tests/datasets/ShapeDatasets.h"
35#include "tests/framework/Asserts.h"
36#include "tests/framework/Macros.h"
37#include "tests/framework/datasets/Datasets.h"
38#include "tests/validation/Helpers.h"
39#include "tests/validation/Validation.h"
40#include "tests/validation/fixtures/ScaleFixture.h"
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010041
42namespace arm_compute
43{
44namespace test
45{
46namespace validation
47{
Isabella Gottardi732f3682017-09-05 14:10:12 +010048namespace
49{
Georgios Pinitas583137c2017-08-31 18:12:42 +010050/** Scale data types */
51const auto ScaleDataTypes = framework::dataset::make("DataType",
52{
53 DataType::U8,
54 DataType::S16,
55 DataType::F32,
56});
57
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010058/** Scale data types */
59const auto ScaleDataLayouts = framework::dataset::make("DataLayout",
60{
61 DataLayout::NCHW,
62 DataLayout::NHWC,
63});
64
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000065/** Align corners */
66const auto AlignCorners = framework::dataset::make("AlignCorners",
67{
68 false,
69 true,
70});
71
Georgios Pinitas583137c2017-08-31 18:12:42 +010072/** Tolerance */
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +010073constexpr AbsoluteTolerance<uint8_t> tolerance_u8(1);
74constexpr AbsoluteTolerance<int16_t> tolerance_s16(1);
Georgios Pinitas583137c2017-08-31 18:12:42 +010075RelativeTolerance<float> tolerance_f32(0.01);
Georgios Pinitasc47ef202018-11-16 18:19:43 +000076#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
77RelativeTolerance<half> tolerance_f16(half(0.1));
78#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Moritz Pflanzerff1c3602017-09-22 12:41:25 +010079
80constexpr float tolerance_num_s16 = 0.01f;
81constexpr float tolerance_num_f32 = 0.01f;
Isabella Gottardi732f3682017-09-05 14:10:12 +010082} // namespace
83
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010084TEST_SUITE(NEON)
85TEST_SUITE(Scale)
86
Georgios Pinitas20b43132018-05-14 16:05:23 +010087// *INDENT-OFF*
88// clang-format off
89DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010090 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Mismatching data type
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010091 TensorInfo(TensorShape(4U, 27U, 13U), 1, DataType::F32), // Invalid policy
92 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Insufficient padding
93 TensorInfo(TensorShape(4U, 27U, 13U), 1, DataType::F32),
Georgios Pinitas20b43132018-05-14 16:05:23 +010094 }),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010095 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(132U, 25U, 2U), 1, DataType::F32),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010096 TensorInfo(TensorShape(4U, 132U, 25U), 1, DataType::F32),
97 TensorInfo(TensorShape(132U, 25U, 2U), 1, DataType::F32),
98 TensorInfo(TensorShape(4U, 132U, 25U), 1, DataType::F32),
Georgios Pinitas20b43132018-05-14 16:05:23 +010099 })),
100 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR,
Georgios Pinitas20b43132018-05-14 16:05:23 +0100101 InterpolationPolicy::AREA,
102 InterpolationPolicy::AREA,
103 InterpolationPolicy::NEAREST_NEIGHBOR,
104 })),
105 framework::dataset::make("BorderMode", { BorderMode::UNDEFINED,
106 BorderMode::UNDEFINED,
107 BorderMode::UNDEFINED,
Georgios Pinitas20b43132018-05-14 16:05:23 +0100108 BorderMode::REPLICATE,
109 })),
110 framework::dataset::make("SamplingPolicy", { SamplingPolicy::CENTER,
Georgios Pinitas20b43132018-05-14 16:05:23 +0100111 SamplingPolicy::CENTER,
112 SamplingPolicy::CENTER,
113 SamplingPolicy::CENTER,
114 })),
115 framework::dataset::make("DataLayout", { DataLayout::NCHW,
Georgios Pinitas20b43132018-05-14 16:05:23 +0100116 DataLayout::NHWC,
117 DataLayout::NCHW,
118 DataLayout::NHWC,
119 })),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000120 framework::dataset::make("Expected", { false, false, false ,true })),
Georgios Pinitas20b43132018-05-14 16:05:23 +0100121 input_info, output_info, policy,border_mode, sampling_policy, data_layout, expected)
122{
123 const PixelValue constant_border(5);
124 Status status = NEScale::validate(&input_info.clone()->set_is_resizable(false).set_data_layout(data_layout),
125 &output_info.clone()->set_is_resizable(false).set_data_layout(data_layout),
126 policy, border_mode, constant_border, sampling_policy);
127 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
128}
129// clang-format on
130// *INDENT-ON*
131
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000132DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallShapes(), ScaleDataTypes), ScaleDataLayouts),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700133 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
134 datasets::BorderModes()),
135 framework::dataset::make("SamplingPolicy", { SamplingPolicy::CENTER })),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100136 shape, data_type, data_layout, policy, border_mode, sampling_policy)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100137{
138 std::mt19937 generator(library->seed());
139 std::uniform_real_distribution<float> distribution_float(0.25, 2);
140 const float scale_x = distribution_float(generator);
141 const float scale_y = distribution_float(generator);
142 uint8_t constant_border_value = 0;
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100143 TensorShape src_shape = shape;
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100144 if(border_mode == BorderMode::CONSTANT)
145 {
146 std::uniform_int_distribution<uint8_t> distribution_u8(0, 255);
147 constant_border_value = distribution_u8(generator);
148 }
149
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100150 // Get width/height indices depending on layout
151 const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
152 const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
153
154 // Change shape in case of NHWC.
155 if(data_layout == DataLayout::NHWC)
156 {
157 permute(src_shape, PermutationVector(2U, 0U, 1U));
158 }
159
160 // Calculate scaled shape
161 TensorShape shape_scaled(src_shape);
162 shape_scaled.set(idx_width, src_shape[idx_width] * scale_x);
163 shape_scaled.set(idx_height, src_shape[idx_height] * scale_y);
164
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100165 // Create tensors
Vidhya Sudhan Loganathan014333d2018-07-02 09:13:49 +0100166 Tensor src = create_tensor<Tensor>(src_shape, data_type, 1, QuantizationInfo(), data_layout);
167 Tensor dst = create_tensor<Tensor>(shape_scaled, data_type, 1, QuantizationInfo(), data_layout);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100168
169 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
170 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
171
172 // Create and configure function
173 NEScale nescale;
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700174 nescale.configure(&src, &dst, policy, border_mode, constant_border_value, sampling_policy);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100175
176 // Validate valid region
Diego Lopez Recas00854292018-02-22 13:08:01 +0000177 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 +0100178 validate(dst.info()->valid_region(), dst_valid_region);
179
180 // Validate padding
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100181 int num_elements_processed_x = 16;
182 if(data_layout == DataLayout::NHWC)
183 {
184 num_elements_processed_x = (policy == InterpolationPolicy::BILINEAR) ? 1 : 16 / src.info()->element_size();
185 }
186 PaddingCalculator calculator(shape_scaled.x(), num_elements_processed_x);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100187 calculator.set_border_mode(border_mode);
188
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100189 PaddingSize read_padding(1);
190 if(data_layout == DataLayout::NHWC)
191 {
192 read_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER);
Michalis Spyrouc050e0c2019-07-25 17:58:30 +0100193 if(border_mode != BorderMode::REPLICATE && policy == InterpolationPolicy::BILINEAR)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100194 {
195 read_padding.top = 1;
196 }
197 }
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100198 const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER);
199 validate(src.info()->padding(), read_padding);
200 validate(dst.info()->padding(), write_padding);
201}
202
203template <typename T>
204using NEScaleFixture = ScaleValidationFixture<Tensor, Accessor, NEScale, T>;
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000205template <typename T>
206using NEScaleQuantizedFixture = ScaleValidationQuantizedFixture<Tensor, Accessor, NEScale, T>;
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100207
Georgios Pinitas583137c2017-08-31 18:12:42 +0100208TEST_SUITE(Float)
209TEST_SUITE(FP32)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000210FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700211 DataType::F32)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100212 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000213 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
214 datasets::BorderModes()),
215 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })),
216 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100217{
218 //Create valid region
219 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000220 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 +0100221
222 // Validate output
Moritz Pflanzerff1c3602017-09-22 12:41:25 +0100223 validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100224}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000225FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Georgios Pinitas583137c2017-08-31 18:12:42 +0100226 DataType::F32)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100227 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700228 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000229 datasets::BorderModes()),
230 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })),
231 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100232{
233 //Create valid region
234 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000235 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 +0100236
237 // Validate output
Moritz Pflanzerff1c3602017-09-22 12:41:25 +0100238 validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100239}
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000240TEST_SUITE_END() // FP32
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000241#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
242TEST_SUITE(FP16)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000243FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000244 DataType::F16)),
245 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 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })),
249 AlignCorners))
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000250{
251 //Create valid region
252 TensorInfo src_info(_shape, 1, _data_type);
253 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
254
255 // Validate output
256 validate(Accessor(_target), _reference, valid_region, tolerance_f16);
257}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000258FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000259 DataType::F16)),
260 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000261 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
262 datasets::BorderModes()),
263 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })),
264 AlignCorners))
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000265{
266 //Create valid region
267 TensorInfo src_info(_shape, 1, _data_type);
268 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
269
270 // Validate output
271 validate(Accessor(_target), _reference, valid_region, tolerance_f16);
272}
273TEST_SUITE_END() // FP16
274#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000275TEST_SUITE_END() // Float
Georgios Pinitas583137c2017-08-31 18:12:42 +0100276
277TEST_SUITE(Integer)
278TEST_SUITE(U8)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000279FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700280 DataType::U8)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100281 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000282 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
283 datasets::BorderModes()),
284 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })),
285 AlignCorners))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100286{
287 //Create valid region
288 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000289 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 +0100290
291 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100292 validate(Accessor(_target), _reference, valid_region, tolerance_u8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100293}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000294FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100295 DataType::U8)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100296 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700297 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000298 datasets::BorderModes()),
299 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })),
300 AlignCorners))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100301{
302 //Create valid region
303 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000304 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 +0100305
306 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100307 validate(Accessor(_target), _reference, valid_region, tolerance_u8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100308}
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000309TEST_SUITE_END() // U8
Georgios Pinitas583137c2017-08-31 18:12:42 +0100310TEST_SUITE(S16)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000311FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700312 DataType::S16)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100313 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000314 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
315 datasets::BorderModes()),
316 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })),
317 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100318{
319 //Create valid region
320 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000321 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 +0100322
323 // Validate output
Moritz Pflanzerff1c3602017-09-22 12:41:25 +0100324 validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100325}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000326FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Georgios Pinitas583137c2017-08-31 18:12:42 +0100327 DataType::S16)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100328 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700329 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000330 datasets::BorderModes()),
331 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })),
332 AlignCorners))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100333{
334 //Create valid region
335 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000336 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 +0100337
338 // Validate output
Moritz Pflanzerff1c3602017-09-22 12:41:25 +0100339 validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100340}
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000341TEST_SUITE_END() // S16
342TEST_SUITE_END() // Integer
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100343
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000344TEST_SUITE(Quantized)
345TEST_SUITE(QASYMM8)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000346FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(combine(datasets::SmallShapes(),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000347 framework::dataset::make("DataType", DataType::QASYMM8)),
348 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -10) })),
349 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
350 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +0000351 datasets::BorderModes()),
352 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })),
353 AlignCorners))
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000354{
355 //Create valid region
356 TensorInfo src_info(_shape, 1, _data_type);
357 ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
358
359 // Validate output
360 validate(Accessor(_target), _reference, valid_region, tolerance_u8);
361}
362TEST_SUITE_END() // QASYMM8
363TEST_SUITE_END() // Quantized
364
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000365TEST_SUITE_END() // Scale
366TEST_SUITE_END() // NEON
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100367} // namespace validation
368} // namespace test
369} // namespace arm_compute