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/NEON/functions/NEScale.h" |
| 27 | #include "arm_compute/runtime/Tensor.h" |
| 28 | #include "arm_compute/runtime/TensorAllocator.h" |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 29 | #include "tests/NEON/Accessor.h" |
| 30 | #include "tests/PaddingCalculator.h" |
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 | { |
Isabella Gottardi | 732f368 | 2017-09-05 14:10:12 +0100 | [diff] [blame] | 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; |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 51 | |
| 52 | /** We consider vector size in byte 64 since the maximum size of |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 53 | * a vector used by @ref NEScaleKernel is currently 64-byte (float32x4x4). |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 54 | * There are possibility to reduce test time further by using |
| 55 | * smaller vector sizes for different data types where applicable. |
| 56 | */ |
| 57 | constexpr uint32_t vector_byte = 64; |
| 58 | |
| 59 | template <typename T> |
| 60 | constexpr uint32_t num_elements_per_vector() |
| 61 | { |
| 62 | return vector_byte / sizeof(T); |
| 63 | } |
| 64 | |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 65 | /** Scale data types */ |
| 66 | const auto ScaleDataTypes = framework::dataset::make("DataType", |
| 67 | { |
| 68 | DataType::U8, |
| 69 | DataType::S16, |
| 70 | DataType::F32, |
| 71 | }); |
| 72 | |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 73 | /** Quantization information data set */ |
| 74 | const auto QuantizationInfoSet = framework::dataset::make("QuantizationInfo", |
| 75 | { |
| 76 | QuantizationInfo(0.5f, -10), |
| 77 | }); |
| 78 | |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 79 | /** Tolerance */ |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 80 | constexpr AbsoluteTolerance<uint8_t> tolerance_u8(1); |
| 81 | constexpr AbsoluteTolerance<int16_t> tolerance_s16(1); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 82 | RelativeTolerance<float> tolerance_f32(0.01); |
Georgios Pinitas | c47ef20 | 2018-11-16 18:19:43 +0000 | [diff] [blame] | 83 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 84 | RelativeTolerance<half> tolerance_f16(half(0.1)); |
| 85 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 86 | |
| 87 | constexpr float tolerance_num_s16 = 0.01f; |
| 88 | constexpr float tolerance_num_f32 = 0.01f; |
Isabella Gottardi | 732f368 | 2017-09-05 14:10:12 +0100 | [diff] [blame] | 89 | } // namespace |
| 90 | |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 91 | TEST_SUITE(NEON) |
| 92 | TEST_SUITE(Scale) |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 93 | TEST_SUITE(Validate) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 94 | |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 95 | /** Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros |
| 96 | * we use to check the validity of given arguments in @ref NEScale |
| 97 | * and subsequent call to @ref NEScaleKernel. |
| 98 | * Since this is using validate() of @ref NEScale, which pre-adjust |
| 99 | * arguments for @ref NEScaleKernel, the following conditions in |
| 100 | * the kernel are not currently tested. |
| 101 | * - The same input and output |
| 102 | * - Data type of offset, dx and dy |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 103 | * This suite also tests two different validate() APIs - one is |
| 104 | * using @ref ScaleKernelInfo and the other one is more verbose |
| 105 | * one calls the other one - in the same test case. Even though |
| 106 | * there are possibility that it makes debugging for regression |
| 107 | * harder, belows are reasons of this test case implementation. |
| 108 | * - The more verbose one is just a wrapper function calls |
| 109 | * the other one without any additional logic. So we are |
| 110 | * safe to merge two tests into one. |
| 111 | * - A large amount of code duplication is test suite can be prevented. |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 112 | */ |
| 113 | |
| 114 | const auto input_shape = TensorShape{ 2, 3, 3, 2 }; |
| 115 | const auto output_shape = TensorShape{ 4, 6, 3, 2 }; |
| 116 | |
| 117 | constexpr auto default_data_type = DataType::U8; |
| 118 | constexpr auto default_data_layout = DataLayout::NHWC; |
| 119 | constexpr auto default_interpolation_policy = InterpolationPolicy::NEAREST_NEIGHBOR; |
| 120 | constexpr auto default_border_mode = BorderMode::UNDEFINED; |
| 121 | constexpr auto default_sampling_policy = SamplingPolicy::CENTER; |
| 122 | constexpr bool default_use_padding = false; |
| 123 | |
| 124 | TEST_CASE(NullPtr, framework::DatasetMode::ALL) |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 125 | { |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 126 | const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout }; |
| 127 | const auto output = TensorInfo{ output_shape, 1, default_data_type, default_data_layout }; |
| 128 | Status result{}; |
Georgios Pinitas | 20b4313 | 2018-05-14 16:05:23 +0100 | [diff] [blame] | 129 | |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 130 | // nullptr is given as input |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 131 | result = NEScale::validate(nullptr, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode }); |
| 132 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 133 | |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 134 | // nullptr is given as output |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 135 | result = NEScale::validate(&input, nullptr, ScaleKernelInfo{ default_interpolation_policy, default_border_mode }); |
| 136 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | TEST_CASE(SupportDataType, framework::DatasetMode::ALL) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 140 | { |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 141 | const std::map<DataType, bool> supported_data_types = |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 142 | { |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 143 | { DataType::U8, true }, |
| 144 | { DataType::S8, false }, |
| 145 | { DataType::QSYMM8, false }, |
| 146 | { DataType::QASYMM8, true }, |
| 147 | { DataType::QASYMM8_SIGNED, true }, |
| 148 | { DataType::QSYMM8_PER_CHANNEL, false }, |
| 149 | { DataType::U16, false }, |
| 150 | { DataType::S16, true }, |
| 151 | { DataType::QSYMM16, false }, |
| 152 | { DataType::QASYMM16, false }, |
| 153 | { DataType::U32, false }, |
| 154 | { DataType::S32, false }, |
| 155 | { DataType::U64, false }, |
| 156 | { DataType::S64, false }, |
| 157 | { DataType::BFLOAT16, false }, |
| 158 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 159 | { DataType::F16, true }, |
| 160 | #else // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 161 | { DataType::F16, false }, |
| 162 | #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 163 | { DataType::F32, true }, |
| 164 | { DataType::F64, false }, |
| 165 | { DataType::SIZET, false }, |
| 166 | }; |
| 167 | Status result{}; |
| 168 | for(auto &kv : supported_data_types) |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 169 | { |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 170 | const auto input = TensorInfo{ input_shape, 1, kv.first, default_data_layout }; |
| 171 | const auto output = TensorInfo{ output_shape, 1, kv.first, default_data_layout }; |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 172 | |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 173 | result = NEScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode }); |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 174 | ARM_COMPUTE_EXPECT(bool(result) == kv.second, framework::LogLevel::ERRORS); |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 175 | } |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 176 | } |
| 177 | |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 178 | TEST_CASE(MissmatchingDataType, framework::DatasetMode::ALL) |
| 179 | { |
| 180 | constexpr auto non_default_data_type = DataType::F32; |
| 181 | |
| 182 | const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout }; |
| 183 | const auto output = TensorInfo{ output_shape, 1, non_default_data_type, default_data_layout }; |
| 184 | Status result{}; |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 185 | |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 186 | result = NEScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode }); |
| 187 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | TEST_CASE(UsePadding, framework::DatasetMode::ALL) |
| 191 | { |
| 192 | const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout }; |
| 193 | const auto output = TensorInfo{ output_shape, 1, default_data_type, default_data_layout }; |
| 194 | Status result{}; |
| 195 | |
| 196 | // When use padding is false, border mode should be constant |
| 197 | constexpr auto border_mode = BorderMode::UNDEFINED; |
| 198 | constexpr bool use_padding = false; |
| 199 | |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 200 | result = NEScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, border_mode, PixelValue(), default_sampling_policy, use_padding }); |
| 201 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | TEST_CASE(AreaWithNHWC, framework::DatasetMode::ALL) |
| 205 | { |
| 206 | // InterpolationPolicy::AREA is not supported for NHWC |
| 207 | constexpr auto interpolation_policy = InterpolationPolicy::AREA; |
| 208 | constexpr auto data_layout = DataLayout::NHWC; |
| 209 | |
| 210 | const auto input = TensorInfo{ input_shape, 1, default_data_type, data_layout }; |
| 211 | const auto output = TensorInfo{ output_shape, 1, default_data_type, data_layout }; |
| 212 | Status result{}; |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 213 | |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 214 | result = NEScale::validate(&input, &output, ScaleKernelInfo{ interpolation_policy, default_border_mode }); |
| 215 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | TEST_CASE(AreaWithNonU8, framework::DatasetMode::ALL) |
| 219 | { |
| 220 | // InterpolationPolicy::AREA only supports U8 |
| 221 | constexpr auto interpolation_policy = InterpolationPolicy::AREA; |
| 222 | constexpr auto data_type = DataType::F32; |
| 223 | constexpr auto data_layout = DataLayout::NCHW; |
| 224 | |
| 225 | const auto input = TensorInfo{ input_shape, 1, data_type, data_layout }; |
| 226 | const auto output = TensorInfo{ output_shape, 1, data_type, data_layout }; |
| 227 | Status result{}; |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 228 | |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 229 | result = NEScale::validate(&input, &output, ScaleKernelInfo{ interpolation_policy, default_border_mode }); |
| 230 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 231 | } |
| 232 | |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 233 | TEST_CASE(AlignedCornerNotSupported, framework::DatasetMode::ALL) |
| 234 | { |
| 235 | // Aligned corners require sampling policy to be TOP_LEFT. |
| 236 | constexpr auto interpolation_policy = InterpolationPolicy::BILINEAR; |
| 237 | constexpr bool align_corners = true; |
| 238 | constexpr auto sampling_policy = SamplingPolicy::CENTER; |
| 239 | |
| 240 | const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout }; |
| 241 | const auto output = TensorInfo{ output_shape, 1, default_data_type, default_data_layout }; |
| 242 | Status result{}; |
| 243 | |
| 244 | result = NEScale::validate(&input, &output, ScaleKernelInfo{ interpolation_policy, default_border_mode, PixelValue(), sampling_policy, default_use_padding, align_corners }); |
| 245 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 246 | } |
| 247 | |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 248 | TEST_CASE(InvalidAlignedCornerOutput, framework::DatasetMode::ALL) |
| 249 | { |
| 250 | // Bilinear with aligned corners require at least 2x2 output to prevent overflow. |
| 251 | // Also, aligned corners require sampling policy to be TOP_LEFT. |
| 252 | constexpr auto interpolation_policy = InterpolationPolicy::BILINEAR; |
| 253 | constexpr bool align_corners = true; |
| 254 | constexpr auto sampling_policy = SamplingPolicy::TOP_LEFT; |
| 255 | const auto invalid_output_shape = TensorShape{ 1, 1, 3, 2 }; |
| 256 | |
| 257 | const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout }; |
| 258 | const auto output = TensorInfo{ invalid_output_shape, 1, default_data_type, default_data_layout }; |
| 259 | Status result{}; |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 260 | |
Sang-Hoon Park | c261798 | 2020-05-20 22:13:47 +0100 | [diff] [blame] | 261 | result = NEScale::validate(&input, &output, ScaleKernelInfo{ interpolation_policy, default_border_mode, PixelValue(), sampling_policy, default_use_padding, align_corners }); |
| 262 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 263 | } |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 264 | TEST_SUITE_END() // Validate |
| 265 | |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 266 | template <typename T> |
| 267 | using NEScaleFixture = ScaleValidationFixture<Tensor, Accessor, NEScale, T>; |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 268 | template <typename T> |
| 269 | using NEScaleQuantizedFixture = ScaleValidationQuantizedFixture<Tensor, Accessor, NEScale, T>; |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 270 | |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 271 | TEST_SUITE(Float) |
| 272 | TEST_SUITE(FP32) |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 273 | const auto f32_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32)); |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 274 | FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 275 | { |
| 276 | //Create valid region |
| 277 | TensorInfo src_info(_shape, 1, _data_type); |
| 278 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 279 | |
| 280 | // Validate output |
| 281 | validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32); |
| 282 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 283 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleAlignCornersSamplingPolicySet)) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 284 | { |
| 285 | //Create valid region |
| 286 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 287 | 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] | 288 | |
| 289 | // Validate output |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 290 | validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 291 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 292 | TEST_SUITE_END() // FP32 |
Georgios Pinitas | c47ef20 | 2018-11-16 18:19:43 +0000 | [diff] [blame] | 293 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 294 | TEST_SUITE(FP16) |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 295 | const auto f16_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16)); |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 296 | FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 297 | { |
| 298 | //Create valid region |
| 299 | TensorInfo src_info(_shape, 1, _data_type); |
| 300 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 301 | |
| 302 | // Validate output |
| 303 | validate(Accessor(_target), _reference, valid_region, tolerance_f16); |
| 304 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 305 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleAlignCornersSamplingPolicySet)) |
Georgios Pinitas | c47ef20 | 2018-11-16 18:19:43 +0000 | [diff] [blame] | 306 | { |
| 307 | //Create valid region |
| 308 | TensorInfo src_info(_shape, 1, _data_type); |
| 309 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 310 | |
| 311 | // Validate output |
| 312 | validate(Accessor(_target), _reference, valid_region, tolerance_f16); |
| 313 | } |
| 314 | TEST_SUITE_END() // FP16 |
| 315 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 316 | TEST_SUITE_END() // Float |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 317 | |
| 318 | TEST_SUITE(Integer) |
| 319 | TEST_SUITE(U8) |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 320 | const auto u8_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8)); |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 321 | FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 322 | { |
| 323 | //Create valid region |
| 324 | TensorInfo src_info(_shape, 1, _data_type); |
| 325 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 326 | |
| 327 | // Validate output |
| 328 | validate(Accessor(_target), _reference, valid_region, tolerance_u8); |
| 329 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 330 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleAlignCornersSamplingPolicySet)) |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 331 | { |
| 332 | //Create valid region |
| 333 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 334 | 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] | 335 | |
| 336 | // Validate output |
Georgios Pinitas | 99d4f4a | 2017-09-19 16:51:42 +0100 | [diff] [blame] | 337 | validate(Accessor(_target), _reference, valid_region, tolerance_u8); |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 338 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 339 | TEST_SUITE_END() // U8 |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 340 | TEST_SUITE(S16) |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 341 | const auto s16_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16)); |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 342 | FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleSamplingPolicySet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 343 | { |
| 344 | //Create valid region |
| 345 | TensorInfo src_info(_shape, 1, _data_type); |
| 346 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 347 | |
| 348 | // Validate output |
| 349 | validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16); |
| 350 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 351 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleAlignCornersSamplingPolicySet)) |
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 | 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 |
Moritz Pflanzer | ff1c360 | 2017-09-22 12:41:25 +0100 | [diff] [blame] | 358 | validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16); |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 359 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 360 | TEST_SUITE_END() // S16 |
| 361 | TEST_SUITE_END() // Integer |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 362 | |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 363 | TEST_SUITE(Quantized) |
| 364 | TEST_SUITE(QASYMM8) |
Sang-Hoon Park | c72dabc | 2020-05-27 13:03:18 +0100 | [diff] [blame] | 365 | const auto qasymm8_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8)); |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 366 | FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleSamplingPolicySet, QuantizationInfoSet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 367 | { |
| 368 | //Create valid region |
| 369 | TensorInfo src_info(_shape, 1, _data_type); |
| 370 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 371 | |
| 372 | // Validate output |
| 373 | validate(Accessor(_target), _reference, valid_region, tolerance_u8); |
| 374 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 375 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleAlignCornersSamplingPolicySet, |
| 376 | QuantizationInfoSet)) |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 377 | { |
| 378 | //Create valid region |
| 379 | TensorInfo src_info(_shape, 1, _data_type); |
| 380 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 381 | |
| 382 | // Validate output |
| 383 | validate(Accessor(_target), _reference, valid_region, tolerance_u8); |
| 384 | } |
| 385 | TEST_SUITE_END() // QASYMM8 |
Sheri Zhang | 359c48e | 2020-04-30 22:53:39 +0100 | [diff] [blame] | 386 | TEST_SUITE(QASYMM8_SIGNED) |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 387 | const auto qasymm8_signed_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)); |
| 388 | constexpr AbsoluteTolerance<int8_t> tolerance_qasymm8_signed{ 1 }; |
| 389 | FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleSamplingPolicySet, QuantizationInfoSet)) |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 390 | { |
| 391 | //Create valid region |
| 392 | TensorInfo src_info(_shape, 1, _data_type); |
| 393 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 394 | |
| 395 | // Validate output |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 396 | validate(Accessor(_target), _reference, valid_region, tolerance_qasymm8_signed); |
Sang-Hoon Park | f025a77 | 2020-05-26 11:11:32 +0100 | [diff] [blame] | 397 | } |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 398 | FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleAlignCornersSamplingPolicySet, |
| 399 | QuantizationInfoSet)) |
Sheri Zhang | 359c48e | 2020-04-30 22:53:39 +0100 | [diff] [blame] | 400 | { |
| 401 | //Create valid region |
| 402 | TensorInfo src_info(_shape, 1, _data_type); |
| 403 | ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
| 404 | |
| 405 | // Validate output |
Sang-Hoon Park | 27a9e4f | 2020-06-08 19:21:34 +0100 | [diff] [blame] | 406 | validate(Accessor(_target), _reference, valid_region, tolerance_qasymm8_signed); |
Sheri Zhang | 359c48e | 2020-04-30 22:53:39 +0100 | [diff] [blame] | 407 | } |
| 408 | TEST_SUITE_END() // QASYMM8_SIGNED |
Vidhya Sudhan Loganathan | 3ac2f3a | 2019-01-17 15:16:19 +0000 | [diff] [blame] | 409 | TEST_SUITE_END() // Quantized |
| 410 | |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 411 | TEST_SUITE_END() // Scale |
| 412 | TEST_SUITE_END() // NEON |
Isabella Gottardi | 1fab09f | 2017-07-13 15:55:57 +0100 | [diff] [blame] | 413 | } // namespace validation |
| 414 | } // namespace test |
| 415 | } // namespace arm_compute |