From 5415a0267523931bae0a012db2438fa7cc89a549 Mon Sep 17 00:00:00 2001 From: John Richardson Date: Tue, 8 May 2018 11:26:10 +0100 Subject: COMPMID-761: Add CL/NEON MinMaxLocation benchmark tests Change-Id: Ib174567e22400a53fca92f1a8bd54f6531befa71 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/129443 Tested-by: Jenkins Reviewed-by: Anthony Barbier --- tests/benchmark/CL/MinMaxLocation.cpp | 63 ++++++++++++++++++ tests/benchmark/NEON/MinMaxLocation.cpp | 63 ++++++++++++++++++ tests/benchmark/fixtures/MinMaxLocationFixture.h | 83 ++++++++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 tests/benchmark/CL/MinMaxLocation.cpp create mode 100644 tests/benchmark/NEON/MinMaxLocation.cpp create mode 100644 tests/benchmark/fixtures/MinMaxLocationFixture.h (limited to 'tests/benchmark') diff --git a/tests/benchmark/CL/MinMaxLocation.cpp b/tests/benchmark/CL/MinMaxLocation.cpp new file mode 100644 index 0000000000..779348d3dc --- /dev/null +++ b/tests/benchmark/CL/MinMaxLocation.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/CL/CLTensor.h" +#include "arm_compute/runtime/CL/functions/CLMinMaxLocation.h" +#include "tests/CL/CLAccessor.h" +#include "tests/benchmark/fixtures/MinMaxLocationFixture.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 data_types = framework::dataset::make("DataType", { DataType::U8, DataType::S16, DataType::F32 }); +} // namespace + +using CLMinMaxLocationFixture = MinMaxLocationFixture; + +TEST_SUITE(CL) +TEST_SUITE(MinMaxLocation) + +// *INDENT-OFF* +// clang-format off +REGISTER_FIXTURE_DATA_TEST_CASE(RunSmall, CLMinMaxLocationFixture, framework::DatasetMode::PRECOMMIT, + combine( datasets::Small2DShapes(), data_types)); + +REGISTER_FIXTURE_DATA_TEST_CASE(RunLarge, CLMinMaxLocationFixture, framework::DatasetMode::NIGHTLY, + combine( datasets::Large2DShapes(), data_types)); +// clang-format on +// *INDENT-ON* +TEST_SUITE_END() // MinMaxLocation +TEST_SUITE_END() // CL +} // namespace benchmark +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/MinMaxLocation.cpp b/tests/benchmark/NEON/MinMaxLocation.cpp new file mode 100644 index 0000000000..446370bdca --- /dev/null +++ b/tests/benchmark/NEON/MinMaxLocation.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/NEON/functions/NEMinMaxLocation.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/NEON/Accessor.h" +#include "tests/benchmark/fixtures/MinMaxLocationFixture.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 data_types = framework::dataset::make("DataType", { DataType::U8, DataType::S16, DataType::F32 }); +} // namespace + +using NEMinMaxLocationFixture = MinMaxLocationFixture; + +TEST_SUITE(NEON) +TEST_SUITE(MinMaxLocation) + +// *INDENT-OFF* +// clang-format off +REGISTER_FIXTURE_DATA_TEST_CASE(RunSmall, NEMinMaxLocationFixture, framework::DatasetMode::PRECOMMIT, + combine(datasets::Small2DShapes(), data_types)); + +REGISTER_FIXTURE_DATA_TEST_CASE(RunLarge, NEMinMaxLocationFixture, framework::DatasetMode::NIGHTLY, + combine(datasets::Large2DShapes(), data_types)); +// clang-format on +// *INDENT-ON* +TEST_SUITE_END() // MinMaxLocation +TEST_SUITE_END() // NEON +} // namespace benchmark +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/fixtures/MinMaxLocationFixture.h b/tests/benchmark/fixtures/MinMaxLocationFixture.h new file mode 100644 index 0000000000..384dce5a3f --- /dev/null +++ b/tests/benchmark/fixtures/MinMaxLocationFixture.h @@ -0,0 +1,83 @@ +/* + * 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_MIN_MAX_LOCATION_FIXTURE +#define ARM_COMPUTE_TEST_MIN_MAX_LOCATION_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Types.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace benchmark +{ +template +class MinMaxLocationFixture : public framework::Fixture +{ +public: + template + void setup(const TensorShape &shape, DataType data_type) + { + // Create tensors + src = create_tensor(shape, data_type); + + // Create and configure function + min_max_location_func.configure(&src, &min, &max, &min_loc, &max_loc); + + // Allocate tensors + src.allocator()->allocate(); + } + + void run() + { + min_max_location_func.run(); + } + + void sync() + { + sync_if_necessary(); + } + + void teardown() + { + src.allocator()->free(); + } + +private: + TensorType src{}; + int32_t min{ 0 }; + int32_t max{ 0 }; + ArrayType min_loc{ 20000 }; + ArrayType max_loc{ 20000 }; + Function min_max_location_func{}; +}; +} // namespace benchmark +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_MIN_MAX_LOCATION_FIXTURE */ -- cgit v1.2.1