diff options
Diffstat (limited to 'tests/benchmark')
-rw-r--r-- | tests/benchmark/CL/Histogram.cpp | 64 | ||||
-rw-r--r-- | tests/benchmark/NEON/Histogram.cpp | 63 | ||||
-rw-r--r-- | tests/benchmark/fixtures/HistogramFixture.h | 79 |
3 files changed, 206 insertions, 0 deletions
diff --git a/tests/benchmark/CL/Histogram.cpp b/tests/benchmark/CL/Histogram.cpp new file mode 100644 index 0000000000..657a5c7921 --- /dev/null +++ b/tests/benchmark/CL/Histogram.cpp @@ -0,0 +1,64 @@ +/* + * 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/CLDistribution1D.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLHistogram.h" +#include "tests/CL/CLAccessor.h" +#include "tests/benchmark/fixtures/HistogramFixture.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 +{ +using CLHistogramFixture = HistogramFixture<CLTensor, CLHistogram, CLAccessor, CLDistribution1D>; + +// *INDENT-OFF* +// clang-format off +TEST_SUITE(CL) +TEST_SUITE(Histogram) +REGISTER_FIXTURE_DATA_TEST_CASE(RunSmall, CLHistogramFixture, framework::DatasetMode::PRECOMMIT, + combine( + datasets::Small2DShapes(), + framework::dataset::make("Format", Format::U8))); + +REGISTER_FIXTURE_DATA_TEST_CASE(RunLarge, CLHistogramFixture, framework::DatasetMode::PRECOMMIT, + combine( + datasets::Large2DShapes(), + framework::dataset::make("Format", Format::U8))); +// clang-format on +// *INDENT-ON* + +TEST_SUITE_END() // Histogram +TEST_SUITE_END() // CL +} // namespace benchmark +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/Histogram.cpp b/tests/benchmark/NEON/Histogram.cpp new file mode 100644 index 0000000000..77e385c879 --- /dev/null +++ b/tests/benchmark/NEON/Histogram.cpp @@ -0,0 +1,63 @@ +/* + * 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/Distribution1D.h" +#include "arm_compute/runtime/NEON/functions/NEHistogram.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/NEON/Accessor.h" +#include "tests/benchmark/fixtures/HistogramFixture.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 +{ +using NEHistogramFixture = HistogramFixture<Tensor, NEHistogram, Accessor, Distribution1D>; + +// *INDENT-OFF* +// clang-format off +TEST_SUITE(NEON) +TEST_SUITE(Histogram) +REGISTER_FIXTURE_DATA_TEST_CASE(RunSmall, NEHistogramFixture, framework::DatasetMode::PRECOMMIT, + combine( + datasets::Small2DShapes(), + framework::dataset::make("Format", Format::U8))); + +REGISTER_FIXTURE_DATA_TEST_CASE(RunLarge, NEHistogramFixture, framework::DatasetMode::PRECOMMIT, + combine( + datasets::Large2DShapes(), + framework::dataset::make("Format", Format::U8))); +// clang-format on +// *INDENT-ON* + +TEST_SUITE_END() // Histogram +TEST_SUITE_END() // NEON +} // namespace benchmark +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/fixtures/HistogramFixture.h b/tests/benchmark/fixtures/HistogramFixture.h new file mode 100644 index 0000000000..355cddb6e7 --- /dev/null +++ b/tests/benchmark/fixtures/HistogramFixture.h @@ -0,0 +1,79 @@ +/* + * 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_HISTOGRAM_FIXTURE +#define ARM_COMPUTE_TEST_HISTOGRAM_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace benchmark +{ +template <typename TensorType, typename Function, typename Accessor, typename DistributionType> +class HistogramFixture : public framework::Fixture +{ +public: + template <typename...> + void setup(const TensorShape &shape, Format format) + { + // Create tensors + src = create_tensor<TensorType>(shape, format); + + // Create and configure function + histogram_func.configure(&src, &dst); + + // Allocate tensors + src.allocator()->allocate(); + } + + void run() + { + histogram_func.run(); + } + + void sync() + { + sync_if_necessary<TensorType>(); + } + + void teardown() + { + src.allocator()->free(); + } + +private: + TensorType src{}; + DistributionType dst{ 30, 125, 255 }; + Function histogram_func{}; +}; +} // namespace benchmark +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_HISTOGRAM_FIXTURE */ |