Sanghoon Lee | 1cd4149 | 2018-03-15 11:48:48 +0000 | [diff] [blame] | 1 | /* |
Michalis Spyrou | d175ece | 2020-07-30 23:39:32 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2020 Arm Limited. |
Sanghoon Lee | 1cd4149 | 2018-03-15 11:48:48 +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. |
Michalis Spyrou | d175ece | 2020-07-30 23:39:32 +0100 | [diff] [blame] | 23 | */ |
Sanghoon Lee | 1cd4149 | 2018-03-15 11:48:48 +0000 | [diff] [blame] | 24 | #include "arm_compute/core/Types.h" |
| 25 | #include "arm_compute/runtime/CL/CLTensor.h" |
| 26 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
| 27 | #include "arm_compute/runtime/CL/functions/CLGaussianPyramid.h" |
| 28 | #include "tests/CL/CLAccessor.h" |
| 29 | #include "tests/PaddingCalculator.h" |
| 30 | #include "tests/datasets/BorderModeDataset.h" |
| 31 | #include "tests/datasets/ShapeDatasets.h" |
| 32 | #include "tests/framework/Asserts.h" |
| 33 | #include "tests/framework/Macros.h" |
| 34 | #include "tests/framework/datasets/Datasets.h" |
| 35 | #include "tests/validation/Validation.h" |
| 36 | #include "tests/validation/fixtures/GaussianPyramidHalfFixture.h" |
| 37 | #include "tests/validation/reference/Utils.h" |
| 38 | |
| 39 | namespace arm_compute |
| 40 | { |
| 41 | namespace test |
| 42 | { |
| 43 | namespace validation |
| 44 | { |
| 45 | namespace |
| 46 | { |
| 47 | const auto small_gaussian_pyramid_levels = combine(datasets::Medium2DShapes(), datasets::BorderModes()) * framework::dataset::make("numlevels", 2, 4); |
| 48 | const auto large_gaussian_pyramid_levels = combine(datasets::Large2DShapes(), datasets::BorderModes()) * framework::dataset::make("numlevels", 2, 5); |
| 49 | |
| 50 | template <typename T> |
| 51 | inline void validate_gaussian_pyramid(const CLPyramid &target, const std::vector<SimpleTensor<T>> &reference, BorderMode border_mode) |
| 52 | { |
| 53 | ValidRegion prev_valid_region = shape_to_valid_region(reference[0].shape()); |
| 54 | |
| 55 | for(size_t i = 1; i < reference.size(); ++i) |
| 56 | { |
| 57 | const ValidRegion valid_region = shape_to_valid_region_gaussian_pyramid_half(reference[i - 1].shape(), prev_valid_region, (border_mode == BorderMode::UNDEFINED)); |
| 58 | |
| 59 | // Validate outputs |
| 60 | validate(CLAccessor(*(target.get_pyramid_level(i))), reference[i], valid_region); |
| 61 | |
| 62 | // Keep the valid region for the next level |
| 63 | prev_valid_region = valid_region; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | } // namespace |
| 68 | |
| 69 | TEST_SUITE(CL) |
| 70 | TEST_SUITE(GaussianPyramid) |
| 71 | TEST_SUITE(Half) |
Sanghoon Lee | 1cd4149 | 2018-03-15 11:48:48 +0000 | [diff] [blame] | 72 | template <typename T> |
| 73 | using CLGaussianPyramidHalfFixture = GaussianPyramidHalfValidationFixture<CLTensor, CLAccessor, CLGaussianPyramidHalf, T, CLPyramid>; |
| 74 | |
Michalis Spyrou | cac09dc | 2020-11-24 00:16:49 +0000 | [diff] [blame] | 75 | FIXTURE_DATA_TEST_CASE(RunSmallGaussianPyramidHalf, CLGaussianPyramidHalfFixture<uint8_t>, framework::DatasetMode::NIGHTLY, small_gaussian_pyramid_levels) |
Sanghoon Lee | 1cd4149 | 2018-03-15 11:48:48 +0000 | [diff] [blame] | 76 | { |
| 77 | validate_gaussian_pyramid(_target, _reference, _border_mode); |
| 78 | } |
| 79 | |
| 80 | FIXTURE_DATA_TEST_CASE(RunLargeGaussianPyramidHalf, CLGaussianPyramidHalfFixture<uint8_t>, framework::DatasetMode::NIGHTLY, large_gaussian_pyramid_levels) |
| 81 | { |
| 82 | validate_gaussian_pyramid(_target, _reference, _border_mode); |
| 83 | } |
| 84 | TEST_SUITE_END() |
| 85 | TEST_SUITE_END() |
| 86 | TEST_SUITE_END() |
| 87 | } // namespace validation |
| 88 | } // namespace test |
| 89 | } // namespace arm_compute |