Frank Lei | 57a150a | 2017-12-19 10:14:57 +0800 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 Arm Limited. |
Frank Lei | 57a150a | 2017-12-19 10:14:57 +0800 | [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/GLES_COMPUTE/functions/GCScale.h" |
| 27 | #include "arm_compute/runtime/Tensor.h" |
| 28 | #include "arm_compute/runtime/TensorAllocator.h" |
| 29 | #include "tests/GLES_COMPUTE/GCAccessor.h" |
| 30 | #include "tests/PaddingCalculator.h" |
| 31 | #include "tests/datasets/BorderModeDataset.h" |
| 32 | #include "tests/datasets/SamplingPolicyDataset.h" |
| 33 | #include "tests/datasets/ShapeDatasets.h" |
| 34 | #include "tests/framework/Asserts.h" |
| 35 | #include "tests/framework/Macros.h" |
| 36 | #include "tests/framework/datasets/Datasets.h" |
| 37 | #include "tests/validation/Helpers.h" |
| 38 | #include "tests/validation/Validation.h" |
| 39 | #include "tests/validation/fixtures/ScaleFixture.h" |
| 40 | |
| 41 | namespace arm_compute |
| 42 | { |
| 43 | namespace test |
| 44 | { |
| 45 | namespace validation |
| 46 | { |
| 47 | namespace |
| 48 | { |
| 49 | /** CNN data types */ |
| 50 | const auto ScaleDataTypes = framework::dataset::make("DataType", |
| 51 | { |
| 52 | DataType::F16, |
| 53 | }); |
| 54 | |
Sang-Hoon Park | 94d5051 | 2020-07-02 10:49:39 +0100 | [diff] [blame] | 55 | /** Aligned corners, this functionality is supported only by NEON and OpenCL backends */ |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 56 | const auto AlignCorners = framework::dataset::make("AlignCorners", |
| 57 | { |
| 58 | false, |
| 59 | }); |
| 60 | |
Frank Lei | 57a150a | 2017-12-19 10:14:57 +0800 | [diff] [blame] | 61 | /** Tolerance */ |
| 62 | RelativeTolerance<half> tolerance_f16(half(0.1)); |
| 63 | } // namespace |
| 64 | |
| 65 | TEST_SUITE(GC) |
| 66 | TEST_SUITE(Scale) |
| 67 | |
Frank Lei | 57a150a | 2017-12-19 10:14:57 +0800 | [diff] [blame] | 68 | template <typename T> |
| 69 | using GCScaleFixture = ScaleValidationFixture<GCTensor, GCAccessor, GCScale, T>; |
| 70 | |
| 71 | TEST_SUITE(Float) |
| 72 | TEST_SUITE(FP16) |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 73 | FIXTURE_DATA_TEST_CASE(RunSmall, GCScaleFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 74 | DataType::F16)), |
| 75 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 76 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR })), |
| 77 | datasets::BorderModes()), |
| 78 | datasets::SamplingPolicies()), |
| 79 | AlignCorners)) |
Frank Lei | 57a150a | 2017-12-19 10:14:57 +0800 | [diff] [blame] | 80 | { |
| 81 | //Create valid region |
| 82 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 83 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
Frank Lei | 57a150a | 2017-12-19 10:14:57 +0800 | [diff] [blame] | 84 | |
| 85 | // Validate output |
| 86 | validate(GCAccessor(_target), _reference, valid_region, tolerance_f16); |
| 87 | } |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 88 | FIXTURE_DATA_TEST_CASE(RunLarge, GCScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", |
Frank Lei | 57a150a | 2017-12-19 10:14:57 +0800 | [diff] [blame] | 89 | DataType::F16)), |
Georgios Pinitas | 393fa4c | 2018-05-08 15:54:53 +0100 | [diff] [blame] | 90 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
Sang-Hoon Park | bb123bd | 2020-01-03 10:57:30 +0000 | [diff] [blame] | 91 | framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR })), |
| 92 | datasets::BorderModes()), |
| 93 | datasets::SamplingPolicies()), |
| 94 | AlignCorners)) |
Frank Lei | 57a150a | 2017-12-19 10:14:57 +0800 | [diff] [blame] | 95 | { |
| 96 | //Create valid region |
| 97 | TensorInfo src_info(_shape, 1, _data_type); |
Diego Lopez Recas | 0085429 | 2018-02-22 13:08:01 +0000 | [diff] [blame] | 98 | const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED)); |
Frank Lei | 57a150a | 2017-12-19 10:14:57 +0800 | [diff] [blame] | 99 | |
| 100 | // Validate output |
| 101 | validate(GCAccessor(_target), _reference, valid_region, tolerance_f16); |
| 102 | } |
| 103 | TEST_SUITE_END() |
| 104 | TEST_SUITE_END() |
| 105 | |
| 106 | TEST_SUITE_END() |
| 107 | TEST_SUITE_END() |
| 108 | } // namespace validation |
| 109 | } // namespace test |
| 110 | } // namespace arm_compute |