Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 1 | /* |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 2 | * Copyright (c) 2022-2024 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" |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 32 | #include "tests/validation/fixtures/dynamic_fusion/operators/ResizeFixture.h" |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 33 | #include "tests/validation/Validation.h" |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 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 | { |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 44 | using datasets::ScaleAlignCornersSamplingPolicySet; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 45 | using datasets::ScaleInterpolationPolicySet; |
| 46 | using datasets::ScaleSamplingPolicySet; |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 47 | using datasets::ScaleShapesBaseDataSet; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 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", |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 62 | { |
| 63 | QuantizationInfo(0.5f, -1), |
| 64 | }); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 65 | |
| 66 | /** Tolerance */ |
Gunes Bayir | 2b9fa59 | 2024-01-17 16:07:03 +0000 | [diff] [blame^] | 67 | constexpr float tolerance_f32_absolute(0.001f); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 68 | |
| 69 | RelativeTolerance<float> tolerance_f32(0.05); |
| 70 | constexpr float abs_tolerance_f16(0.1f); |
| 71 | RelativeTolerance<half> tolerance_f16(half(0.1)); |
| 72 | |
| 73 | constexpr float tolerance_num_f32(0.01f); |
| 74 | |
| 75 | } // namespace |
| 76 | |
| 77 | TEST_SUITE(CL) |
| 78 | TEST_SUITE(DYNAMIC_FUSION) |
| 79 | TEST_SUITE(RESIZE) |
| 80 | |
| 81 | TEST_SUITE(Validate) |
| 82 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 83 | const auto default_input_shape = TensorShape{2, 3, 3, 2}; |
| 84 | const auto default_output_shape = TensorShape{4, 6, 3, 2}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 85 | |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 86 | constexpr auto default_data_type = DataType::U8; |
| 87 | constexpr auto default_data_layout = DataLayout::NHWC; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 88 | |
| 89 | TEST_CASE(NullPtr, framework::DatasetMode::ALL) |
| 90 | { |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 91 | const TensorInfo input_info = TensorInfo{default_input_shape, 1, default_data_type, default_data_layout}; |
| 92 | const TensorInfo output_info = TensorInfo{default_output_shape, 1, default_data_type, default_data_layout}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 93 | |
| 94 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 95 | GpuWorkloadContext context = GpuWorkloadContext{&cl_compile_ctx}; |
| 96 | GpuWorkloadSketch sketch{&context}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 97 | |
| 98 | // nullptr is given as input |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 99 | Status status = GpuResize::validate_op(sketch, nullptr, ResizeAttributes()); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 100 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 101 | } |
| 102 | |
| 103 | TEST_CASE(SupportDataType, framework::DatasetMode::ALL) |
| 104 | { |
Gunes Bayir | 2b9fa59 | 2024-01-17 16:07:03 +0000 | [diff] [blame^] | 105 | const std::map<DataType, bool> supported_data_types = |
| 106 | { |
| 107 | { DataType::U8, false }, |
| 108 | { DataType::S8, false }, |
| 109 | { DataType::QSYMM8, false }, |
| 110 | { DataType::QASYMM8, false }, |
| 111 | { DataType::QASYMM8_SIGNED, false }, |
| 112 | { DataType::QSYMM8_PER_CHANNEL, false }, |
| 113 | { DataType::U16, false }, |
| 114 | { DataType::S16, false }, |
| 115 | { DataType::QSYMM16, false }, |
| 116 | { DataType::QASYMM16, false }, |
| 117 | { DataType::U32, false }, |
| 118 | { DataType::S32, false }, |
| 119 | { DataType::U64, false }, |
| 120 | { DataType::S64, false }, |
| 121 | { DataType::BFLOAT16, false }, |
| 122 | { DataType::F16, true }, |
| 123 | { DataType::F32, true }, |
| 124 | { DataType::F64, false }, |
| 125 | { DataType::SIZET, false }, |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 128 | for (auto &kv : supported_data_types) |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 129 | { |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 130 | 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] | 131 | |
| 132 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 133 | GpuWorkloadContext context = GpuWorkloadContext{&cl_compile_ctx}; |
| 134 | GpuWorkloadSketch sketch{&context}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 135 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 136 | const ITensorInfo *sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 137 | |
Gunes Bayir | cc28773 | 2023-01-19 15:56:00 +0000 | [diff] [blame] | 138 | ResizeAttributes attributes; |
| 139 | attributes.output_width(default_output_shape[0]); // shape is not important unless it's empty |
| 140 | attributes.output_height(default_output_shape[1]); |
| 141 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 142 | Status status = GpuResize::validate_op(sketch, sketch_input_info, attributes); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 143 | ARM_COMPUTE_EXPECT(bool(status) == kv.second, framework::LogLevel::ERRORS); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | TEST_CASE(MismatchingDataType, framework::DatasetMode::ALL) |
| 148 | { |
| 149 | constexpr DataType non_default_data_type = DataType::F32; |
| 150 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 151 | const TensorInfo input_info = TensorInfo{default_input_shape, 1, default_data_type, default_data_layout}; |
| 152 | const TensorInfo output_info = TensorInfo{default_output_shape, 1, non_default_data_type, default_data_layout}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 153 | |
| 154 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 155 | GpuWorkloadContext context = GpuWorkloadContext{&cl_compile_ctx}; |
| 156 | GpuWorkloadSketch sketch{&context}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 157 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 158 | const ITensorInfo *sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 159 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 160 | Status status = GpuResize::validate_op(sketch, sketch_input_info, ResizeAttributes()); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 161 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 162 | } |
| 163 | |
| 164 | TEST_CASE(AlignedCornerNotSupported, framework::DatasetMode::ALL) |
| 165 | { |
| 166 | // Aligned corners require sampling policy to be TOP_LEFT. |
| 167 | constexpr InterpolationPolicy interpolation_policy = InterpolationPolicy::BILINEAR; |
| 168 | constexpr bool align_corners = true; |
| 169 | constexpr SamplingPolicy sampling_policy = SamplingPolicy::CENTER; |
| 170 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 171 | const TensorInfo input_info = TensorInfo{default_input_shape, 1, default_data_type, default_data_layout}; |
| 172 | const TensorInfo output_info = TensorInfo{default_output_shape, 1, default_data_type, default_data_layout}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 173 | |
| 174 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 175 | GpuWorkloadContext context = GpuWorkloadContext{&cl_compile_ctx}; |
| 176 | GpuWorkloadSketch sketch{&context}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 177 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 178 | const ITensorInfo *sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 179 | |
| 180 | ResizeAttributes attributes{}; |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 181 | attributes.interpolation_policy(interpolation_policy).sampling_policy(sampling_policy).align_corners(align_corners); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 182 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 183 | Status status = GpuResize::validate_op(sketch, sketch_input_info, attributes); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 184 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 185 | } |
| 186 | |
| 187 | TEST_CASE(UnsupportedInterpolationPolicy, framework::DatasetMode::ALL) |
| 188 | { |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 189 | const TensorInfo input_info = TensorInfo{TensorShape(28U, 33U, 2U), 1, DataType::F32, default_data_layout}; |
| 190 | const TensorInfo output_info = TensorInfo{TensorShape(26U, 21U, 2U), 1, DataType::F32, default_data_layout}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 191 | constexpr auto interpolation_policy = InterpolationPolicy::AREA; |
| 192 | |
| 193 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 194 | GpuWorkloadContext context = GpuWorkloadContext{&cl_compile_ctx}; |
| 195 | GpuWorkloadSketch sketch{&context}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 196 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 197 | const ITensorInfo *sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 198 | |
| 199 | ResizeAttributes attributes{}; |
| 200 | attributes.interpolation_policy(interpolation_policy); |
| 201 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 202 | Status status = GpuResize::validate_op(sketch, sketch_input_info, attributes); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 203 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 204 | } |
| 205 | |
| 206 | TEST_CASE(UnsupportedLayout, framework::DatasetMode::ALL) |
| 207 | { |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 208 | const TensorInfo input_info = TensorInfo{default_input_shape, 1, default_data_type, DataLayout::NCHW}; |
| 209 | const TensorInfo output_info = TensorInfo{default_output_shape, 1, default_data_type, DataLayout::NCHW}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 210 | constexpr auto interpolation_policy = InterpolationPolicy::BILINEAR; |
| 211 | |
| 212 | CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 213 | GpuWorkloadContext context = GpuWorkloadContext{&cl_compile_ctx}; |
| 214 | GpuWorkloadSketch sketch{&context}; |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 215 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 216 | const ITensorInfo *sketch_input_info = context.create_tensor_info(input_info); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 217 | |
| 218 | ResizeAttributes attributes{}; |
| 219 | attributes.interpolation_policy(interpolation_policy); |
| 220 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 221 | Status status = GpuResize::validate_op(sketch, sketch_input_info, attributes); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 222 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 223 | } |
| 224 | |
| 225 | TEST_SUITE_END() // Validate |
| 226 | |
| 227 | template <typename T> |
| 228 | using DynamicFusionResizeFixture = DynamicFusionResizeValidationFixture<CLTensor, CLAccessor, GpuResize, T>; |
| 229 | |
| 230 | TEST_SUITE(Float) |
| 231 | TEST_SUITE(FP32) |
| 232 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 233 | const auto f32_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<float>())), |
| 234 | framework::dataset::make("DataType", DataType::F32)); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 235 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 236 | FIXTURE_DATA_TEST_CASE(Run, |
| 237 | DynamicFusionResizeFixture<float>, |
| 238 | framework::DatasetMode::ALL, |
| 239 | ASSEMBLE_DATASET_DYNAMIC_FUSION(f32_shape, ScaleSamplingPolicySet)) |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 240 | { |
| 241 | //Create valid region |
| 242 | TensorInfo src_info(_shape, 1, _data_type); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 243 | const ValidRegion valid_region = |
| 244 | calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 245 | |
| 246 | // Validate output |
| 247 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 248 | } |
| 249 | |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 250 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, |
| 251 | DynamicFusionResizeFixture<float>, |
| 252 | framework::DatasetMode::ALL, |
| 253 | ASSEMBLE_DATASET_DYNAMIC_FUSION(f32_shape, ScaleAlignCornersSamplingPolicySet)) |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 254 | { |
| 255 | //Create valid region |
| 256 | TensorInfo src_info(_shape, 1, _data_type); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 257 | const ValidRegion valid_region = |
| 258 | calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 259 | |
| 260 | // Validate output |
| 261 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 262 | } |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 263 | const auto f32_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<float>())), |
| 264 | framework::dataset::make("DataType", DataType::F32)); |
| 265 | FIXTURE_DATA_TEST_CASE(RunNightly, |
| 266 | DynamicFusionResizeFixture<float>, |
| 267 | framework::DatasetMode::NIGHTLY, |
| 268 | ASSEMBLE_DATASET_DYNAMIC_FUSION(f32_nightly_shape, ScaleSamplingPolicySet)) |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 269 | { |
| 270 | //Create valid region |
| 271 | TensorInfo src_info(_shape, 1, _data_type); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 272 | const ValidRegion valid_region = |
| 273 | calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 274 | |
| 275 | // Validate output |
| 276 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 277 | } |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 278 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, |
| 279 | DynamicFusionResizeFixture<float>, |
| 280 | framework::DatasetMode::NIGHTLY, |
| 281 | ASSEMBLE_DATASET_DYNAMIC_FUSION(f32_nightly_shape, ScaleAlignCornersSamplingPolicySet)) |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 282 | { |
| 283 | //Create valid region |
| 284 | TensorInfo src_info(_shape, 1, _data_type); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 285 | const ValidRegion valid_region = |
| 286 | calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 287 | |
| 288 | // Validate output |
| 289 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute); |
| 290 | } |
| 291 | TEST_SUITE_END() // FP32 |
| 292 | |
| 293 | TEST_SUITE(FP16) |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 294 | const auto f16_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<half>())), |
| 295 | framework::dataset::make("DataType", DataType::F16)); |
| 296 | FIXTURE_DATA_TEST_CASE(Run, |
| 297 | DynamicFusionResizeFixture<half>, |
| 298 | framework::DatasetMode::ALL, |
| 299 | ASSEMBLE_DATASET_DYNAMIC_FUSION(f16_shape, ScaleSamplingPolicySet)) |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 300 | { |
| 301 | //Create valid region |
| 302 | TensorInfo src_info(_shape, 1, _data_type); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 303 | const ValidRegion valid_region = |
| 304 | calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 305 | |
| 306 | // Validate output |
| 307 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16); |
| 308 | } |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 309 | FIXTURE_DATA_TEST_CASE(RunAlignCorners, |
| 310 | DynamicFusionResizeFixture<half>, |
| 311 | framework::DatasetMode::ALL, |
| 312 | ASSEMBLE_DATASET_DYNAMIC_FUSION(f16_shape, ScaleAlignCornersSamplingPolicySet)) |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 313 | { |
| 314 | //Create valid region |
| 315 | TensorInfo src_info(_shape, 1, _data_type); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 316 | const ValidRegion valid_region = |
| 317 | calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 318 | |
| 319 | // Validate output |
| 320 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16); |
| 321 | } |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 322 | const auto f16_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<half>())), |
| 323 | framework::dataset::make("DataType", DataType::F16)); |
| 324 | FIXTURE_DATA_TEST_CASE(RunNightly, |
| 325 | DynamicFusionResizeFixture<half>, |
| 326 | framework::DatasetMode::NIGHTLY, |
| 327 | ASSEMBLE_DATASET_DYNAMIC_FUSION(f16_nightly_shape, ScaleSamplingPolicySet)) |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 328 | { |
| 329 | //Create valid region |
| 330 | TensorInfo src_info(_shape, 1, _data_type); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 331 | const ValidRegion valid_region = |
| 332 | calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 333 | |
| 334 | // Validate output |
| 335 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16); |
| 336 | } |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 337 | FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, |
| 338 | DynamicFusionResizeFixture<half>, |
| 339 | framework::DatasetMode::NIGHTLY, |
| 340 | ASSEMBLE_DATASET_DYNAMIC_FUSION(f16_nightly_shape, ScaleAlignCornersSamplingPolicySet)) |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 341 | { |
| 342 | //Create valid region |
| 343 | TensorInfo src_info(_shape, 1, _data_type); |
Viet-Hoa Do | fdf56fb | 2024-01-18 16:10:46 +0000 | [diff] [blame] | 344 | const ValidRegion valid_region = |
| 345 | calculate_valid_region_scale(src_info, _reference.shape(), _interpolation_policy, _sampling_policy, false); |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 346 | |
| 347 | // Validate output |
| 348 | validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16); |
| 349 | } |
| 350 | TEST_SUITE_END() // FP16 |
| 351 | TEST_SUITE_END() // Float |
| 352 | |
Jakub Sujak | 8ae5714 | 2022-12-02 16:09:06 +0000 | [diff] [blame] | 353 | TEST_SUITE_END() // RESIZE |
| 354 | TEST_SUITE_END() // DYNAMIC_FUSION |
| 355 | TEST_SUITE_END() // CL |
| 356 | |
| 357 | } // namespace validation |
| 358 | } // namespace test |
| 359 | } // namespace arm_compute |