Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [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" |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 31 | #include "tests/datasets/ScaleValidationDataset.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 32 | #include "tests/framework/Asserts.h" |
| 33 | #include "tests/framework/Macros.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 34 | #include "tests/validation/Helpers.h" |
| 35 | #include "tests/validation/Validation.h" |
| 36 | #include "tests/validation/fixtures/ScaleFixture.h" |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 37 | |
| 38 | namespace arm_compute |
| 39 | { |
| 40 | namespace test |
| 41 | { |
| 42 | namespace validation |
| 43 | { |
| 44 | namespace |
| 45 | { |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 46 | using datasets::ScaleShapesBaseDataSet; |
| 47 | using datasets::ScaleInterpolationPolicySet; |
| 48 | using datasets::ScaleDataLayouts; |
| 49 | using datasets::ScaleSamplingPolicySet; |
| 50 | using datasets::ScaleAlignCornersSamplingPolicySet; |
| 51 | |
| 52 | /** We consider vector size in byte 16 since the maximum size of |
| 53 | * a vector used by @ref CLScaleKernel is currently 16-byte (float4). |
| 54 | */ |
| 55 | constexpr uint32_t vector_byte = 16; |
| 56 | |
| 57 | template <typename T> |
| 58 | constexpr uint32_t num_elements_per_vector() |
| 59 | { |
| 60 | return vector_byte / sizeof(T); |
| 61 | } |
| 62 | |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 63 | /** CNN data types */ |
| 64 | const auto ScaleDataTypes = framework::dataset::make("DataType", |
| 65 | { |
| 66 | DataType::U8, |
| 67 | DataType::S16, |
| 68 | DataType::F16, |
| 69 | DataType::F32, |
| 70 | }); |
| 71 | |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 72 | /** Quantization information data set */ |
| 73 | const auto QuantizationInfoSet = framework::dataset::make("QuantizationInfo", |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 74 | { |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 75 | QuantizationInfo(0.5f, -1), |
| 76 | }); |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 77 | |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 78 | /** Tolerance */ |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 79 | constexpr AbsoluteTolerance<uint8_t> tolerance_q8(1); |
| 80 | constexpr AbsoluteTolerance<int8_t> tolerance_qs8(1); |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 81 | constexpr AbsoluteTolerance<int16_t> tolerance_s16(1); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 82 | constexpr float tolerance_f32_absolute(0.001f); |
| 83 | |
| 84 | RelativeTolerance<float> tolerance_f32(0.05); |
| 85 | RelativeTolerance<half> tolerance_f16(half(0.1)); |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 86 | |
| 87 | constexpr float tolerance_num_f32(0.01f); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 88 | } // namespace |
| 89 | |
| 90 | TEST_SUITE(CL) |
| 91 | TEST_SUITE(Scale) |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 92 | TEST_SUITE(Validate) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 93 | |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 94 | const auto default_input_shape = TensorShape{ 2, 3, 3, 2 }; |
| 95 | const auto default_output_shape = TensorShape{ 4, 6, 3, 2 }; |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 96 | |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 97 | constexpr auto default_data_type = DataType::U8; |
| 98 | constexpr auto default_data_layout = DataLayout::NHWC; |
| 99 | constexpr auto default_interpolation_policy = InterpolationPolicy::NEAREST_NEIGHBOR; |
| 100 | constexpr auto default_border_mode = BorderMode::UNDEFINED; |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 101 | constexpr bool default_use_padding = false; |
| 102 | |
| 103 | TEST_CASE(NullPtr, framework::DatasetMode::ALL) |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 104 | { |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 105 | const auto input = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout }; |
| 106 | const auto output = TensorInfo{ default_output_shape, 1, default_data_type, default_data_layout }; |
| 107 | Status result{}; |
| 108 | |
| 109 | // nullptr is given as input |
| 110 | result = CLScale::validate(nullptr, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode }); |
| 111 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 112 | |
| 113 | // nullptr is given as output |
| 114 | result = CLScale::validate(&input, nullptr, ScaleKernelInfo{ default_interpolation_policy, default_border_mode }); |
| 115 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
Isabella Gottardi | 553b999 | 2018-09-03 12:17:47 +0100 | [diff] [blame] | 116 | } |
| 117 | |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 118 | TEST_CASE(SupportDataType, framework::DatasetMode::ALL) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 119 | { |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 120 | const std::map<DataType, bool> supported_data_types = |
| 121 | { |
| 122 | { DataType::U8, true }, |
| 123 | { DataType::S8, false }, |
| 124 | { DataType::QSYMM8, false }, |
| 125 | { DataType::QASYMM8, true }, |
| 126 | { DataType::QASYMM8_SIGNED, true }, |
| 127 | { DataType::QSYMM8_PER_CHANNEL, false }, |
| 128 | { DataType::U16, false }, |
| 129 | { DataType::S16, true }, |
| 130 | { DataType::QSYMM16, false }, |
| 131 | { DataType::QASYMM16, false }, |
| 132 | { DataType::U32, false }, |
| 133 | { DataType::S32, false }, |
| 134 | { DataType::U64, false }, |
| 135 | { DataType::S64, false }, |
| 136 | { DataType::BFLOAT16, false }, |
| 137 | { DataType::F16, true }, |
| 138 | { DataType::F32, true }, |
| 139 | { DataType::F64, false }, |
| 140 | { DataType::SIZET, false }, |
| 141 | }; |
| 142 | Status result{}; |
| 143 | for(auto &kv : supported_data_types) |
| 144 | { |
| 145 | const auto input = TensorInfo{ default_input_shape, 1, kv.first, default_data_layout }; |
| 146 | const auto output = TensorInfo{ default_output_shape, 1, kv.first, default_data_layout }; |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 147 | |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 148 | result = CLScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode }); |
| 149 | ARM_COMPUTE_EXPECT(bool(result) == kv.second, framework::LogLevel::ERRORS); |
| 150 | } |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 151 | } |
| 152 | |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 153 | TEST_CASE(SameInputOutput, framework::DatasetMode::ALL) |
| 154 | { |
| 155 | const auto input = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout }; |
| 156 | Status result{}; |
| 157 | |
| 158 | result = CLScale::validate(&input, &input, ScaleKernelInfo{ default_interpolation_policy, default_border_mode }); |
| 159 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 160 | } |
| 161 | |
| 162 | TEST_CASE(MissmatchingDataType, framework::DatasetMode::ALL) |
| 163 | { |
| 164 | constexpr auto non_default_data_type = DataType::F32; |
| 165 | |
| 166 | const auto input = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout }; |
| 167 | const auto output = TensorInfo{ default_output_shape, 1, non_default_data_type, default_data_layout }; |
| 168 | Status result{}; |
| 169 | |
| 170 | result = CLScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode }); |
| 171 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 172 | } |
| 173 | |
| 174 | TEST_CASE(AlignedCornerNotSupported, framework::DatasetMode::ALL) |
| 175 | { |
| 176 | // Aligned corners require sampling policy to be TOP_LEFT. |
| 177 | constexpr auto interpolation_policy = InterpolationPolicy::BILINEAR; |
| 178 | constexpr bool align_corners = true; |
| 179 | constexpr auto sampling_policy = SamplingPolicy::CENTER; |
| 180 | |
| 181 | const auto input = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout }; |
| 182 | const auto output = TensorInfo{ default_output_shape, 1, default_data_type, default_data_layout }; |
| 183 | Status result{}; |
| 184 | |
| 185 | result = CLScale::validate(&input, &output, ScaleKernelInfo{ interpolation_policy, default_border_mode, PixelValue(), sampling_policy, default_use_padding, align_corners }); |
| 186 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 187 | } |
| 188 | |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 189 | TEST_CASE(WindowShrink, framework::DatasetMode::ALL) |
| 190 | { |
| 191 | const auto input = TensorInfo{ TensorShape(37U, 37U, 2U), 1, DataType::F32 }; |
| 192 | const auto output = TensorInfo{ TensorShape(39U, 55U, 2U), 1, DataType::F32 }; |
| 193 | Status result{}; |
| 194 | |
| 195 | result = CLScale::validate(&input.clone()->set_is_resizable(false), &output.clone()->set_is_resizable(false), ScaleKernelInfo{ default_interpolation_policy, default_border_mode }); |
| 196 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 197 | } |
| 198 | |
| 199 | TEST_CASE(IncorrectScaleFactor, framework::DatasetMode::ALL) |
| 200 | { |
| 201 | const auto input = TensorInfo{ TensorShape(28U, 33U, 2U), 1, DataType::F32 }; |
| 202 | const auto output = TensorInfo{ TensorShape(26U, 21U, 2U), 1, DataType::F32 }; |
| 203 | constexpr auto interpolation_policy = InterpolationPolicy::AREA; |
| 204 | Status result{}; |
| 205 | |
| 206 | result = CLScale::validate(&input, &output, ScaleKernelInfo{ interpolation_policy, default_border_mode }); |
| 207 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 208 | } |
| 209 | TEST_SUITE_END() // Validate |
| 210 | |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 211 | template <typename T> |
| 212 | using CLScaleFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T>; |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame^] | 213 | template <typename T> |
| 214 | using CLScaleMixedDataLayoutFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T, true>; |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 215 | |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 216 | TEST_SUITE(Float) |
| 217 | TEST_SUITE(FP32) |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 218 | const auto f32_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32)); |
| 219 | FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleSamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 220 | { |
| 221 | //Create valid region |
| 222 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 223 | 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] | 224 | |
| 225 | // Validate output |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 226 | 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] | 227 | } |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame^] | 228 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLScaleMixedDataLayoutFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleSamplingPolicySet)) |
| 229 | { |
| 230 | //Create valid region |
| 231 | TensorInfo src_info(_shape, 1, _data_type); |
| 232 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 233 | |
| 234 | // Validate output |
| 235 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 236 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 237 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleAlignCornersSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 238 | { |
| 239 | //Create valid region |
| 240 | TensorInfo src_info(_shape, 1, _data_type); |
| 241 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 242 | |
| 243 | // Validate output |
| 244 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 245 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 246 | const auto f32_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32)); |
| 247 | FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f32_nightly_shape, ScaleSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 248 | { |
| 249 | //Create valid region |
| 250 | TensorInfo src_info(_shape, 1, _data_type); |
| 251 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 252 | |
| 253 | // Validate output |
| 254 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 255 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 256 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f32_nightly_shape, ScaleAlignCornersSamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 257 | { |
| 258 | //Create valid region |
| 259 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 260 | 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] | 261 | |
| 262 | // Validate output |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 263 | 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] | 264 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 265 | TEST_SUITE_END() // FP32 |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 266 | TEST_SUITE(FP16) |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 267 | const auto f16_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16)); |
| 268 | FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleSamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 269 | { |
| 270 | //Create valid region |
| 271 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 272 | 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] | 273 | |
| 274 | // Validate output |
| 275 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); |
| 276 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 277 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleAlignCornersSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 278 | { |
| 279 | //Create valid region |
| 280 | TensorInfo src_info(_shape, 1, _data_type); |
| 281 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 282 | |
| 283 | // Validate output |
| 284 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); |
| 285 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 286 | const auto f16_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16)); |
| 287 | FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f16_nightly_shape, ScaleSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 288 | { |
| 289 | //Create valid region |
| 290 | TensorInfo src_info(_shape, 1, _data_type); |
| 291 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 292 | |
| 293 | // Validate output |
| 294 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); |
| 295 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 296 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f16_nightly_shape, ScaleAlignCornersSamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 297 | { |
| 298 | //Create valid region |
| 299 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 300 | 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] | 301 | |
| 302 | // Validate output |
| 303 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16); |
| 304 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 305 | TEST_SUITE_END() // FP16 |
| 306 | TEST_SUITE_END() // Float |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 307 | |
| 308 | TEST_SUITE(Integer) |
| 309 | TEST_SUITE(U8) |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 310 | const auto u8_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8)); |
| 311 | FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleSamplingPolicySet)) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 312 | { |
| 313 | //Create valid region |
| 314 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 315 | 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] | 316 | |
| 317 | // Validate output |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 318 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 319 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 320 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleAlignCornersSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 321 | { |
| 322 | //Create valid region |
| 323 | TensorInfo src_info(_shape, 1, _data_type); |
| 324 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 325 | |
| 326 | // Validate output |
| 327 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 328 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 329 | const auto u8_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8)); |
| 330 | FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(u8_nightly_shape, ScaleSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 331 | { |
| 332 | //Create valid region |
| 333 | TensorInfo src_info(_shape, 1, _data_type); |
| 334 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 335 | |
| 336 | // Validate output |
| 337 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 338 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 339 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(u8_nightly_shape, ScaleAlignCornersSamplingPolicySet)) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 340 | { |
| 341 | //Create valid region |
| 342 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 343 | 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] | 344 | |
| 345 | // Validate output |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 346 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 347 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 348 | TEST_SUITE_END() // U8 |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 349 | TEST_SUITE(S16) |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 350 | const auto s16_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16)); |
| 351 | FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleSamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 352 | { |
| 353 | //Create valid region |
| 354 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 355 | 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] | 356 | |
| 357 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 358 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 359 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 360 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleAlignCornersSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 361 | { |
| 362 | //Create valid region |
| 363 | TensorInfo src_info(_shape, 1, _data_type); |
| 364 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 365 | |
| 366 | // Validate output |
| 367 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
| 368 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 369 | const auto s16_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16)); |
| 370 | FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(s16_nightly_shape, ScaleSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 371 | { |
| 372 | //Create valid region |
| 373 | TensorInfo src_info(_shape, 1, _data_type); |
| 374 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 375 | |
| 376 | // Validate output |
| 377 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
| 378 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 379 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(s16_nightly_shape, ScaleAlignCornersSamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 380 | { |
| 381 | //Create valid region |
| 382 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 383 | 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] | 384 | |
| 385 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 386 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 387 | } |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 388 | TEST_SUITE_END() // S16 |
| 389 | TEST_SUITE_END() // Integer |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 390 | |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 391 | template <typename T> |
| 392 | using CLScaleQuantizedFixture = ScaleValidationQuantizedFixture<CLTensor, CLAccessor, CLScale, T>; |
| 393 | TEST_SUITE(Quantized) |
| 394 | TEST_SUITE(QASYMM8) |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 395 | const auto qasymm8_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8)); |
| 396 | FIXTURE_DATA_TEST_CASE(Run, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleSamplingPolicySet, QuantizationInfoSet)) |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 397 | { |
| 398 | //Create valid region |
| 399 | TensorInfo src_info(_shape, 1, _data_type); |
| 400 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 401 | |
| 402 | // Validate output |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 403 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 404 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 405 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleAlignCornersSamplingPolicySet, |
| 406 | QuantizationInfoSet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 407 | { |
| 408 | //Create valid region |
| 409 | TensorInfo src_info(_shape, 1, _data_type); |
| 410 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 411 | |
| 412 | // Validate output |
| 413 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 414 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 415 | const auto qasymm8_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8)); |
| 416 | FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_nightly_shape, ScaleSamplingPolicySet, QuantizationInfoSet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 417 | { |
| 418 | //Create valid region |
| 419 | TensorInfo src_info(_shape, 1, _data_type); |
| 420 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 421 | |
| 422 | // Validate output |
| 423 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 424 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 425 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_nightly_shape, ScaleAlignCornersSamplingPolicySet, |
| 426 | QuantizationInfoSet)) |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 427 | { |
| 428 | //Create valid region |
| 429 | TensorInfo src_info(_shape, 1, _data_type); |
| 430 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 431 | |
| 432 | // Validate output |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 433 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 434 | } |
| 435 | TEST_SUITE_END() // QASYMM8 |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 436 | TEST_SUITE(QASYMM8_SIGNED) |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 437 | const auto qasymm8_signed_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)); |
| 438 | FIXTURE_DATA_TEST_CASE(Run, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleSamplingPolicySet, QuantizationInfoSet)) |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 439 | { |
| 440 | //Create valid region |
| 441 | TensorInfo src_info(_shape, 1, _data_type); |
| 442 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 443 | |
| 444 | // Validate output |
| 445 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 446 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 447 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleAlignCornersSamplingPolicySet, |
| 448 | QuantizationInfoSet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 449 | { |
| 450 | //Create valid region |
| 451 | TensorInfo src_info(_shape, 1, _data_type); |
| 452 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 453 | |
| 454 | // Validate output |
| 455 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 456 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 457 | const auto qasymm8_signed_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)); |
| 458 | FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_nightly_shape, ScaleSamplingPolicySet, |
| 459 | QuantizationInfoSet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 460 | { |
| 461 | //Create valid region |
| 462 | TensorInfo src_info(_shape, 1, _data_type); |
| 463 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 464 | |
| 465 | // Validate output |
| 466 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 467 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 468 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_nightly_shape, |
| 469 | ScaleAlignCornersSamplingPolicySet, |
| 470 | QuantizationInfoSet)) |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 471 | { |
| 472 | //Create valid region |
| 473 | TensorInfo src_info(_shape, 1, _data_type); |
| 474 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 475 | |
| 476 | // Validate output |
| 477 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 478 | } |
| 479 | TEST_SUITE_END() // QASYMM8_SIGNED |
Michalis Spyrou | 17220e2 | 2018-09-12 13:35:38 +0100 | [diff] [blame] | 480 | TEST_SUITE_END() // Quantized |
| 481 | |
| 482 | TEST_SUITE_END() // Scale |
| 483 | TEST_SUITE_END() // CL |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 484 | } // namespace validation |
| 485 | } // namespace test |
| 486 | } // namespace arm_compute |