Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 1 | /* |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 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 | |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 58 | /** Sampling policy data set */ |
| 59 | const auto SamplingPolicySet = combine(datasets::SamplingPolicies(), |
| 60 | framework::dataset::make("AlignCorners", { false })); |
| 61 | |
| 62 | /** Sampling policy data set for Aligned Corners which only allows TOP_LEFT poicy.*/ |
| 63 | const auto AlignCornersSamplingPolicySet = combine(framework::dataset::make("SamplingPolicy", |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 64 | { |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 65 | SamplingPolicy::TOP_LEFT, |
| 66 | }), |
| 67 | framework::dataset::make("AlignCorners", { true })); |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 68 | |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 69 | /** Tolerance */ |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 70 | constexpr AbsoluteTolerance<uint8_t> tolerance_q8(1); |
| 71 | constexpr AbsoluteTolerance<int8_t> tolerance_qs8(1); |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 72 | constexpr AbsoluteTolerance<int16_t> tolerance_s16(1); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 73 | constexpr float tolerance_f32_absolute(0.001f); |
| 74 | |
| 75 | RelativeTolerance<float> tolerance_f32(0.05); |
| 76 | RelativeTolerance<half> tolerance_f16(half(0.1)); |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 77 | |
| 78 | constexpr float tolerance_num_f32(0.01f); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 79 | } // namespace |
| 80 | |
| 81 | TEST_SUITE(CL) |
| 82 | TEST_SUITE(Scale) |
| 83 | |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 84 | // *INDENT-OFF* |
| 85 | // clang-format off |
| 86 | |
| 87 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( |
| 88 | framework::dataset::make("InputInfo",{ TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F16), |
| 89 | TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F32), |
| 90 | TensorInfo(TensorShape(36U, 36U, 2U, 4U), 1, DataType::U8), |
| 91 | TensorInfo(TensorShape(40U, 35U, 2U, 4U), 1, DataType::S16), |
| 92 | TensorInfo(TensorShape(37U, 37U, 2U), 1, DataType::F32), // window shrink |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 93 | TensorInfo(TensorShape(37U, 37U, 3U, 4U), 1, DataType::F32), // mismatching datatype |
| 94 | TensorInfo(TensorShape(28U, 33U, 2U), 1, DataType::F32), // policy area, scale factor not correct |
| 95 | }), |
| 96 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 68U, 2U), 1, DataType::F16), |
| 97 | TensorInfo(TensorShape(40U, 56U, 2U), 1, DataType::F32), |
| 98 | TensorInfo(TensorShape(40U, 76U, 2U, 4U), 1, DataType::U8), |
| 99 | TensorInfo(TensorShape(28U, 32U, 2U, 4U), 1, DataType::S16), |
| 100 | TensorInfo(TensorShape(39U, 55U, 2U), 1, DataType::F32), // window shrink |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 101 | TensorInfo(TensorShape(39U, 77U, 3U, 4U), 1, DataType::F16), // mismatching datatype |
| 102 | TensorInfo(TensorShape(26U, 21U, 2U), 1, DataType::F32), // policy area, scale factor not correct |
| 103 | })), |
| 104 | framework::dataset::make("Policy",{ InterpolationPolicy::BILINEAR, |
| 105 | InterpolationPolicy::BILINEAR, |
| 106 | InterpolationPolicy::NEAREST_NEIGHBOR, |
| 107 | InterpolationPolicy::NEAREST_NEIGHBOR, |
| 108 | InterpolationPolicy::NEAREST_NEIGHBOR, |
| 109 | InterpolationPolicy::BILINEAR, |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 110 | InterpolationPolicy::AREA, |
| 111 | })), |
| 112 | framework::dataset::make("BorderMode",{ BorderMode::UNDEFINED, |
| 113 | BorderMode::UNDEFINED, |
| 114 | BorderMode::UNDEFINED, |
| 115 | BorderMode::UNDEFINED, |
| 116 | BorderMode::UNDEFINED, |
| 117 | BorderMode::UNDEFINED, |
| 118 | BorderMode::UNDEFINED, |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 119 | })), |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 120 | framework::dataset::make("Expected", { true, true, true, true, false, false, false })), |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 121 | input_info, output_info, policy, border_mode, expected) |
| 122 | { |
| 123 | Status status = CLScale::validate(&input_info.clone()->set_is_resizable(false), |
| 124 | &output_info.clone()->set_is_resizable(false), policy, border_mode); |
| 125 | ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS); |
| 126 | } |
| 127 | |
| 128 | // clang-format on |
| 129 | // *INDENT-ON* |
| 130 | |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 131 | 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] | 132 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 133 | datasets::BorderModes()), |
| 134 | datasets::SamplingPolicies()), |
| 135 | shape, data_type, policy, border_mode, sampling_policy) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 136 | { |
| 137 | std::mt19937 generator(library->seed()); |
| 138 | std::uniform_real_distribution<float> distribution_float(0.25, 2); |
| 139 | const float scale_x = distribution_float(generator); |
| 140 | const float scale_y = distribution_float(generator); |
| 141 | std::uniform_int_distribution<uint8_t> distribution_u8(0, 255); |
| 142 | uint8_t constant_border_value = distribution_u8(generator); |
| 143 | |
| 144 | // Create tensors |
| 145 | CLTensor src = create_tensor<CLTensor>(shape, data_type); |
| 146 | TensorShape shape_scaled(shape); |
| 147 | shape_scaled.set(0, shape[0] * scale_x); |
| 148 | shape_scaled.set(1, shape[1] * scale_y); |
| 149 | CLTensor dst = create_tensor<CLTensor>(shape_scaled, data_type); |
| 150 | |
| 151 | ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 152 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 153 | |
| 154 | // Create and configure function |
| 155 | CLScale clscale; |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 156 | clscale.configure(&src, &dst, policy, border_mode, constant_border_value, sampling_policy); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 157 | |
Daniil Efremov | 7a49c79 | 2017-11-14 21:25:34 +0700 | [diff] [blame] | 158 | // Get border size depending on border mode |
| 159 | const BorderSize border_size(border_mode == BorderMode::UNDEFINED ? 0 : 1); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 160 | |
Daniil Efremov | 7a49c79 | 2017-11-14 21:25:34 +0700 | [diff] [blame] | 161 | // Validate valid region |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 162 | 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] | 163 | validate(dst.info()->valid_region(), dst_valid_region); |
| 164 | |
| 165 | // Validate padding |
| 166 | PaddingCalculator calculator(shape_scaled.x(), 4); |
| 167 | calculator.set_border_mode(border_mode); |
| 168 | |
Daniil Efremov | 7a49c79 | 2017-11-14 21:25:34 +0700 | [diff] [blame] | 169 | const PaddingSize read_padding(border_size); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 170 | const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); |
| 171 | validate(src.info()->padding(), read_padding); |
| 172 | validate(dst.info()->padding(), write_padding); |
| 173 | } |
| 174 | |
| 175 | template <typename T> |
| 176 | using CLScaleFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T>; |
| 177 | |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 178 | TEST_SUITE(Float) |
| 179 | TEST_SUITE(FP32) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 180 | 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] | 181 | DataType::F32)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 182 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 183 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 184 | datasets::BorderModes()), |
| 185 | SamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 186 | { |
| 187 | //Create valid region |
| 188 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 189 | 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] | 190 | |
| 191 | // Validate output |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 192 | 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] | 193 | } |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 194 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, 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] | 195 | DataType::F32)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 196 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 197 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 198 | datasets::BorderModes()), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 199 | AlignCornersSamplingPolicySet)) |
| 200 | { |
| 201 | //Create valid region |
| 202 | TensorInfo src_info(_shape, 1, _data_type); |
| 203 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 204 | |
| 205 | // Validate output |
| 206 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 207 | } |
| 208 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
| 209 | DataType::F32)), |
| 210 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 211 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 212 | datasets::BorderModes()), |
| 213 | SamplingPolicySet)) |
| 214 | { |
| 215 | //Create valid region |
| 216 | TensorInfo src_info(_shape, 1, _data_type); |
| 217 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 218 | |
| 219 | // Validate output |
| 220 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 221 | } |
| 222 | FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), |
| 223 | framework::dataset::make("DataType", |
| 224 | DataType::F32)), |
| 225 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 226 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 227 | datasets::BorderModes()), |
| 228 | AlignCornersSamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 229 | { |
| 230 | //Create valid region |
| 231 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 232 | 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] | 233 | |
| 234 | // Validate output |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 235 | 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] | 236 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 237 | TEST_SUITE_END() // FP32 |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 238 | TEST_SUITE(FP16) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 239 | 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] | 240 | DataType::F16)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 241 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 242 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 243 | datasets::BorderModes()), |
| 244 | SamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 245 | { |
| 246 | //Create valid region |
| 247 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 248 | 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] | 249 | |
| 250 | // Validate output |
| 251 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); |
| 252 | } |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 253 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), framework::dataset::make("DataType", |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 254 | DataType::F16)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 255 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 256 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 257 | datasets::BorderModes()), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 258 | AlignCornersSamplingPolicySet)) |
| 259 | { |
| 260 | //Create valid region |
| 261 | TensorInfo src_info(_shape, 1, _data_type); |
| 262 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 263 | |
| 264 | // Validate output |
| 265 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); |
| 266 | } |
| 267 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
| 268 | DataType::F16)), |
| 269 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 270 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 271 | datasets::BorderModes()), |
| 272 | SamplingPolicySet)) |
| 273 | { |
| 274 | //Create valid region |
| 275 | TensorInfo src_info(_shape, 1, _data_type); |
| 276 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 277 | |
| 278 | // Validate output |
| 279 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); |
| 280 | } |
| 281 | FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), |
| 282 | framework::dataset::make("DataType", |
| 283 | DataType::F16)), |
| 284 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 285 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 286 | datasets::BorderModes()), |
| 287 | AlignCornersSamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +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 | 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] | 292 | |
| 293 | // Validate output |
| 294 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); |
| 295 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 296 | TEST_SUITE_END() // FP16 |
| 297 | TEST_SUITE_END() // Float |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 298 | |
| 299 | TEST_SUITE(Integer) |
| 300 | TEST_SUITE(U8) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 301 | 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] | 302 | DataType::U8)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 303 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 304 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 305 | datasets::BorderModes()), |
| 306 | SamplingPolicySet)) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 307 | { |
| 308 | //Create valid region |
| 309 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 310 | 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] | 311 | |
| 312 | // Validate output |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 313 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 314 | } |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 315 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), |
| 316 | framework::dataset::make("DataType", |
| 317 | DataType::U8)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 318 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 319 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 320 | datasets::BorderModes()), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 321 | AlignCornersSamplingPolicySet)) |
| 322 | { |
| 323 | //Create valid region |
| 324 | TensorInfo src_info(_shape, 1, _data_type); |
| 325 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 326 | |
| 327 | // Validate output |
| 328 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 329 | } |
| 330 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
| 331 | DataType::U8)), |
| 332 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 333 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 334 | datasets::BorderModes()), |
| 335 | SamplingPolicySet)) |
| 336 | { |
| 337 | //Create valid region |
| 338 | TensorInfo src_info(_shape, 1, _data_type); |
| 339 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 340 | |
| 341 | // Validate output |
| 342 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 343 | } |
| 344 | FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), |
| 345 | framework::dataset::make("DataType", |
| 346 | DataType::U8)), |
| 347 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 348 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 349 | datasets::BorderModes()), |
| 350 | AlignCornersSamplingPolicySet)) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 351 | { |
| 352 | //Create valid region |
| 353 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 354 | 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] | 355 | |
| 356 | // Validate output |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 357 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 358 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 359 | TEST_SUITE_END() // U8 |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 360 | TEST_SUITE(S16) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 361 | 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] | 362 | DataType::S16)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 363 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 364 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 365 | datasets::BorderModes()), |
| 366 | SamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 367 | { |
| 368 | //Create valid region |
| 369 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 370 | 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] | 371 | |
| 372 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 373 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 374 | } |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 375 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), |
| 376 | framework::dataset::make("DataType", |
| 377 | DataType::S16)), |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 378 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Daniil Efremov | 02bf80d | 2017-11-22 00:26:51 +0700 | [diff] [blame] | 379 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 380 | datasets::BorderModes()), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 381 | AlignCornersSamplingPolicySet)) |
| 382 | { |
| 383 | //Create valid region |
| 384 | TensorInfo src_info(_shape, 1, _data_type); |
| 385 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 386 | |
| 387 | // Validate output |
| 388 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
| 389 | } |
| 390 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
| 391 | DataType::S16)), |
| 392 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 393 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 394 | datasets::BorderModes()), |
| 395 | SamplingPolicySet)) |
| 396 | { |
| 397 | //Create valid region |
| 398 | TensorInfo src_info(_shape, 1, _data_type); |
| 399 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 400 | |
| 401 | // Validate output |
| 402 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
| 403 | } |
| 404 | FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeShapes(), |
| 405 | framework::dataset::make("DataType", |
| 406 | DataType::S16)), |
| 407 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 408 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 409 | datasets::BorderModes()), |
| 410 | AlignCornersSamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 411 | { |
| 412 | //Create valid region |
| 413 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 414 | 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] | 415 | |
| 416 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 417 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 418 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 419 | TEST_SUITE_END() // S16 |
| 420 | TEST_SUITE_END() // Integer |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 421 | |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 422 | template <typename T> |
| 423 | using CLScaleQuantizedFixture = ScaleValidationQuantizedFixture<CLTensor, CLAccessor, CLScale, T>; |
| 424 | TEST_SUITE(Quantized) |
| 425 | TEST_SUITE(QASYMM8) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 426 | 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] | 427 | framework::dataset::make("DataType", |
| 428 | DataType::QASYMM8)), |
| 429 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), |
| 430 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 431 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 432 | datasets::BorderModes()), |
| 433 | SamplingPolicySet)) |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 434 | { |
| 435 | //Create valid region |
| 436 | TensorInfo src_info(_shape, 1, _data_type); |
| 437 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 438 | |
| 439 | // Validate output |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 440 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 441 | } |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 442 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, 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] | 443 | framework::dataset::make("DataType", |
| 444 | DataType::QASYMM8)), |
| 445 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), |
| 446 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 447 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 448 | datasets::BorderModes()), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 449 | AlignCornersSamplingPolicySet)) |
| 450 | { |
| 451 | //Create valid region |
| 452 | TensorInfo src_info(_shape, 1, _data_type); |
| 453 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 454 | |
| 455 | // Validate output |
| 456 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 457 | } |
| 458 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), |
| 459 | framework::dataset::make("DataType", |
| 460 | DataType::QASYMM8)), |
| 461 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), |
| 462 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 463 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 464 | datasets::BorderModes()), |
| 465 | SamplingPolicySet)) |
| 466 | { |
| 467 | //Create valid region |
| 468 | TensorInfo src_info(_shape, 1, _data_type); |
| 469 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 470 | |
| 471 | // Validate output |
| 472 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 473 | } |
| 474 | FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), |
| 475 | framework::dataset::make("DataType", |
| 476 | DataType::QASYMM8)), |
| 477 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), |
| 478 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 479 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 480 | datasets::BorderModes()), |
| 481 | AlignCornersSamplingPolicySet)) |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 482 | { |
| 483 | //Create valid region |
| 484 | TensorInfo src_info(_shape, 1, _data_type); |
| 485 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 486 | |
| 487 | // Validate output |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 488 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 489 | } |
| 490 | TEST_SUITE_END() // QASYMM8 |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 491 | TEST_SUITE(QASYMM8_SIGNED) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 492 | FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 493 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 494 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), |
| 495 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 496 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 497 | datasets::BorderModes()), |
| 498 | SamplingPolicySet)) |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 499 | { |
| 500 | //Create valid region |
| 501 | TensorInfo src_info(_shape, 1, _data_type); |
| 502 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 503 | |
| 504 | // Validate output |
| 505 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 506 | } |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 507 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::Tiny4DShapes(), |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 508 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 509 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), |
| 510 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 511 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 512 | datasets::BorderModes()), |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame^] | 513 | AlignCornersSamplingPolicySet)) |
| 514 | { |
| 515 | //Create valid region |
| 516 | TensorInfo src_info(_shape, 1, _data_type); |
| 517 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 518 | |
| 519 | // Validate output |
| 520 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 521 | } |
| 522 | FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), |
| 523 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 524 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), |
| 525 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 526 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 527 | datasets::BorderModes()), |
| 528 | SamplingPolicySet)) |
| 529 | { |
| 530 | //Create valid region |
| 531 | TensorInfo src_info(_shape, 1, _data_type); |
| 532 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 533 | |
| 534 | // Validate output |
| 535 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 536 | } |
| 537 | FIXTURE_DATA_TEST_CASE(RunLargeAlignCorners, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), |
| 538 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 539 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, -1) })), |
| 540 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 541 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), |
| 542 | datasets::BorderModes()), |
| 543 | AlignCornersSamplingPolicySet)) |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 544 | { |
| 545 | //Create valid region |
| 546 | TensorInfo src_info(_shape, 1, _data_type); |
| 547 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 548 | |
| 549 | // Validate output |
| 550 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 551 | } |
| 552 | TEST_SUITE_END() // QASYMM8_SIGNED |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 553 | TEST_SUITE_END() // Quantized |
| 554 | |
| 555 | TEST_SUITE_END() // Scale |
| 556 | TEST_SUITE_END() // CL |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 557 | } // namespace validation |
| 558 | } // namespace test |
| 559 | } // namespace arm_compute |