From d226d8dd6599b16ebbb22f4930abb49798ec811b Mon Sep 17 00:00:00 2001 From: John Richardson Date: Wed, 6 Jun 2018 14:08:58 +0100 Subject: COMPMID-761: Add CL/NEON LaplacianReconstruct benchmark tests Change-Id: I21d94d83e2bcde6c992c2425a1b8cc6f60a1d12a Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/134757 Tested-by: Jenkins Reviewed-by: Anthony Barbier --- tests/benchmark/CL/LaplacianReconstruct.cpp | 82 ++++++++++++++++++++++ tests/benchmark/NEON/LaplacianReconstruct.cpp | 82 ++++++++++++++++++++++ tests/benchmark/fixtures/LaplacianPyramidFixture.h | 12 ++-- .../fixtures/LaplacianReconstructFixture.h | 80 +++++++++++++++++++++ 4 files changed, 252 insertions(+), 4 deletions(-) create mode 100644 tests/benchmark/CL/LaplacianReconstruct.cpp create mode 100644 tests/benchmark/NEON/LaplacianReconstruct.cpp create mode 100644 tests/benchmark/fixtures/LaplacianReconstructFixture.h (limited to 'tests/benchmark') diff --git a/tests/benchmark/CL/LaplacianReconstruct.cpp b/tests/benchmark/CL/LaplacianReconstruct.cpp new file mode 100644 index 0000000000..a25ea595da --- /dev/null +++ b/tests/benchmark/CL/LaplacianReconstruct.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/functions/CLLaplacianPyramid.h" +#include "arm_compute/runtime/CL/functions/CLLaplacianReconstruct.h" +#include "tests/CL/CLAccessor.h" +#include "tests/benchmark/fixtures/LaplacianReconstructFixture.h" +#include "tests/datasets/BorderModeDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "utils/TypePrinter.h" + +namespace arm_compute +{ +namespace test +{ +namespace benchmark +{ +namespace +{ +const auto small_laplacian_reconstruct_levels = framework::dataset::make("NumLevels", 2, 3); +const auto large_laplacian_reconstruct_levels = framework::dataset::make("NumLevels", 2, 5); + +const auto formats = combine(framework::dataset::make("FormatIn", Format::S16), framework::dataset::make("FormatOut", Format::U8)); +} // namespace + +// *INDENT-OFF* +// clang-format off +using CLLaplacianReconstructFixture = LaplacianReconstructFixture; + +TEST_SUITE(CL) +TEST_SUITE(LaplacianReconstruct) + +REGISTER_FIXTURE_DATA_TEST_CASE(RunSmall, CLLaplacianReconstructFixture, framework::DatasetMode::PRECOMMIT, + combine(combine(combine( + datasets::Medium2DShapes(), + datasets::BorderModes()), + small_laplacian_reconstruct_levels), + formats)); + +REGISTER_FIXTURE_DATA_TEST_CASE(RunLarge, CLLaplacianReconstructFixture, framework::DatasetMode::PRECOMMIT, + combine(combine(combine( + datasets::Large2DShapes(), + datasets::BorderModes()), + large_laplacian_reconstruct_levels), + formats)); + +// clang-format on +// *INDENT-ON* + +TEST_SUITE_END() // LaplacianReconstruct +TEST_SUITE_END() // CL +} // namespace benchmark +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/LaplacianReconstruct.cpp b/tests/benchmark/NEON/LaplacianReconstruct.cpp new file mode 100644 index 0000000000..602923b9e7 --- /dev/null +++ b/tests/benchmark/NEON/LaplacianReconstruct.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NELaplacianPyramid.h" +#include "arm_compute/runtime/NEON/functions/NELaplacianReconstruct.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/NEON/Accessor.h" +#include "tests/benchmark/fixtures/LaplacianReconstructFixture.h" +#include "tests/datasets/BorderModeDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "utils/TypePrinter.h" + +namespace arm_compute +{ +namespace test +{ +namespace benchmark +{ +namespace +{ +const auto small_laplacian_reconstruct_levels = framework::dataset::make("NumLevels", 2, 3); +const auto large_laplacian_reconstruct_levels = framework::dataset::make("NumLevels", 2, 5); + +const auto formats = combine(framework::dataset::make("FormatIn", Format::S16), framework::dataset::make("FormatOut", Format::U8)); +} // namespace + +// *INDENT-OFF* +// clang-format off +using NELaplacianReconstructFixture = LaplacianReconstructFixture; + +TEST_SUITE(NEON) +TEST_SUITE(LaplacianReconstruct) + +REGISTER_FIXTURE_DATA_TEST_CASE(RunSmall, NELaplacianReconstructFixture, framework::DatasetMode::PRECOMMIT, + combine(combine(combine( + datasets::Medium2DShapes(), + datasets::BorderModes()), + small_laplacian_reconstruct_levels), + formats)); + +REGISTER_FIXTURE_DATA_TEST_CASE(RunLarge, NELaplacianReconstructFixture, framework::DatasetMode::PRECOMMIT, + combine(combine(combine( + datasets::Large2DShapes(), + datasets::BorderModes()), + large_laplacian_reconstruct_levels), + formats)); + +// clang-format on +// *INDENT-ON* + +TEST_SUITE_END() // LaplacianReconstruct +TEST_SUITE_END() // NEON +} // namespace benchmark +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/fixtures/LaplacianPyramidFixture.h b/tests/benchmark/fixtures/LaplacianPyramidFixture.h index 3d594b7f80..7bc3370312 100644 --- a/tests/benchmark/fixtures/LaplacianPyramidFixture.h +++ b/tests/benchmark/fixtures/LaplacianPyramidFixture.h @@ -47,7 +47,9 @@ public: // Initialize pyramid PyramidInfo pyramid_info(num_levels, SCALE_PYRAMID_HALF, input_shape, format_out); - pyramid.init(pyramid_info); + + // Use conservative padding strategy to fit all subsequent kernels + pyramid.init_auto_padding(pyramid_info); // Create tensor src = create_tensor(input_shape, format_in); @@ -84,11 +86,13 @@ public: sync_tensor_if_necessary(dst); } -private: - TensorType src{}; +protected: TensorType dst{}; PyramidType pyramid{}; - Function laplacian_pyramid_func{}; + +private: + TensorType src{}; + Function laplacian_pyramid_func{}; }; } // namespace benchmark } // namespace test diff --git a/tests/benchmark/fixtures/LaplacianReconstructFixture.h b/tests/benchmark/fixtures/LaplacianReconstructFixture.h new file mode 100644 index 0000000000..39906977a1 --- /dev/null +++ b/tests/benchmark/fixtures/LaplacianReconstructFixture.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LAPLACIAN_RECONSTRUCT_FIXTURE +#define ARM_COMPUTE_TEST_LAPLACIAN_RECONSTRUCT_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/benchmark/fixtures/LaplacianPyramidFixture.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace benchmark +{ +template +class LaplacianReconstructFixture : public LaplacianPyramidFixture +{ +public: + template + void setup(TensorShape input_shape, BorderMode border_mode, size_t num_levels, Format format_in, Format format_out) + { + const uint8_t constant_border_value = 0; + + LPF::setup(input_shape, border_mode, num_levels, format_out, format_in); + LPF::run(); + + // Create tensor + dst = create_tensor(input_shape, DataType::U8); + + laplacian_reconstruct_func.configure(&(LPF::pyramid), &(LPF::dst), &dst, border_mode, constant_border_value); + + dst.allocator()->allocate(); + } + + void run() + { + laplacian_reconstruct_func.run(); + } + + void sync() + { + sync_if_necessary(); + sync_tensor_if_necessary(dst); + } + +private: + TensorType dst{}; + Function laplacian_reconstruct_func{}; + + using LPF = LaplacianPyramidFixture; +}; +} // namespace benchmark +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LAPLACIAN_RECONSTRUCT_FIXTURE */ -- cgit v1.2.1