diff options
author | John Richardson <john.richardson@arm.com> | 2018-05-08 11:26:10 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:52:35 +0000 |
commit | 5415a0267523931bae0a012db2438fa7cc89a549 (patch) | |
tree | 5848a5e43e7259468eaf7af39b91d031df8f89ca | |
parent | 18557bb5bb8dd645c1987af9cae650bea8a3a06b (diff) | |
download | ComputeLibrary-5415a0267523931bae0a012db2438fa7cc89a549.tar.gz |
COMPMID-761: Add CL/NEON MinMaxLocation benchmark tests
Change-Id: Ib174567e22400a53fca92f1a8bd54f6531befa71
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/129443
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
-rw-r--r-- | tests/benchmark/CL/MinMaxLocation.cpp | 63 | ||||
-rw-r--r-- | tests/benchmark/NEON/MinMaxLocation.cpp | 63 | ||||
-rw-r--r-- | tests/benchmark/fixtures/MinMaxLocationFixture.h | 83 |
3 files changed, 209 insertions, 0 deletions
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<CLTensor, CLMinMaxLocation, CLAccessor, CLCoordinates2DArray>; + +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<Tensor, NEMinMaxLocation, Accessor, Coordinates2DArray>; + +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 <typename TensorType, typename Function, typename Accessor, typename ArrayType> +class MinMaxLocationFixture : public framework::Fixture +{ +public: + template <typename...> + void setup(const TensorShape &shape, DataType data_type) + { + // Create tensors + src = create_tensor<TensorType>(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<TensorType>(); + } + + 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 */ |