blob: c05b8ac03b8cce0634d6c7fdbd4a40432c05fdf6 [file] [log] [blame]
Isabella Gottardi1fab09f2017-07-13 15:55:57 +01001/*
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +00002 * Copyright (c) 2017-2019 ARM Limited.
Isabella Gottardi1fab09f2017-07-13 15:55:57 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/Helpers.h"
25#include "arm_compute/core/Types.h"
26#include "arm_compute/runtime/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
Georgios Pinitas583137c2017-08-31 18:12:42 +010065/** Tolerance */
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +010066constexpr AbsoluteTolerance<uint8_t> tolerance_u8(1);
67constexpr AbsoluteTolerance<int16_t> tolerance_s16(1);
Georgios Pinitas583137c2017-08-31 18:12:42 +010068RelativeTolerance<float> tolerance_f32(0.01);
Georgios Pinitasc47ef202018-11-16 18:19:43 +000069#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
70RelativeTolerance<half> tolerance_f16(half(0.1));
71#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Moritz Pflanzerff1c3602017-09-22 12:41:25 +010072
73constexpr float tolerance_num_s16 = 0.01f;
74constexpr float tolerance_num_f32 = 0.01f;
Isabella Gottardi732f3682017-09-05 14:10:12 +010075} // namespace
76
Isabella Gottardi1fab09f2017-07-13 15:55:57 +010077TEST_SUITE(NEON)
78TEST_SUITE(Scale)
79
Georgios Pinitas20b43132018-05-14 16:05:23 +010080// *INDENT-OFF*
81// clang-format off
82DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010083 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Mismatching data type
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010084 TensorInfo(TensorShape(4U, 27U, 13U), 1, DataType::F32), // Invalid policy
85 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Insufficient padding
86 TensorInfo(TensorShape(4U, 27U, 13U), 1, DataType::F32),
Georgios Pinitas20b43132018-05-14 16:05:23 +010087 }),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010088 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(132U, 25U, 2U), 1, DataType::F32),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010089 TensorInfo(TensorShape(4U, 132U, 25U), 1, DataType::F32),
90 TensorInfo(TensorShape(132U, 25U, 2U), 1, DataType::F32),
91 TensorInfo(TensorShape(4U, 132U, 25U), 1, DataType::F32),
Georgios Pinitas20b43132018-05-14 16:05:23 +010092 })),
93 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR,
Georgios Pinitas20b43132018-05-14 16:05:23 +010094 InterpolationPolicy::AREA,
95 InterpolationPolicy::AREA,
96 InterpolationPolicy::NEAREST_NEIGHBOR,
97 })),
98 framework::dataset::make("BorderMode", { BorderMode::UNDEFINED,
99 BorderMode::UNDEFINED,
100 BorderMode::UNDEFINED,
Georgios Pinitas20b43132018-05-14 16:05:23 +0100101 BorderMode::REPLICATE,
102 })),
103 framework::dataset::make("SamplingPolicy", { SamplingPolicy::CENTER,
Georgios Pinitas20b43132018-05-14 16:05:23 +0100104 SamplingPolicy::CENTER,
105 SamplingPolicy::CENTER,
106 SamplingPolicy::CENTER,
107 })),
108 framework::dataset::make("DataLayout", { DataLayout::NCHW,
Georgios Pinitas20b43132018-05-14 16:05:23 +0100109 DataLayout::NHWC,
110 DataLayout::NCHW,
111 DataLayout::NHWC,
112 })),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000113 framework::dataset::make("Expected", { false, false, false ,true })),
Georgios Pinitas20b43132018-05-14 16:05:23 +0100114 input_info, output_info, policy,border_mode, sampling_policy, data_layout, expected)
115{
116 const PixelValue constant_border(5);
117 Status status = NEScale::validate(&input_info.clone()->set_is_resizable(false).set_data_layout(data_layout),
118 &output_info.clone()->set_is_resizable(false).set_data_layout(data_layout),
119 policy, border_mode, constant_border, sampling_policy);
120 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
121}
122// clang-format on
123// *INDENT-ON*
124
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000125DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallShapes(), ScaleDataTypes), ScaleDataLayouts),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700126 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
127 datasets::BorderModes()),
128 framework::dataset::make("SamplingPolicy", { SamplingPolicy::CENTER })),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100129 shape, data_type, data_layout, policy, border_mode, sampling_policy)
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100130{
131 std::mt19937 generator(library->seed());
132 std::uniform_real_distribution<float> distribution_float(0.25, 2);
133 const float scale_x = distribution_float(generator);
134 const float scale_y = distribution_float(generator);
135 uint8_t constant_border_value = 0;
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100136 TensorShape src_shape = shape;
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100137 if(border_mode == BorderMode::CONSTANT)
138 {
139 std::uniform_int_distribution<uint8_t> distribution_u8(0, 255);
140 constant_border_value = distribution_u8(generator);
141 }
142
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100143 // Get width/height indices depending on layout
144 const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
145 const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
146
147 // Change shape in case of NHWC.
148 if(data_layout == DataLayout::NHWC)
149 {
150 permute(src_shape, PermutationVector(2U, 0U, 1U));
151 }
152
153 // Calculate scaled shape
154 TensorShape shape_scaled(src_shape);
155 shape_scaled.set(idx_width, src_shape[idx_width] * scale_x);
156 shape_scaled.set(idx_height, src_shape[idx_height] * scale_y);
157
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100158 // Create tensors
Vidhya Sudhan Loganathan014333d2018-07-02 09:13:49 +0100159 Tensor src = create_tensor<Tensor>(src_shape, data_type, 1, QuantizationInfo(), data_layout);
160 Tensor dst = create_tensor<Tensor>(shape_scaled, data_type, 1, QuantizationInfo(), data_layout);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100161
162 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
163 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
164
165 // Create and configure function
166 NEScale nescale;
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700167 nescale.configure(&src, &dst, policy, border_mode, constant_border_value, sampling_policy);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100168
169 // Validate valid region
Diego Lopez Recas00854292018-02-22 13:08:01 +0000170 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 +0100171 validate(dst.info()->valid_region(), dst_valid_region);
172
173 // Validate padding
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100174 int num_elements_processed_x = 16;
175 if(data_layout == DataLayout::NHWC)
176 {
177 num_elements_processed_x = (policy == InterpolationPolicy::BILINEAR) ? 1 : 16 / src.info()->element_size();
178 }
179 PaddingCalculator calculator(shape_scaled.x(), num_elements_processed_x);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100180 calculator.set_border_mode(border_mode);
181
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100182 PaddingSize read_padding(1);
183 if(data_layout == DataLayout::NHWC)
184 {
185 read_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER);
186 if(border_mode == BorderMode::CONSTANT && policy == InterpolationPolicy::BILINEAR)
187 {
188 read_padding.top = 1;
189 }
190 }
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100191 const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER);
192 validate(src.info()->padding(), read_padding);
193 validate(dst.info()->padding(), write_padding);
194}
195
196template <typename T>
197using NEScaleFixture = ScaleValidationFixture<Tensor, Accessor, NEScale, T>;
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000198template <typename T>
199using NEScaleQuantizedFixture = ScaleValidationQuantizedFixture<Tensor, Accessor, NEScale, T>;
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100200
Georgios Pinitas583137c2017-08-31 18:12:42 +0100201TEST_SUITE(Float)
202TEST_SUITE(FP32)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100203FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700204 DataType::F32)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100205 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700206 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
207 datasets::BorderModes()),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000208 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100209{
210 //Create valid region
211 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000212 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 +0100213
214 // Validate output
Moritz Pflanzerff1c3602017-09-22 12:41:25 +0100215 validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100216}
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100217FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Georgios Pinitas583137c2017-08-31 18:12:42 +0100218 DataType::F32)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100219 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700220 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
221 datasets::BorderModes()),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000222 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100223{
224 //Create valid region
225 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000226 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 +0100227
228 // Validate output
Moritz Pflanzerff1c3602017-09-22 12:41:25 +0100229 validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100230}
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000231TEST_SUITE_END() // FP32
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000232#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
233TEST_SUITE(FP16)
234FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
235 DataType::F16)),
236 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
237 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
238 datasets::BorderModes()),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000239 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })))
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000240{
241 //Create valid region
242 TensorInfo src_info(_shape, 1, _data_type);
243 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
244
245 // Validate output
246 validate(Accessor(_target), _reference, valid_region, tolerance_f16);
247}
248FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
249 DataType::F16)),
250 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
251 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
252 datasets::BorderModes()),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000253 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })))
Georgios Pinitasc47ef202018-11-16 18:19:43 +0000254{
255 //Create valid region
256 TensorInfo src_info(_shape, 1, _data_type);
257 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
258
259 // Validate output
260 validate(Accessor(_target), _reference, valid_region, tolerance_f16);
261}
262TEST_SUITE_END() // FP16
263#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000264TEST_SUITE_END() // Float
Georgios Pinitas583137c2017-08-31 18:12:42 +0100265
266TEST_SUITE(Integer)
267TEST_SUITE(U8)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100268FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700269 DataType::U8)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100270 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700271 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
272 datasets::BorderModes()),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000273 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100274{
275 //Create valid region
276 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000277 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 +0100278
279 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100280 validate(Accessor(_target), _reference, valid_region, tolerance_u8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100281}
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100282FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100283 DataType::U8)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100284 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700285 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
286 datasets::BorderModes()),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000287 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })))
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100288{
289 //Create valid region
290 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000291 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 +0100292
293 // Validate output
Georgios Pinitas99d4f4a2017-09-19 16:51:42 +0100294 validate(Accessor(_target), _reference, valid_region, tolerance_u8);
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100295}
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000296TEST_SUITE_END() // U8
Georgios Pinitas583137c2017-08-31 18:12:42 +0100297TEST_SUITE(S16)
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100298FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700299 DataType::S16)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100300 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700301 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
302 datasets::BorderModes()),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000303 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })))
Georgios Pinitas583137c2017-08-31 18:12:42 +0100304{
305 //Create valid region
306 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +0000307 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 +0100308
309 // Validate output
Moritz Pflanzerff1c3602017-09-22 12:41:25 +0100310 validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16);
Georgios Pinitas583137c2017-08-31 18:12:42 +0100311}
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100312FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Georgios Pinitas583137c2017-08-31 18:12:42 +0100313 DataType::S16)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +0100314 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
Daniil Efremov02bf80d2017-11-22 00:26:51 +0700315 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
316 datasets::BorderModes()),
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000317 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })))
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}
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000326TEST_SUITE_END() // S16
327TEST_SUITE_END() // Integer
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100328
Vidhya Sudhan Loganathan3ac2f3a2019-01-17 15:16:19 +0000329TEST_SUITE(Quantized)
330TEST_SUITE(QASYMM8)
331FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(),
332 framework::dataset::make("DataType", DataType::QASYMM8)),
333 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -10) })),
334 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
335 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
336 datasets::BorderModes()),
337 framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER })))
338{
339 //Create valid region
340 TensorInfo src_info(_shape, 1, _data_type);
341 ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
342
343 // Validate output
344 validate(Accessor(_target), _reference, valid_region, tolerance_u8);
345}
346TEST_SUITE_END() // QASYMM8
347TEST_SUITE_END() // Quantized
348
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000349TEST_SUITE_END() // Scale
350TEST_SUITE_END() // NEON
Isabella Gottardi1fab09f2017-07-13 15:55:57 +0100351} // namespace validation
352} // namespace test
353} // namespace arm_compute