From d03b00acd71847fa2db1c5308c87d3b57c781bf9 Mon Sep 17 00:00:00 2001 From: Moritz Pflanzer Date: Mon, 17 Jul 2017 13:50:12 +0100 Subject: COMPMID-415: Fix dataset modes Change-Id: I266e8a22890c914edb3335104f073e79d2bf0ad9 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/80766 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- tests/DatasetManager.cpp | 82 ----------------- tests/DatasetManager.h | 101 --------------------- tests/benchmark_new/CL/ActivationLayer.cpp | 6 +- tests/benchmark_new/CL/ConvolutionLayer.cpp | 6 +- tests/benchmark_new/CL/FullyConnectedLayer.cpp | 6 +- tests/benchmark_new/CL/GEMM.cpp | 2 +- tests/benchmark_new/CL/NormalizationLayer.cpp | 4 +- tests/benchmark_new/CL/PoolingLayer.cpp | 6 +- tests/benchmark_new/CL/SYSTEM/AlexNet.cpp | 2 +- tests/benchmark_new/CL/SYSTEM/LeNet5.cpp | 2 +- tests/benchmark_new/NEON/ActivationLayer.cpp | 6 +- tests/benchmark_new/NEON/ConvolutionLayer.cpp | 6 +- .../benchmark_new/NEON/DirectConvolutionLayer.cpp | 2 +- tests/benchmark_new/NEON/FullyConnectedLayer.cpp | 6 +- tests/benchmark_new/NEON/GEMM.cpp | 2 +- tests/benchmark_new/NEON/NormalizationLayer.cpp | 4 +- tests/benchmark_new/NEON/PoolingLayer.cpp | 6 +- tests/benchmark_new/NEON/SYSTEM/AlexNet.cpp | 2 +- tests/benchmark_new/NEON/SYSTEM/LeNet5.cpp | 2 +- tests/benchmark_new/main.cpp | 17 ++-- 20 files changed, 43 insertions(+), 227 deletions(-) delete mode 100644 tests/DatasetManager.cpp delete mode 100644 tests/DatasetManager.h (limited to 'tests') diff --git a/tests/DatasetManager.cpp b/tests/DatasetManager.cpp deleted file mode 100644 index fbc40e64cd..0000000000 --- a/tests/DatasetManager.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2017 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 "DatasetManager.h" - -#include - -namespace arm_compute -{ -namespace test -{ -DatasetManager &DatasetManager::get() -{ - static DatasetManager instance; - return instance; -} - -void DatasetManager::set_mode(DatasetMode mode) -{ - _mode = mode; -} - -DatasetManager::ShapesDataset DatasetManager::shapesDataset() const -{ - static const std::string name = "Shape"; - static const std::vector shapes{ arm_compute::TensorShape(1U), arm_compute::TensorShape(2U), arm_compute::TensorShape(3U), arm_compute::TensorShape(10U), arm_compute::TensorShape(20U), arm_compute::TensorShape(30U) }; - - switch(_mode) - { - case DatasetManager::DatasetMode::PRECOMMIT: - return framework::dataset::make(name, shapes.cbegin(), shapes.cbegin() + 3); - break; - case DatasetManager::DatasetMode::NIGHTLY: - return framework::dataset::make(name, shapes.cbegin() + 3, shapes.cend()); - break; - case DatasetManager::DatasetMode::ALL: - // Fallthrough - default: - return framework::dataset::make(name, shapes.cbegin(), shapes.cend()); - } -} - -DatasetManager::DatasetMode dataset_mode_from_name(const std::string &name) -{ - static const std::map modes = - { - { "all", DatasetManager::DatasetMode::ALL }, - { "precommit", DatasetManager::DatasetMode::PRECOMMIT }, - { "nightly", DatasetManager::DatasetMode::NIGHTLY }, - }; - - try - { - return modes.at(name); - } - catch(const std::out_of_range &) - { - throw std::invalid_argument(name); - } -} -} // namespace test -} // namespace arm_compute diff --git a/tests/DatasetManager.h b/tests/DatasetManager.h deleted file mode 100644 index 2080203286..0000000000 --- a/tests/DatasetManager.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2017 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_DATASETMANAGER -#define ARM_COMPUTE_TEST_DATASETMANAGER - -#include "arm_compute/core/TensorShape.h" -#include "framework/datasets/Datasets.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -class DatasetManager final -{ -public: - enum class DatasetMode : unsigned int - { - ALL = 0, - PRECOMMIT = 1, - NIGHTLY = 2 - }; - - using ShapesDataset = framework::dataset::RangeDataset::const_iterator>; - - static DatasetManager &get(); - - void set_mode(DatasetMode mode); - - ShapesDataset shapesDataset() const; - -private: - DatasetManager() = default; - ~DatasetManager() = default; - - DatasetMode _mode{ DatasetMode::ALL }; -}; - -DatasetManager::DatasetMode dataset_mode_from_name(const std::string &name); - -inline ::std::stringstream &operator>>(::std::stringstream &stream, DatasetManager::DatasetMode &mode) -{ - std::string value; - stream >> value; - mode = dataset_mode_from_name(value); - return stream; -} - -inline ::std::stringstream &operator<<(::std::stringstream &stream, DatasetManager::DatasetMode mode) -{ - switch(mode) - { - case DatasetManager::DatasetMode::PRECOMMIT: - stream << "PRECOMMIT"; - break; - case DatasetManager::DatasetMode::NIGHTLY: - stream << "NIGHTLY"; - break; - case DatasetManager::DatasetMode::ALL: - stream << "ALL"; - break; - default: - throw std::invalid_argument("Unsupported dataset mode"); - } - - return stream; -} - -inline std::string to_string(const DatasetManager::DatasetMode &mode) -{ - std::stringstream stream; - stream << mode; - return stream.str(); -} -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DATASETMANAGER */ diff --git a/tests/benchmark_new/CL/ActivationLayer.cpp b/tests/benchmark_new/CL/ActivationLayer.cpp index 2ab23d292f..7ce222925c 100644 --- a/tests/benchmark_new/CL/ActivationLayer.cpp +++ b/tests/benchmark_new/CL/ActivationLayer.cpp @@ -41,17 +41,17 @@ using CLActivationLayerFixture = ActivationLayerFixture; TEST_SUITE(CL) -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetGEMM, CLGEMMFixture, framework::dataset::combine(datasets::GoogLeNetGEMMDataset(), std::move(data_types))); +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetGEMM, CLGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::GoogLeNetGEMMDataset(), std::move(data_types))); TEST_SUITE_END() } // namespace test diff --git a/tests/benchmark_new/CL/NormalizationLayer.cpp b/tests/benchmark_new/CL/NormalizationLayer.cpp index 95e78c4a18..088d8739d0 100644 --- a/tests/benchmark_new/CL/NormalizationLayer.cpp +++ b/tests/benchmark_new/CL/NormalizationLayer.cpp @@ -41,12 +41,12 @@ using CLNormalizationLayerFixture = NormalizationLayerFixture; TEST_SUITE(NEON) -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetGEMM, NEGEMMFixture, framework::dataset::combine(datasets::GoogLeNetGEMMDataset(), std::move(data_types))); +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetGEMM, NEGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::GoogLeNetGEMMDataset(), std::move(data_types))); TEST_SUITE_END() } // namespace test diff --git a/tests/benchmark_new/NEON/NormalizationLayer.cpp b/tests/benchmark_new/NEON/NormalizationLayer.cpp index d9f1323620..8c1f37df0a 100644 --- a/tests/benchmark_new/NEON/NormalizationLayer.cpp +++ b/tests/benchmark_new/NEON/NormalizationLayer.cpp @@ -41,12 +41,12 @@ using NENormalizationLayerFixture = NormalizationLayerFixture allowed_modes + std::set allowed_modes { - DatasetManager::DatasetMode::PRECOMMIT, - DatasetManager::DatasetMode::NIGHTLY, - DatasetManager::DatasetMode::ALL + framework::DatasetMode::PRECOMMIT, + framework::DatasetMode::NIGHTLY, + framework::DatasetMode::ALL }; std::set supported_log_formats @@ -90,7 +90,7 @@ int main(int argc, char **argv) auto help = parser.add_option("help"); help->set_help("Show this help message"); - auto dataset_mode = parser.add_option>("mode", allowed_modes, DatasetManager::DatasetMode::ALL); + auto dataset_mode = parser.add_option>("mode", allowed_modes, framework::DatasetMode::ALL); dataset_mode->set_help("For managed datasets select which group to use"); auto instruments = parser.add_option>("instruments", allowed_instruments, std::initializer_list { framework::InstrumentType::ALL }); instruments->set_help("Set the profiling instruments to use"); @@ -162,7 +162,6 @@ int main(int argc, char **argv) } } - DatasetManager::get().set_mode(dataset_mode->value()); library = support::cpp14::make_unique(assets->value(), seed->value()); Scheduler::get().set_num_threads(threads->value()); @@ -175,7 +174,7 @@ int main(int argc, char **argv) printer->print_entry("Dataset mode", to_string(dataset_mode->value())); } - framework.init(instruments->value(), iterations->value(), filter->value(), filter_id->value()); + framework.init(instruments->value(), iterations->value(), dataset_mode->value(), filter->value(), filter_id->value()); framework.set_printer(printer.get()); framework.set_throw_errors(throw_errors->value()); @@ -185,7 +184,7 @@ int main(int argc, char **argv) { for(const auto &id : framework.test_ids()) { - std::cout << "[" << id.first << "] " << id.second << "\n"; + std::cout << "[" << std::get<0>(id) << ", " << std::get<2>(id) << "] " << std::get<1>(id) << "\n"; } } else -- cgit v1.2.1