Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +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/CL/functions/CLScale.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/CL/CLAccessor.h" |
| 30 | #include "tests/PaddingCalculator.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 31 | #include "tests/datasets/BorderModeDataset.h" |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 32 | #include "tests/datasets/SamplingPolicyDataset.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 33 | #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 Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 40 | |
| 41 | namespace arm_compute |
| 42 | { |
| 43 | namespace test |
| 44 | { |
| 45 | namespace validation |
| 46 | { |
| 47 | namespace |
| 48 | { |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 49 | /** CNN data types */ |
| 50 | const auto ScaleDataTypes = framework::dataset::make("DataType", |
| 51 | { |
| 52 | DataType::U8, |
| 53 | DataType::S16, |
| 54 | DataType::F16, |
| 55 | DataType::F32, |
| 56 | }); |
| 57 | |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 58 | /** Tolerance */ |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 59 | constexpr AbsoluteTolerance<uint8_t> tolerance_u8(1); |
| 60 | constexpr AbsoluteTolerance<int16_t> tolerance_s16(1); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 61 | constexpr float tolerance_f32_absolute(0.001f); |
| 62 | |
| 63 | RelativeTolerance<float> tolerance_f32(0.05); |
| 64 | RelativeTolerance<half> tolerance_f16(half(0.1)); |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 65 | |
| 66 | constexpr float tolerance_num_f32(0.01f); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 67 | } // namespace |
| 68 | |
| 69 | TEST_SUITE(CL) |
| 70 | TEST_SUITE(Scale) |
| 71 | |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 72 | // *INDENT-OFF* |
| 73 | // clang-format off |
| 74 | |
| 75 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( |
| 76 | framework::dataset::make("InputInfo",{ TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F16), |
| 77 | TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F32), |
| 78 | TensorInfo(TensorShape(36U, 36U, 2U, 4U), 1, DataType::U8), |
| 79 | TensorInfo(TensorShape(40U, 35U, 2U, 4U), 1, DataType::S16), |
| 80 | TensorInfo(TensorShape(37U, 37U, 2U), 1, DataType::F32), // window shrink |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 81 | TensorInfo(TensorShape(37U, 37U, 3U, 4U), 1, DataType::F32), // mismatching datatype |
| 82 | TensorInfo(TensorShape(28U, 33U, 2U), 1, DataType::F32), // policy area, scale factor not correct |
| 83 | }), |
| 84 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 68U, 2U), 1, DataType::F16), |
| 85 | TensorInfo(TensorShape(40U, 56U, 2U), 1, DataType::F32), |
| 86 | TensorInfo(TensorShape(40U, 76U, 2U, 4U), 1, DataType::U8), |
| 87 | TensorInfo(TensorShape(28U, 32U, 2U, 4U), 1, DataType::S16), |
| 88 | TensorInfo(TensorShape(39U, 55U, 2U), 1, DataType::F32), // window shrink |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 89 | TensorInfo(TensorShape(39U, 77U, 3U, 4U), 1, DataType::F16), // mismatching datatype |
| 90 | TensorInfo(TensorShape(26U, 21U, 2U), 1, DataType::F32), // policy area, scale factor not correct |
| 91 | })), |
| 92 | framework::dataset::make("Policy",{ InterpolationPolicy::BILINEAR, |
| 93 | InterpolationPolicy::BILINEAR, |
| 94 | InterpolationPolicy::NEAREST_NEIGHBOR, |
| 95 | InterpolationPolicy::NEAREST_NEIGHBOR, |
| 96 | InterpolationPolicy::NEAREST_NEIGHBOR, |
| 97 | InterpolationPolicy::BILINEAR, |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 98 | InterpolationPolicy::AREA, |
| 99 | })), |
| 100 | framework::dataset::make("BorderMode",{ BorderMode::UNDEFINED, |
| 101 | BorderMode::UNDEFINED, |
| 102 | BorderMode::UNDEFINED, |
| 103 | BorderMode::UNDEFINED, |
| 104 | BorderMode::UNDEFINED, |
| 105 | BorderMode::UNDEFINED, |
| 106 | BorderMode::UNDEFINED, |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 107 | })), |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 108 | framework::dataset::make("Expected", { true, true, true, true, false, false, false })), |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 109 | input_info, output_info, policy, border_mode, expected) |
| 110 | { |
| 111 | Status status = CLScale::validate(&input_info.clone()->set_is_resizable(false), |
| 112 | &output_info.clone()->set_is_resizable(false), policy, border_mode); |
| 113 | ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS); |
| 114 | } |
| 115 | |
| 116 | // clang-format on |
| 117 | // *INDENT-ON* |
| 118 | |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 119 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::MediumShapes(), ScaleDataTypes), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 120 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 121 | datasets::BorderModes()), |
| 122 | datasets::SamplingPolicies()), |
| 123 | shape, data_type, policy, border_mode, sampling_policy) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 124 | { |
| 125 | std::mt19937 generator(library->seed()); |
| 126 | std::uniform_real_distribution<float> distribution_float(0.25, 2); |
| 127 | const float scale_x = distribution_float(generator); |
| 128 | const float scale_y = distribution_float(generator); |
| 129 | std::uniform_int_distribution<uint8_t> distribution_u8(0, 255); |
| 130 | uint8_t constant_border_value = distribution_u8(generator); |
| 131 | |
| 132 | // Create tensors |
| 133 | CLTensor src = create_tensor<CLTensor>(shape, data_type); |
| 134 | TensorShape shape_scaled(shape); |
| 135 | shape_scaled.set(0, shape[0] * scale_x); |
| 136 | shape_scaled.set(1, shape[1] * scale_y); |
| 137 | CLTensor dst = create_tensor<CLTensor>(shape_scaled, data_type); |
| 138 | |
| 139 | ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 140 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 141 | |
| 142 | // Create and configure function |
| 143 | CLScale clscale; |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 144 | clscale.configure(&src, &dst, policy, border_mode, constant_border_value, sampling_policy); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 145 | |
Daniil Efremov | 7a49c79 | 2017-11-14 21:25:34 +0700 | [diff] [blame] | 146 | // Get border size depending on border mode |
| 147 | const BorderSize border_size(border_mode == BorderMode::UNDEFINED ? 0 : 1); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 148 | |
Daniil Efremov | 7a49c79 | 2017-11-14 21:25:34 +0700 | [diff] [blame] | 149 | // Validate valid region |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 150 | 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] | 151 | validate(dst.info()->valid_region(), dst_valid_region); |
| 152 | |
| 153 | // Validate padding |
| 154 | PaddingCalculator calculator(shape_scaled.x(), 4); |
| 155 | calculator.set_border_mode(border_mode); |
| 156 | |
Daniil Efremov | 7a49c79 | 2017-11-14 21:25:34 +0700 | [diff] [blame] | 157 | const PaddingSize read_padding(border_size); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 158 | const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); |
| 159 | validate(src.info()->padding(), read_padding); |
| 160 | validate(dst.info()->padding(), write_padding); |
| 161 | } |
| 162 | |
| 163 | template <typename T> |
| 164 | using CLScaleFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T>; |
| 165 | |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 166 | TEST_SUITE(Float) |
| 167 | TEST_SUITE(FP32) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 168 | FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 169 | DataType::F32)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 170 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 171 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 172 | datasets::BorderModes()), |
| 173 | datasets::SamplingPolicies())) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 174 | { |
| 175 | //Create valid region |
| 176 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 177 | const 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] | 178 | |
| 179 | // Validate output |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 180 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 181 | } |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 182 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
| 183 | DataType::F32)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 184 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 185 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 186 | datasets::BorderModes()), |
| 187 | datasets::SamplingPolicies())) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 188 | { |
| 189 | //Create valid region |
| 190 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 191 | const 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] | 192 | |
| 193 | // Validate output |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 194 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 195 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 196 | TEST_SUITE_END() // FP32 |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 197 | TEST_SUITE(FP16) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 198 | FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 199 | DataType::F16)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 200 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 201 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 202 | datasets::BorderModes()), |
| 203 | datasets::SamplingPolicies())) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 204 | { |
| 205 | //Create valid region |
| 206 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 207 | const 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] | 208 | |
| 209 | // Validate output |
| 210 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); |
| 211 | } |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 212 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 213 | DataType::F16)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 214 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 215 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 216 | datasets::BorderModes()), |
| 217 | datasets::SamplingPolicies())) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 218 | { |
| 219 | //Create valid region |
| 220 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 221 | const 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] | 222 | |
| 223 | // Validate output |
| 224 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); |
| 225 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 226 | TEST_SUITE_END() // FP16 |
| 227 | TEST_SUITE_END() // Float |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 228 | |
| 229 | TEST_SUITE(Integer) |
| 230 | TEST_SUITE(U8) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 231 | FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 232 | DataType::U8)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 233 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 234 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 235 | datasets::BorderModes()), |
| 236 | datasets::SamplingPolicies())) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 237 | { |
| 238 | //Create valid region |
| 239 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 240 | const 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] | 241 | |
| 242 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 243 | validate(CLAccessor(_target), _reference, valid_region, tolerance_u8); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 244 | } |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 245 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
| 246 | DataType::U8)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 247 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 248 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 249 | datasets::BorderModes()), |
| 250 | datasets::SamplingPolicies())) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 251 | { |
| 252 | //Create valid region |
| 253 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 254 | const 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] | 255 | |
| 256 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 257 | validate(CLAccessor(_target), _reference, valid_region, tolerance_u8); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 258 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 259 | TEST_SUITE_END() // U8 |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 260 | TEST_SUITE(S16) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 261 | FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 262 | DataType::S16)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 263 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 264 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 265 | datasets::BorderModes()), |
| 266 | datasets::SamplingPolicies())) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 267 | { |
| 268 | //Create valid region |
| 269 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 270 | const 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] | 271 | |
| 272 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 273 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 274 | } |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 275 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 276 | DataType::S16)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 277 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 278 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 279 | datasets::BorderModes()), |
| 280 | datasets::SamplingPolicies())) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 281 | { |
| 282 | //Create valid region |
| 283 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 284 | const 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] | 285 | |
| 286 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 287 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 288 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 289 | TEST_SUITE_END() // S16 |
| 290 | TEST_SUITE_END() // Integer |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 291 | |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 292 | template <typename T> |
| 293 | using CLScaleQuantizedFixture = ScaleValidationQuantizedFixture<CLTensor, CLAccessor, CLScale, T>; |
| 294 | TEST_SUITE(Quantized) |
| 295 | TEST_SUITE(QASYMM8) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 296 | FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 297 | framework::dataset::make("DataType", |
| 298 | DataType::QASYMM8)), |
| 299 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), |
| 300 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 301 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 302 | datasets::BorderModes()), |
| 303 | datasets::SamplingPolicies())) |
| 304 | { |
| 305 | //Create valid region |
| 306 | TensorInfo src_info(_shape, 1, _data_type); |
| 307 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 308 | |
| 309 | // Validate output |
| 310 | validate(CLAccessor(_target), _reference, valid_region, tolerance_u8); |
| 311 | } |
| 312 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), |
| 313 | 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 })), |
| 318 | datasets::BorderModes()), |
| 319 | datasets::SamplingPolicies())) |
| 320 | { |
| 321 | //Create valid region |
| 322 | TensorInfo src_info(_shape, 1, _data_type); |
| 323 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 324 | |
| 325 | // Validate output |
| 326 | validate(CLAccessor(_target), _reference, valid_region, tolerance_u8); |
| 327 | } |
| 328 | TEST_SUITE_END() // QASYMM8 |
| 329 | TEST_SUITE_END() // Quantized |
| 330 | |
| 331 | TEST_SUITE_END() // Scale |
| 332 | TEST_SUITE_END() // CL |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 333 | } // namespace validation |
| 334 | } // namespace test |
| 335 | } // namespace arm_compute |