Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 1 | /* |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 2 | * Copyright (c) 2022-2023 Arm Limited. |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [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 | |
| 25 | #include "arm_compute/dynamic_fusion/sketch/gpu/operators/GpuResize.h" |
| 26 | |
| 27 | #include "tests/CL/CLAccessor.h" |
| 28 | #include "tests/datasets/ScaleValidationDataset.h" |
| 29 | #include "tests/framework/Asserts.h" |
| 30 | #include "tests/framework/Fixture.h" |
| 31 | #include "tests/framework/Macros.h" |
| 32 | #include "tests/validation/Validation.h" |
| 33 | #include "tests/validation/fixtures/dynamic_fusion/operators/ResizeFixture.h" |
| 34 | |
| 35 | using namespace arm_compute::experimental::dynamic_fusion; |
| 36 | namespace arm_compute |
| 37 | { |
| 38 | namespace test |
| 39 | { |
| 40 | namespace validation |
| 41 | { |
| 42 | namespace |
| 43 | { |
| 44 | using datasets::ScaleShapesBaseDataSet; |
| 45 | using datasets::ScaleInterpolationPolicySet; |
| 46 | using datasets::ScaleSamplingPolicySet; |
| 47 | using datasets::ScaleAlignCornersSamplingPolicySet; |
| 48 | |
| 49 | /** We consider vector size in byte 16 since the maximum size of |
| 50 | * a vector used by @ref CLScaleKernel is currently 16-byte (float4). |
| 51 | */ |
| 52 | constexpr uint32_t vector_byte = 16; |
| 53 | |
| 54 | template <typename T> |
| 55 | constexpr uint32_t num_elements_per_vector() |
| 56 | { |
| 57 | return vector_byte / sizeof(T); |
| 58 | } |
| 59 | |
| 60 | /** Quantization information data set */ |
| 61 | const auto QuantizationInfoSet = framework::dataset::make("QuantizationInfo", |
| 62 | { |
| 63 | QuantizationInfo(0.5f, -1), |
| 64 | }); |
| 65 | |
| 66 | /** Tolerance */ |
| 67 | constexpr AbsoluteTolerance<uint8_t> tolerance_q8(1); |
| 68 | constexpr AbsoluteTolerance<int8_t> tolerance_qs8(1); |
| 69 | constexpr AbsoluteTolerance<int16_t> tolerance_s16(1); |
| 70 | constexpr float tolerance_f32_absolute(0.001f); |
| 71 | |
| 72 | RelativeTolerance<float> tolerance_f32(0.05); |
| 73 | constexpr float abs_tolerance_f16(0.1f); |
| 74 | RelativeTolerance<half> tolerance_f16(half(0.1)); |
| 75 | |
| 76 | constexpr float tolerance_num_f32(0.01f); |
| 77 | |
| 78 | } // namespace |
| 79 | |
| 80 | TEST_SUITE(CL) |
| 81 | TEST_SUITE(DYNAMIC_FUSION) |
| 82 | TEST_SUITE(RESIZE) |
| 83 | |
| 84 | TEST_SUITE(Validate) |
| 85 | |
| 86 | const auto default_input_shape = TensorShape{ 2, 3, 3, 2 }; |
| 87 | const auto default_output_shape = TensorShape{ 4, 6, 3, 2 }; |
| 88 | |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 89 | constexpr auto default_data_type = DataType::U8; |
| 90 | constexpr auto default_data_layout = DataLayout::NHWC; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 91 | |
| 92 | TEST_CASE(NullPtr, framework::DatasetMode::ALL) |
| 93 | { |
| 94 | const TensorInfo input_info = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout }; |
| 95 | const TensorInfo output_info = TensorInfo{ default_output_shape, 1, default_data_type, default_data_layout }; |
| 96 | |
| 97 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 98 | GpuWorkloadContext context = GpuWorkloadContext{ &cl_compile_ctx }; |
| 99 | GpuWorkloadSketch sketch{ &context }; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 100 | |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 101 | const TensorInfo sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 102 | |
| 103 | // nullptr is given as input |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 104 | Status status = GpuResize::validate_op(sketch, nullptr, ResizeAttributes()); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 105 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 106 | } |
| 107 | |
| 108 | TEST_CASE(SupportDataType, framework::DatasetMode::ALL) |
| 109 | { |
| 110 | const std::map<DataType, bool> supported_data_types = |
| 111 | { |
| 112 | { DataType::U8, true }, |
| 113 | { DataType::S8, false }, |
| 114 | { DataType::QSYMM8, false }, |
| 115 | { DataType::QASYMM8, true }, |
| 116 | { DataType::QASYMM8_SIGNED, true }, |
| 117 | { DataType::QSYMM8_PER_CHANNEL, false }, |
| 118 | { DataType::U16, false }, |
| 119 | { DataType::S16, true }, |
| 120 | { DataType::QSYMM16, false }, |
| 121 | { DataType::QASYMM16, false }, |
| 122 | { DataType::U32, false }, |
| 123 | { DataType::S32, false }, |
| 124 | { DataType::U64, false }, |
| 125 | { DataType::S64, false }, |
| 126 | { DataType::BFLOAT16, false }, |
| 127 | { DataType::F16, true }, |
| 128 | { DataType::F32, true }, |
| 129 | { DataType::F64, false }, |
| 130 | { DataType::SIZET, false }, |
| 131 | }; |
| 132 | |
| 133 | for(auto &kv : supported_data_types) |
| 134 | { |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 135 | const TensorInfo input_info = TensorInfo{ default_input_shape, 1, kv.first, default_data_layout }; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 136 | |
| 137 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 138 | GpuWorkloadContext context = GpuWorkloadContext{ &cl_compile_ctx }; |
| 139 | GpuWorkloadSketch sketch{ &context }; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 140 | |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 141 | const TensorInfo sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 142 | |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 143 | ResizeAttributes attributes; |
| 144 | attributes.output_width(default_output_shape[0]); // shape is not important unless it's empty |
| 145 | attributes.output_height(default_output_shape[1]); |
| 146 | |
| 147 | Status status = GpuResize::validate_op(sketch, &sketch_input_info, attributes); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 148 | ARM_COMPUTE_EXPECT(bool(status) == kv.second, framework::LogLevel::ERRORS); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | TEST_CASE(MismatchingDataType, framework::DatasetMode::ALL) |
| 153 | { |
| 154 | constexpr DataType non_default_data_type = DataType::F32; |
| 155 | |
| 156 | const TensorInfo input_info = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout }; |
| 157 | const TensorInfo output_info = TensorInfo{ default_output_shape, 1, non_default_data_type, default_data_layout }; |
| 158 | |
| 159 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 160 | GpuWorkloadContext context = GpuWorkloadContext{ &cl_compile_ctx }; |
| 161 | GpuWorkloadSketch sketch{ &context }; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 162 | |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 163 | const TensorInfo sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 164 | |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 165 | Status status = GpuResize::validate_op(sketch, &sketch_input_info, ResizeAttributes()); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 166 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 167 | } |
| 168 | |
| 169 | TEST_CASE(AlignedCornerNotSupported, framework::DatasetMode::ALL) |
| 170 | { |
| 171 | // Aligned corners require sampling policy to be TOP_LEFT. |
| 172 | constexpr InterpolationPolicy interpolation_policy = InterpolationPolicy::BILINEAR; |
| 173 | constexpr bool align_corners = true; |
| 174 | constexpr SamplingPolicy sampling_policy = SamplingPolicy::CENTER; |
| 175 | |
| 176 | const TensorInfo input_info = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout }; |
| 177 | const TensorInfo output_info = TensorInfo{ default_output_shape, 1, default_data_type, default_data_layout }; |
| 178 | |
| 179 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 180 | GpuWorkloadContext context = GpuWorkloadContext{ &cl_compile_ctx }; |
| 181 | GpuWorkloadSketch sketch{ &context }; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 182 | |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 183 | const TensorInfo sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 184 | |
| 185 | ResizeAttributes attributes{}; |
| 186 | attributes.interpolation_policy(interpolation_policy) |
| 187 | .sampling_policy(sampling_policy) |
| 188 | .align_corners(align_corners); |
| 189 | |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 190 | Status status = GpuResize::validate_op(sketch, &sketch_input_info, attributes); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 191 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 192 | } |
| 193 | |
| 194 | TEST_CASE(UnsupportedInterpolationPolicy, framework::DatasetMode::ALL) |
| 195 | { |
| 196 | const TensorInfo input_info = TensorInfo{ TensorShape(28U, 33U, 2U), 1, DataType::F32, default_data_layout }; |
| 197 | const TensorInfo output_info = TensorInfo{ TensorShape(26U, 21U, 2U), 1, DataType::F32, default_data_layout }; |
| 198 | constexpr auto interpolation_policy = InterpolationPolicy::AREA; |
| 199 | |
| 200 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 201 | GpuWorkloadContext context = GpuWorkloadContext{ &cl_compile_ctx }; |
| 202 | GpuWorkloadSketch sketch{ &context }; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 203 | |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 204 | const TensorInfo sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 205 | |
| 206 | ResizeAttributes attributes{}; |
| 207 | attributes.interpolation_policy(interpolation_policy); |
| 208 | |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 209 | Status status = GpuResize::validate_op(sketch, &sketch_input_info, attributes); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 210 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 211 | } |
| 212 | |
| 213 | TEST_CASE(UnsupportedLayout, framework::DatasetMode::ALL) |
| 214 | { |
| 215 | const TensorInfo input_info = TensorInfo{ default_input_shape, 1, default_data_type, DataLayout::NCHW }; |
| 216 | const TensorInfo output_info = TensorInfo{ default_output_shape, 1, default_data_type, DataLayout::NCHW }; |
| 217 | constexpr auto interpolation_policy = InterpolationPolicy::BILINEAR; |
| 218 | |
| 219 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 220 | GpuWorkloadContext context = GpuWorkloadContext{ &cl_compile_ctx }; |
| 221 | GpuWorkloadSketch sketch{ &context }; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 222 | |
Viet-Hoa Do | 3fcf3dc | 2023-05-17 15:17:48 +0100 | [diff] [blame] | 223 | const TensorInfo sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 224 | |
| 225 | ResizeAttributes attributes{}; |
| 226 | attributes.interpolation_policy(interpolation_policy); |
| 227 | |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 228 | Status status = GpuResize::validate_op(sketch, &sketch_input_info, attributes); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 229 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 230 | } |
| 231 | |
| 232 | TEST_SUITE_END() // Validate |
| 233 | |
| 234 | template <typename T> |
| 235 | using DynamicFusionResizeFixture = DynamicFusionResizeValidationFixture<CLTensor, CLAccessor, GpuResize, T>; |
| 236 | |
| 237 | TEST_SUITE(Float) |
| 238 | TEST_SUITE(FP32) |
| 239 | |
| 240 | const auto f32_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32)); |
| 241 | |
| 242 | FIXTURE_DATA_TEST_CASE(Run, DynamicFusionResizeFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET_DYNAMIC_FUSION(f32_shape, ScaleSamplingPolicySet)) |
| 243 | { |
| 244 | //Create valid region |
| 245 | TensorInfo src_info(_shape, 1, _data_type); |
| 246 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 247 | |
| 248 | // Validate output |
| 249 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 250 | } |
| 251 | |
| 252 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, DynamicFusionResizeFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET_DYNAMIC_FUSION(f32_shape, ScaleAlignCornersSamplingPolicySet)) |
| 253 | { |
| 254 | //Create valid region |
| 255 | TensorInfo src_info(_shape, 1, _data_type); |
| 256 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 257 | |
| 258 | // Validate output |
| 259 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 260 | } |
| 261 | const auto f32_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32)); |
| 262 | FIXTURE_DATA_TEST_CASE(RunNightly, DynamicFusionResizeFixture<float>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET_DYNAMIC_FUSION(f32_nightly_shape, ScaleSamplingPolicySet)) |
| 263 | { |
| 264 | //Create valid region |
| 265 | TensorInfo src_info(_shape, 1, _data_type); |
| 266 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 267 | |
| 268 | // Validate output |
| 269 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 270 | } |
| 271 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, DynamicFusionResizeFixture<float>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET_DYNAMIC_FUSION(f32_nightly_shape, |
| 272 | ScaleAlignCornersSamplingPolicySet)) |
| 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(), _interpolation_policy, _sampling_policy, false); |
| 277 | |
| 278 | // Validate output |
| 279 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 280 | } |
| 281 | TEST_SUITE_END() // FP32 |
| 282 | |
| 283 | TEST_SUITE(FP16) |
| 284 | const auto f16_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16)); |
| 285 | FIXTURE_DATA_TEST_CASE(Run, DynamicFusionResizeFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET_DYNAMIC_FUSION(f16_shape, ScaleSamplingPolicySet)) |
| 286 | { |
| 287 | //Create valid region |
| 288 | TensorInfo src_info(_shape, 1, _data_type); |
| 289 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 290 | |
| 291 | // Validate output |
| 292 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16); |
| 293 | } |
| 294 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, DynamicFusionResizeFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET_DYNAMIC_FUSION(f16_shape, ScaleAlignCornersSamplingPolicySet)) |
| 295 | { |
| 296 | //Create valid region |
| 297 | TensorInfo src_info(_shape, 1, _data_type); |
| 298 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 299 | |
| 300 | // Validate output |
| 301 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16); |
| 302 | } |
| 303 | const auto f16_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16)); |
| 304 | FIXTURE_DATA_TEST_CASE(RunNightly, DynamicFusionResizeFixture<half>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET_DYNAMIC_FUSION(f16_nightly_shape, ScaleSamplingPolicySet)) |
| 305 | { |
| 306 | //Create valid region |
| 307 | TensorInfo src_info(_shape, 1, _data_type); |
| 308 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 309 | |
| 310 | // Validate output |
| 311 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16); |
| 312 | } |
| 313 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, DynamicFusionResizeFixture<half>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET_DYNAMIC_FUSION(f16_nightly_shape, |
| 314 | ScaleAlignCornersSamplingPolicySet)) |
| 315 | { |
| 316 | //Create valid region |
| 317 | TensorInfo src_info(_shape, 1, _data_type); |
| 318 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 319 | |
| 320 | // Validate output |
| 321 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16); |
| 322 | } |
| 323 | TEST_SUITE_END() // FP16 |
| 324 | TEST_SUITE_END() // Float |
| 325 | |
| 326 | TEST_SUITE(Integer) |
| 327 | TEST_SUITE(U8) |
| 328 | const auto u8_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8)); |
| 329 | FIXTURE_DATA_TEST_CASE(Run, DynamicFusionResizeFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET_DYNAMIC_FUSION(u8_shape, ScaleSamplingPolicySet)) |
| 330 | { |
| 331 | //Create valid region |
| 332 | TensorInfo src_info(_shape, 1, _data_type); |
| 333 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 334 | |
| 335 | // Validate output |
| 336 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 337 | } |
| 338 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, DynamicFusionResizeFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET_DYNAMIC_FUSION(u8_shape, ScaleAlignCornersSamplingPolicySet)) |
| 339 | { |
| 340 | //Create valid region |
| 341 | TensorInfo src_info(_shape, 1, _data_type); |
| 342 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 343 | |
| 344 | // Validate output |
| 345 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 346 | } |
| 347 | const auto u8_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8)); |
| 348 | FIXTURE_DATA_TEST_CASE(RunNightly, DynamicFusionResizeFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET_DYNAMIC_FUSION(u8_nightly_shape, ScaleSamplingPolicySet)) |
| 349 | { |
| 350 | //Create valid region |
| 351 | TensorInfo src_info(_shape, 1, _data_type); |
| 352 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 353 | |
| 354 | // Validate output |
| 355 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 356 | } |
| 357 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, DynamicFusionResizeFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET_DYNAMIC_FUSION(u8_nightly_shape, |
| 358 | ScaleAlignCornersSamplingPolicySet)) |
| 359 | { |
| 360 | //Create valid region |
| 361 | TensorInfo src_info(_shape, 1, _data_type); |
| 362 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 363 | |
| 364 | // Validate output |
| 365 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 366 | } |
| 367 | TEST_SUITE_END() // U8 |
| 368 | |
| 369 | TEST_SUITE(S16) |
| 370 | const auto s16_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16)); |
| 371 | FIXTURE_DATA_TEST_CASE(Run, DynamicFusionResizeFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET_DYNAMIC_FUSION(s16_shape, ScaleSamplingPolicySet)) |
| 372 | { |
| 373 | //Create valid region |
| 374 | TensorInfo src_info(_shape, 1, _data_type); |
| 375 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 376 | |
| 377 | // Validate output |
| 378 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
| 379 | } |
| 380 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, DynamicFusionResizeFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET_DYNAMIC_FUSION(s16_shape, ScaleAlignCornersSamplingPolicySet)) |
| 381 | { |
| 382 | //Create valid region |
| 383 | TensorInfo src_info(_shape, 1, _data_type); |
| 384 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 385 | |
| 386 | // Validate output |
| 387 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
| 388 | } |
| 389 | const auto s16_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16)); |
| 390 | FIXTURE_DATA_TEST_CASE(RunNightly, DynamicFusionResizeFixture<int16_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET_DYNAMIC_FUSION(s16_nightly_shape, ScaleSamplingPolicySet)) |
| 391 | { |
| 392 | //Create valid region |
| 393 | TensorInfo src_info(_shape, 1, _data_type); |
| 394 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 395 | |
| 396 | // Validate output |
| 397 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
| 398 | } |
| 399 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, DynamicFusionResizeFixture<int16_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET_DYNAMIC_FUSION(s16_nightly_shape, |
| 400 | ScaleAlignCornersSamplingPolicySet)) |
| 401 | { |
| 402 | //Create valid region |
| 403 | TensorInfo src_info(_shape, 1, _data_type); |
| 404 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 405 | |
| 406 | // Validate output |
| 407 | validate(CLAccessor(_target), _reference, valid_region, tolerance_s16); |
| 408 | } |
| 409 | TEST_SUITE_END() // S16 |
| 410 | TEST_SUITE_END() // Integer |
| 411 | |
| 412 | template <typename T> |
| 413 | using DynamicFusionResizeQuantizedFixture = DynamicFusionResizeQuantizedValidationFixture<CLTensor, CLAccessor, GpuResize, T>; |
| 414 | TEST_SUITE(Quantized) |
| 415 | TEST_SUITE(QASYMM8) |
| 416 | const auto qasymm8_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8)); |
| 417 | FIXTURE_DATA_TEST_CASE(Run, DynamicFusionResizeQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET_DYNAMIC_FUSION(qasymm8_shape, ScaleSamplingPolicySet, |
| 418 | QuantizationInfoSet)) |
| 419 | { |
| 420 | //Create valid region |
| 421 | TensorInfo src_info(_shape, 1, _data_type); |
| 422 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 423 | |
| 424 | // Validate output |
| 425 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 426 | } |
| 427 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, DynamicFusionResizeQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET_DYNAMIC_FUSION(qasymm8_shape, |
| 428 | ScaleAlignCornersSamplingPolicySet, |
| 429 | QuantizationInfoSet)) |
| 430 | { |
| 431 | //Create valid region |
| 432 | TensorInfo src_info(_shape, 1, _data_type); |
| 433 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 434 | |
| 435 | // Validate output |
| 436 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 437 | } |
| 438 | const auto qasymm8_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8)); |
| 439 | FIXTURE_DATA_TEST_CASE(RunNightly, DynamicFusionResizeQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET_DYNAMIC_FUSION(qasymm8_nightly_shape, |
| 440 | ScaleSamplingPolicySet, |
| 441 | QuantizationInfoSet)) |
| 442 | { |
| 443 | //Create valid region |
| 444 | TensorInfo src_info(_shape, 1, _data_type); |
| 445 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 446 | |
| 447 | // Validate output |
| 448 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 449 | } |
| 450 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, DynamicFusionResizeQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET_DYNAMIC_FUSION(qasymm8_nightly_shape, |
| 451 | ScaleAlignCornersSamplingPolicySet, |
| 452 | QuantizationInfoSet)) |
| 453 | { |
| 454 | //Create valid region |
| 455 | TensorInfo src_info(_shape, 1, _data_type); |
| 456 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 457 | |
| 458 | // Validate output |
| 459 | validate(CLAccessor(_target), _reference, valid_region, tolerance_q8); |
| 460 | } |
| 461 | TEST_SUITE_END() // QASYMM8 |
| 462 | |
| 463 | TEST_SUITE(QASYMM8_SIGNED) |
| 464 | const auto qasymm8_signed_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)); |
| 465 | FIXTURE_DATA_TEST_CASE(Run, DynamicFusionResizeQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET_DYNAMIC_FUSION(qasymm8_signed_shape, ScaleSamplingPolicySet, |
| 466 | QuantizationInfoSet)) |
| 467 | { |
| 468 | //Create valid region |
| 469 | TensorInfo src_info(_shape, 1, _data_type); |
| 470 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 471 | |
| 472 | // Validate output |
| 473 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 474 | } |
| 475 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, DynamicFusionResizeQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET_DYNAMIC_FUSION(qasymm8_signed_shape, |
| 476 | ScaleAlignCornersSamplingPolicySet, |
| 477 | QuantizationInfoSet)) |
| 478 | { |
| 479 | //Create valid region |
| 480 | TensorInfo src_info(_shape, 1, _data_type); |
| 481 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 482 | |
| 483 | // Validate output |
| 484 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 485 | } |
| 486 | const auto qasymm8_signed_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)); |
| 487 | FIXTURE_DATA_TEST_CASE(RunNightly, DynamicFusionResizeQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET_DYNAMIC_FUSION(qasymm8_signed_nightly_shape, |
| 488 | ScaleSamplingPolicySet, |
| 489 | QuantizationInfoSet)) |
| 490 | { |
| 491 | //Create valid region |
| 492 | TensorInfo src_info(_shape, 1, _data_type); |
| 493 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 494 | |
| 495 | // Validate output |
| 496 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 497 | } |
| 498 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, DynamicFusionResizeQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET_DYNAMIC_FUSION(qasymm8_signed_nightly_shape, |
| 499 | ScaleAlignCornersSamplingPolicySet, |
| 500 | QuantizationInfoSet)) |
| 501 | { |
| 502 | //Create valid region |
| 503 | TensorInfo src_info(_shape, 1, _data_type); |
| 504 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
| 505 | |
| 506 | // Validate output |
| 507 | validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8); |
| 508 | } |
| 509 | TEST_SUITE_END() // QASYMM8_SIGNED |
| 510 | |
| 511 | TEST_SUITE_END() // Quantized |
| 512 | |
| 513 | TEST_SUITE_END() // RESIZE |
| 514 | TEST_SUITE_END() // DYNAMIC_FUSION |
| 515 | TEST_SUITE_END() // CL |
| 516 | |
| 517 | } // namespace validation |
| 518 | } // namespace test |
| 519 | } // namespace arm_compute |