Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 ARM Limited. |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 3 | * |
| 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 Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 29 | #include "tests/NEON/Accessor.h" |
| 30 | #include "tests/PaddingCalculator.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 31 | #include "tests/datasets/BorderModeDataset.h" |
| 32 | #include "tests/datasets/InterpolationPolicyDataset.h" |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 33 | #include "tests/datasets/SamplingPolicyDataset.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 34 | #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 Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 41 | |
| 42 | namespace arm_compute |
| 43 | { |
| 44 | namespace test |
| 45 | { |
| 46 | namespace validation |
| 47 | { |
Isabella Gottardi | 732f368 | 2017-09-05 14:10:12 +0100 | [diff] [blame] | 48 | namespace |
| 49 | { |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 50 | /** Scale data types */ |
| 51 | const auto ScaleDataTypes = framework::dataset::make("DataType", |
| 52 | { |
| 53 | DataType::U8, |
| 54 | DataType::S16, |
| 55 | DataType::F32, |
| 56 | }); |
| 57 | |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 58 | /** Scale data types */ |
| 59 | const auto ScaleDataLayouts = framework::dataset::make("DataLayout", |
| 60 | { |
| 61 | DataLayout::NCHW, |
| 62 | DataLayout::NHWC, |
| 63 | }); |
| 64 | |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 65 | /** Tolerance */ |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 66 | constexpr AbsoluteTolerance<uint8_t> tolerance_u8(1); |
| 67 | constexpr AbsoluteTolerance<int16_t> tolerance_s16(1); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 68 | RelativeTolerance<float> tolerance_f32(0.01); |
Georgios Pinitas | c47ef20 | 2018-11-16 18:19:43 +0000 | [diff] [blame] | 69 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 70 | RelativeTolerance<half> tolerance_f16(half(0.1)); |
| 71 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 72 | |
| 73 | constexpr float tolerance_num_s16 = 0.01f; |
| 74 | constexpr float tolerance_num_f32 = 0.01f; |
Isabella Gottardi | 732f368 | 2017-09-05 14:10:12 +0100 | [diff] [blame] | 75 | } // namespace |
| 76 | |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 77 | TEST_SUITE(NEON) |
| 78 | TEST_SUITE(Scale) |
| 79 | |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 80 | // *INDENT-OFF* |
| 81 | // clang-format off |
| 82 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip( |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 83 | framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Mismatching data type |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 84 | 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 Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 87 | }), |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 88 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(132U, 25U, 2U), 1, DataType::F32), |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 89 | 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 Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 92 | })), |
| 93 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 94 | InterpolationPolicy::AREA, |
| 95 | InterpolationPolicy::AREA, |
| 96 | InterpolationPolicy::NEAREST_NEIGHBOR, |
| 97 | })), |
| 98 | framework::dataset::make("BorderMode", { BorderMode::UNDEFINED, |
| 99 | BorderMode::UNDEFINED, |
| 100 | BorderMode::UNDEFINED, |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 101 | BorderMode::REPLICATE, |
| 102 | })), |
| 103 | framework::dataset::make("SamplingPolicy", { SamplingPolicy::CENTER, |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 104 | SamplingPolicy::CENTER, |
| 105 | SamplingPolicy::CENTER, |
| 106 | SamplingPolicy::CENTER, |
| 107 | })), |
| 108 | framework::dataset::make("DataLayout", { DataLayout::NCHW, |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 109 | DataLayout::NHWC, |
| 110 | DataLayout::NCHW, |
| 111 | DataLayout::NHWC, |
| 112 | })), |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 113 | framework::dataset::make("Expected", { false, false, false ,true })), |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 114 | 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 Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 125 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallShapes(), ScaleDataTypes), ScaleDataLayouts), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 126 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 127 | datasets::BorderModes()), |
| 128 | framework::dataset::make("SamplingPolicy", { SamplingPolicy::CENTER })), |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 129 | shape, data_type, data_layout, policy, border_mode, sampling_policy) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 130 | { |
| 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 Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 136 | TensorShape src_shape = shape; |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 137 | 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 Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 143 | // 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 Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 158 | // Create tensors |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame] | 159 | 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 Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 161 | |
| 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 Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 167 | nescale.configure(&src, &dst, policy, border_mode, constant_border_value, sampling_policy); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 168 | |
| 169 | // Validate valid region |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 170 | const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, sampling_policy, (border_mode == BorderMode::UNDEFINED)); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 171 | validate(dst.info()->valid_region(), dst_valid_region); |
| 172 | |
| 173 | // Validate padding |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 174 | 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 Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 180 | calculator.set_border_mode(border_mode); |
| 181 | |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 182 | 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 Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 191 | 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 | |
| 196 | template <typename T> |
| 197 | using NEScaleFixture = ScaleValidationFixture<Tensor, Accessor, NEScale, T>; |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 198 | template <typename T> |
| 199 | using NEScaleQuantizedFixture = ScaleValidationQuantizedFixture<Tensor, Accessor, NEScale, T>; |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 200 | |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 201 | TEST_SUITE(Float) |
| 202 | TEST_SUITE(FP32) |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 203 | FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 204 | DataType::F32)), |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 205 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 206 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 207 | datasets::BorderModes()), |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 208 | framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER }))) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 209 | { |
| 210 | //Create valid region |
| 211 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 212 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 213 | |
| 214 | // Validate output |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 215 | validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 216 | } |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 217 | FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 218 | DataType::F32)), |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 219 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 220 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 221 | datasets::BorderModes()), |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 222 | framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER }))) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 223 | { |
| 224 | //Create valid region |
| 225 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 226 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 227 | |
| 228 | // Validate output |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 229 | validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 230 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 231 | TEST_SUITE_END() // FP32 |
Georgios Pinitas | c47ef20 | 2018-11-16 18:19:43 +0000 | [diff] [blame] | 232 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 233 | TEST_SUITE(FP16) |
| 234 | FIXTURE_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 Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 239 | framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER }))) |
Georgios Pinitas | c47ef20 | 2018-11-16 18:19:43 +0000 | [diff] [blame] | 240 | { |
| 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 | } |
| 248 | FIXTURE_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 Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 253 | framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER }))) |
Georgios Pinitas | c47ef20 | 2018-11-16 18:19:43 +0000 | [diff] [blame] | 254 | { |
| 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 | } |
| 262 | TEST_SUITE_END() // FP16 |
| 263 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 264 | TEST_SUITE_END() // Float |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 265 | |
| 266 | TEST_SUITE(Integer) |
| 267 | TEST_SUITE(U8) |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 268 | FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 269 | DataType::U8)), |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 270 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 271 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 272 | datasets::BorderModes()), |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 273 | framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER }))) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 274 | { |
| 275 | //Create valid region |
| 276 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 277 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 278 | |
| 279 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 280 | validate(Accessor(_target), _reference, valid_region, tolerance_u8); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 281 | } |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 282 | FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 283 | DataType::U8)), |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 284 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 285 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 286 | datasets::BorderModes()), |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 287 | framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER }))) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 288 | { |
| 289 | //Create valid region |
| 290 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 291 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 292 | |
| 293 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 294 | validate(Accessor(_target), _reference, valid_region, tolerance_u8); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 295 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 296 | TEST_SUITE_END() // U8 |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 297 | TEST_SUITE(S16) |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 298 | FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 299 | DataType::S16)), |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 300 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 301 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 302 | datasets::BorderModes()), |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 303 | framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER }))) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 304 | { |
| 305 | //Create valid region |
| 306 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 307 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 308 | |
| 309 | // Validate output |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 310 | validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 311 | } |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 312 | FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 313 | DataType::S16)), |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 314 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 315 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 316 | datasets::BorderModes()), |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 317 | framework::dataset::make("SamplingPolicy", { SamplingPolicy::TOP_LEFT, SamplingPolicy::CENTER }))) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 318 | { |
| 319 | //Create valid region |
| 320 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 321 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 322 | |
| 323 | // Validate output |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 324 | validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 325 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 326 | TEST_SUITE_END() // S16 |
| 327 | TEST_SUITE_END() // Integer |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 328 | |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 329 | TEST_SUITE(Quantized) |
| 330 | TEST_SUITE(QASYMM8) |
| 331 | FIXTURE_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 | } |
| 346 | TEST_SUITE_END() // QASYMM8 |
| 347 | TEST_SUITE_END() // Quantized |
| 348 | |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 349 | TEST_SUITE_END() // Scale |
| 350 | TEST_SUITE_END() // NEON |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 351 | } // namespace validation |
| 352 | } // namespace test |
| 353 | } // namespace arm_compute |