diff options
Diffstat (limited to 'tests')
78 files changed, 3919 insertions, 5138 deletions
diff --git a/tests/DatasetManager.cpp b/tests/DatasetManager.cpp new file mode 100644 index 0000000000..fbc40e64cd --- /dev/null +++ b/tests/DatasetManager.cpp @@ -0,0 +1,82 @@ +/* + * 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 <map> + +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<arm_compute::TensorShape> 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<std::string, DatasetManager::DatasetMode> 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 new file mode 100644 index 0000000000..2080203286 --- /dev/null +++ b/tests/DatasetManager.h @@ -0,0 +1,101 @@ +/* + * 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 <sstream> +#include <stdexcept> +#include <string> + +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<std::vector<arm_compute::TensorShape>::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/SConscript b/tests/SConscript index 8da1d2fa33..291a7a5555 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -68,31 +68,17 @@ common_env.Append(LIBS = ['boost_program_options']) common_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers']) validation_env = common_env.Clone() -benchmark_env = common_env.Clone() validation_env.Append(CPPDEFINES=['BOOST']) -# overloaded virtual function "benchmark::Fixture::SetUp" is only partially overridden -benchmark_env.Append(CPPFLAGS=['-Wno-overloaded-virtual']) files = Glob('*.cpp') +files = [f for f in files if "DatasetManager" not in os.path.basename(str(f))] common_objects = [ common_env.StaticObject( f ) for f in files ] validation_env.Append(LIBS = ['boost_unit_test_framework']) -benchmark_env.Append(LIBS = ['benchmark']) files_validation = Glob('validation/*.cpp') -files_benchmark = Glob('benchmark/*.cpp') - -if env['os'] == 'android' or not common_env['pmu']: - if env['os'] == 'android' and common_env['pmu']: - if env['Werror']: - print("pmu=1 is not supported for os=android") - Exit(1) - else: - print("pmu=1 is not supported for os=android") - - files_benchmark = [f for f in files_benchmark if "PMU" not in os.path.basename(str(f))] # Add unit tests files_validation += Glob('validation/UNIT/*.cpp') @@ -101,31 +87,19 @@ files_validation += Glob('validation/UNIT/*/*.cpp') if env['opencl']: Import('opencl') - benchmark_env.Append(CPPDEFINES=['OPENCL']) - files_validation += Glob('validation/CL/*.cpp') files_validation += Glob('validation/CL/*/*.cpp') files_validation += Glob('validation/system_tests/CL/*.cpp') - files_benchmark += Glob('benchmark/CL/*/*.cpp') - files_benchmark += Glob('benchmark/CL/*.cpp') - files_benchmark += Glob('benchmark/system_tests/CL/*.cpp') validation_env.Append(LIBS = "OpenCL") - benchmark_env.Append(LIBS = "OpenCL") if env['neon']: files_validation += Glob('validation/NEON/*.cpp') files_validation += Glob('validation/NEON/*/*.cpp') files_validation += Glob('validation/system_tests/NEON/*.cpp') - files_benchmark += Glob('benchmark/NEON/*/*.cpp') - files_benchmark += Glob('benchmark/NEON/*.cpp') - files_benchmark += Glob('benchmark/system_tests/NEON/*.cpp') if env['os'] == 'android': validation_env.Append(LIBS = ["log"]) - benchmark_env.Append(LIBS = ["log"]) -else: - benchmark_env.Append(LIBS = ["rt"]) if common_env['validation_tests']: arm_compute_validation = validation_env.Program('arm_compute_validation', @@ -135,12 +109,70 @@ if common_env['validation_tests']: Depends(arm_compute_validation, opencl) Default(arm_compute_validation) Export('arm_compute_validation') + +####################################################################### +# Using new framework +####################################################################### + +# Clone the environment to make sure we're not polluting the arm_compute one: +benchmark_env = env.Clone() +# Workaround to build both test systems in parallel +benchmark_env.VariantDir("new", ".", duplicate=0) + +if env['os'] in ['android', 'bare_metal'] or env['standalone']: + Import("arm_compute_a") + benchmark_env.Append(LIBS = [arm_compute_a]) + arm_compute_lib = arm_compute_a +else: + Import('arm_compute_so') + benchmark_env.Append(LIBS = ["arm_compute"]) + arm_compute_lib = arm_compute_so + +#FIXME Delete before release +if common_env['internal_only']: + benchmark_env.Append(CPPDEFINES=['INTERNAL_ONLY']) + +benchmark_env.Append(CPPPATH = [".", "#3rdparty/include"]) +benchmark_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) +benchmark_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) +benchmark_env.Append(LIBPATH = ["#build/%s/framework" % env['build_dir']]) +benchmark_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) + +Import("arm_compute_test_framework") +benchmark_env.Append(LIBS = ['arm_compute_test_framework']) + +files_benchmark = Glob('new/DatasetManager.cpp') +files_benchmark += Glob('new/TensorLibrary.cpp') +files_benchmark += Glob('new/RawTensor.cpp') +files_benchmark += Glob('new/benchmark_new/*.cpp') + +# Add unit tests +if env['opencl']: + Import('opencl') + + benchmark_env.Append(CPPDEFINES=['OPENCL']) + + files_benchmark += Glob('new/benchmark_new/CL/*/*.cpp') + files_benchmark += Glob('new/benchmark_new/CL/*.cpp') + + benchmark_env.Append(LIBS = "OpenCL") + +if env['neon']: + files_benchmark += Glob('new/benchmark_new/NEON/*/*.cpp') + files_benchmark += Glob('new/benchmark_new/NEON/*.cpp') + +if env['os'] == 'android': + benchmark_env.Append(LIBS = ["log"]) +else: + benchmark_env.Append(LIBS = ["rt"]) + if common_env['benchmark_tests']: - arm_compute_benchmark = benchmark_env.Program('arm_compute_benchmark', - files_benchmark + common_objects) + arm_compute_benchmark = benchmark_env.Program('arm_compute_benchmark', files_benchmark) + Depends(arm_compute_benchmark, arm_compute_test_framework) Depends(arm_compute_benchmark, arm_compute_lib) + if env['opencl']: Depends(arm_compute_benchmark, opencl) + Default(arm_compute_benchmark) Export('arm_compute_benchmark') - diff --git a/tests/TypePrinter.h b/tests/TypePrinter.h index c4f3495761..75499065eb 100644 --- a/tests/TypePrinter.h +++ b/tests/TypePrinter.h @@ -29,6 +29,8 @@ #include "arm_compute/core/Types.h" #include <ostream> +#include <sstream> +#include <string> namespace arm_compute { @@ -53,6 +55,22 @@ inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions<T> &dimen return os; } +//FIXME: Check why this doesn't work and the TensorShape overload is needed +template <typename T> +inline std::string to_string(const Dimensions<T> &dimensions) +{ + std::stringstream str; + str << dimensions; + return str.str(); +} + +inline std::string to_string(const TensorShape &shape) +{ + std::stringstream str; + str << shape; + return str.str(); +} + /** Formatted output of the Rectangle type. */ inline ::std::ostream &operator<<(::std::ostream &os, const Rectangle &rect) { @@ -231,6 +249,13 @@ inline ::std::ostream &operator<<(::std::ostream &os, const ActivationLayerInfo: return os; } +inline std::string to_string(const arm_compute::ActivationLayerInfo &info) +{ + std::stringstream str; + str << info.activation(); + return str.str(); +} + /** Formatted output of the NormType type. */ inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type) { @@ -252,6 +277,13 @@ inline ::std::ostream &operator<<(::std::ostream &os, const NormType &norm_type) return os; } +inline std::string to_string(const arm_compute::NormalizationLayerInfo &info) +{ + std::stringstream str; + str << info.type(); + return str.str(); +} + /** Formatted output of the PoolingType type. */ inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_type) { @@ -270,6 +302,14 @@ inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_ty return os; } +/** Formatted output of @ref PoolingLayerInfo. */ +inline ::std::ostream &operator<<(::std::ostream &os, const PoolingLayerInfo &info) +{ + os << info.pool_type(); + + return os; +} + /** Formatted output of the RoundingPolicy type. */ inline ::std::ostream &operator<<(::std::ostream &os, const RoundingPolicy &rounding_policy) { @@ -348,6 +388,13 @@ inline ::std::ostream &operator<<(::std::ostream &os, const DataType &data_type) return os; } +inline std::string to_string(const arm_compute::DataType &data_type) +{ + std::stringstream str; + str << data_type; + return str.str(); +} + /** Formatted output of the Format type. */ inline ::std::ostream &operator<<(::std::ostream &os, const Format &format) { diff --git a/tests/benchmark/CL/ActivationLayer.cpp b/tests/benchmark/CL/ActivationLayer.cpp deleted file mode 100644 index 52a357b2a6..0000000000 --- a/tests/benchmark/CL/ActivationLayer.cpp +++ /dev/null @@ -1,211 +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 "CL/CLAccessor.h" -#include "Globals.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::cl; - -#include "benchmark/common/ActivationLayer.h" - -namespace -{ -using ActivationLayerAlexNet = ActivationLayer<AlexNetActivationLayerDataset, CLTensor, CLAccessor, CLActivationLayer>; -using ActivationLayerLeNet5 = ActivationLayer<LeNet5ActivationLayerDataset, CLTensor, CLAccessor, CLActivationLayer>; -using ActivationLayerGoogLeNet = ActivationLayer<GoogLeNetActivationLayerDataset, CLTensor, CLAccessor, CLActivationLayer>; -} // namespace - -BENCHMARK_DEFINE_F(ActivationLayerAlexNet, cl_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - act_layer.run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ActivationLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 4, 1, 4, 8>); - -BENCHMARK_DEFINE_F(ActivationLayerLeNet5, cl_lenet5) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - act_layer.run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ActivationLayerLeNet5, cl_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5ActivationLayerDataset, 0, 1, 4, 8>); - -BENCHMARK_DEFINE_F(ActivationLayerGoogLeNet, cl_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - act_layer.run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 4, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 5, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 6, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 7, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 8, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 9, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 10, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 11, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 12, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 13, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 14, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 15, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 16, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 17, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 18, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 19, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 20, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 21, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 22, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 23, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 24, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 25, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 26, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 27, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 28, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 29, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 30, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 31, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 32, 1, 4, 8>); diff --git a/tests/benchmark/CL/BitwiseAnd.cpp b/tests/benchmark/CL/BitwiseAnd.cpp deleted file mode 100644 index 4858c73948..0000000000 --- a/tests/benchmark/CL/BitwiseAnd.cpp +++ /dev/null @@ -1,133 +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 "CL/CLAccessor.h" -#include "Globals.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLBitwiseAnd.h" - -#include "benchmark/benchmark_api.h" - -#include <memory> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::cl; - -namespace -{ -template <typename DataSet> -class BitwiseAnd : public ::benchmark::Fixture -{ -public: - void SetUp(::benchmark::State &state) override - { - ::benchmark::Fixture::SetUp(state); - - profiler.add(std::make_shared<WallClockTimer>()); - - const std::string image_name = *(DataSet().begin() + state.range(0)); - const RawTensor &raw = library->get(image_name); - - // Create tensors - src1 = create_tensor<CLTensor>(raw.shape(), DataType::U8); - src2 = create_tensor<CLTensor>(raw.shape(), DataType::U8); - dst = create_tensor<CLTensor>(raw.shape(), DataType::U8); - - // Create and configure function - band.configure(&src1, &src2, &dst); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill source tensors - library->fill(CLAccessor(src1), image_name, Channel::R); - library->fill(CLAccessor(src2), image_name, Channel::G); - } - - void TearDown(::benchmark::State &state) override - { - profiler.submit(state); - - ::benchmark::Fixture::TearDown(state); - } - - CLBitwiseAnd band{}; - Profiler profiler{}; - -private: - CLTensor src1{}; - CLTensor src2{}; - CLTensor dst{}; -}; - -using BitwiseAndSmall = BitwiseAnd<SmallImages>; -using BitwiseAndLarge = BitwiseAnd<LargeImages>; -} // namespace - -BENCHMARK_DEFINE_F(BitwiseAndSmall, cl_bitwise_and) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - band.run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(BitwiseAndSmall, cl_bitwise_and) -->Threads(1) -->Apply(DataSetArgs<SmallImages>); - -BENCHMARK_DEFINE_F(BitwiseAndLarge, cl_bitwise_and) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - band.run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(BitwiseAndLarge, cl_bitwise_and) -->Threads(1) -->Apply(DataSetArgs<LargeImages>); diff --git a/tests/benchmark/CL/CMakeLists.txt b/tests/benchmark/CL/CMakeLists.txt deleted file mode 100644 index 8493309f40..0000000000 --- a/tests/benchmark/CL/CMakeLists.txt +++ /dev/null @@ -1,57 +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. -cmake_minimum_required (VERSION 3.1) - -include_directories(${CMAKE_SOURCE_DIR}/../include) - -set(arm_compute_test_benchmark_TARGET_DEFINITIONS - ${arm_compute_test_benchmark_TARGET_DEFINITIONS} - -DOPENCL - PARENT_SCOPE -) - -set(arm_compute_test_benchmark_TARGET_INCLUDES - ${arm_compute_test_benchmark_TARGET_INCLUDES} - ${CMAKE_SOURCE_DIR}/../include - PARENT_SCOPE -) - -set(arm_compute_test_benchmark_OPENCL_SOURCE_FILES - ${CMAKE_SOURCE_DIR}/CL/CLAccessor.h - ${CMAKE_CURRENT_SOURCE_DIR}/Bitwise/BitwiseAnd.cpp -) - -add_library(arm_compute_test_benchmark_OPENCL OBJECT - ${arm_compute_test_benchmark_OPENCL_SOURCE_FILES} -) - -set(arm_compute_test_benchmark_TARGET_OBJECTS - ${arm_compute_test_benchmark_TARGET_OBJECTS} - $<TARGET_OBJECTS:arm_compute_test_benchmark_OPENCL> - PARENT_SCOPE -) - -set(arm_compute_test_benchmark_TARGET_LIBRARIES - ${arm_compute_test_benchmark_TARGET_LIBRARIES} - OpenCL - PARENT_SCOPE -) diff --git a/tests/benchmark/CL/ConvolutionLayer.cpp b/tests/benchmark/CL/ConvolutionLayer.cpp deleted file mode 100644 index e790273f9c..0000000000 --- a/tests/benchmark/CL/ConvolutionLayer.cpp +++ /dev/null @@ -1,276 +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 "CL/CLAccessor.h" -#include "Globals.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::cl; - -#include "benchmark/common/ConvolutionLayer.h" - -namespace -{ -using ConvolutionLayerAlexNet = ConvolutionLayer<AlexNetConvolutionLayerDataset, CLTensor, CLAccessor, CLConvolutionLayer>; -using ConvolutionLayerLeNet5 = ConvolutionLayer<LeNet5ConvolutionLayerDataset, CLTensor, CLAccessor, CLConvolutionLayer>; -using ConvolutionLayerGoogLeNet1 = ConvolutionLayer<GoogLeNetConvolutionLayerDataset1, CLTensor, CLAccessor, CLConvolutionLayer>; -using ConvolutionLayerGoogLeNet2 = ConvolutionLayer<GoogLeNetConvolutionLayerDataset2, CLTensor, CLAccessor, CLConvolutionLayer>; -} // namespace - -BENCHMARK_DEFINE_F(ConvolutionLayerAlexNet, cl_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - conv_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 4, 1, 4, 8>); - -BENCHMARK_DEFINE_F(ConvolutionLayerLeNet5, cl_lenet5) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - conv_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ConvolutionLayerLeNet5, cl_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5ConvolutionLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerLeNet5, cl_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5ConvolutionLayerDataset, 1, 1, 4, 8>); - -BENCHMARK_DEFINE_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - conv_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_DEFINE_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - conv_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 4, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 5, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 6, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 7, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 8, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 9, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 10, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 11, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 12, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 13, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 14, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 15, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 16, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 17, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 18, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 19, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 20, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 21, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 22, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 23, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 24, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 25, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 26, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 27, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 28, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 29, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 30, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 31, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 4, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 5, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 6, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 7, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 8, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 9, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 10, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 11, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 12, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 13, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 14, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 15, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 16, 1, 4, 8>); diff --git a/tests/benchmark/CL/FullyConnectedLayer.cpp b/tests/benchmark/CL/FullyConnectedLayer.cpp deleted file mode 100644 index fb8e1bc09f..0000000000 --- a/tests/benchmark/CL/FullyConnectedLayer.cpp +++ /dev/null @@ -1,115 +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 "CL/CLAccessor.h" -#include "Globals.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" - -#include "benchmark/benchmark_api.h" - -#include <memory> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::cl; - -#include "benchmark/common/FullyConnectedLayer.h" - -namespace -{ -using FullyConnectedLayerAlexNet = FullyConnectedLayer<AlexNetFullyConnectedLayerDataset, CLTensor, CLAccessor, CLFullyConnectedLayer>; -using FullyConnectedLayerLeNet5 = FullyConnectedLayer<LeNet5FullyConnectedLayerDataset, CLTensor, CLAccessor, CLFullyConnectedLayer>; -using FullyConnectedLayerGoogLeNet = FullyConnectedLayer<GoogLeNetFullyConnectedLayerDataset, CLTensor, CLAccessor, CLFullyConnectedLayer>; -} // namespace - -BENCHMARK_DEFINE_F(FullyConnectedLayerAlexNet, cl_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - fc_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(FullyConnectedLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetFullyConnectedLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(FullyConnectedLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetFullyConnectedLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(FullyConnectedLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetFullyConnectedLayerDataset, 2, 1, 4, 8>); - -BENCHMARK_DEFINE_F(FullyConnectedLayerLeNet5, cl_lenet5) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - fc_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(FullyConnectedLayerLeNet5, cl_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5FullyConnectedLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(FullyConnectedLayerLeNet5, cl_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5FullyConnectedLayerDataset, 1, 1, 4, 8>); - -BENCHMARK_DEFINE_F(FullyConnectedLayerGoogLeNet, cl_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - fc_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(FullyConnectedLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetFullyConnectedLayerDataset, 0, 1, 4, 8>); diff --git a/tests/benchmark/CL/GEMM.cpp b/tests/benchmark/CL/GEMM.cpp deleted file mode 100644 index 87dad05f30..0000000000 --- a/tests/benchmark/CL/GEMM.cpp +++ /dev/null @@ -1,539 +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 "CL/CLAccessor.h" -#include "Globals.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLGEMM.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::cl; - -#include "benchmark/CL/GEMM.h" - -namespace -{ -using GEMMFP16GoogLeNet1 = GEMM<GoogLeNetGEMMDataset1, CLTensor, CLAccessor, CLGEMM, DataType::F16>; -using GEMMFP16GoogLeNet2 = GEMM<GoogLeNetGEMMDataset2, CLTensor, CLAccessor, CLGEMM, DataType::F16>; -using GEMMFP32GoogLeNet1 = GEMM<GoogLeNetGEMMDataset1, CLTensor, CLAccessor, CLGEMM, DataType::F32>; -using GEMMFP32GoogLeNet2 = GEMM<GoogLeNetGEMMDataset2, CLTensor, CLAccessor, CLGEMM, DataType::F32>; -using FP16MatrixMultiply = GEMM<MatrixMultiplyDataset, CLTensor, CLAccessor, CLGEMM, DataType::F16>; -using FP32MatrixMultiply = GEMM<MatrixMultiplyDataset, CLTensor, CLAccessor, CLGEMM, DataType::F32>; -} // namespace - -BENCHMARK_DEFINE_F(GEMMFP16GoogLeNet1, cl_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_DEFINE_F(GEMMFP16GoogLeNet2, cl_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 0>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 1>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 2>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 3>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 4>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 5>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 6>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 7>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 8>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 9>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 10>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 11>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 12>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 13>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 14>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 15>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 16>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 17>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 18>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 19>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 20>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 21>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 22>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 23>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 24>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 25>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 26>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 27>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 28>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 29>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 30>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 31>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 0>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 1>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 2>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 3>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 4>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 5>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 6>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 7>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 8>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 9>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 10>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 11>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 12>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 13>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 14>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 15>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 16>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 17>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 18>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 19>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 20>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 21>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 22>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 23>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 24>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 25>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 26>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 27>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 28>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 29>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 30>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 31>); - -BENCHMARK_DEFINE_F(GEMMFP32GoogLeNet1, cl_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_DEFINE_F(GEMMFP32GoogLeNet2, cl_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 0>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 1>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 2>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 3>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 4>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 5>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 6>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 7>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 8>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 9>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 10>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 11>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 12>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 13>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 14>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 15>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 16>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 17>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 18>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 19>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 20>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 21>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 22>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 23>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 24>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 25>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 26>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 27>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 28>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 29>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 30>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 31>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 0>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 1>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 2>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 3>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 4>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 5>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 6>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 7>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 8>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 9>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 10>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 11>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 12>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 13>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 14>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 15>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 16>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 17>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 18>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 19>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 20>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 21>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 22>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 23>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 24>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 25>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 26>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 27>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 28>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 29>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 30>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, cl_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 31>); - -BENCHMARK_DEFINE_F(FP16MatrixMultiply, cl_matrix_multiply) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(FP16MatrixMultiply, cl_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 0>); -BENCHMARK_REGISTER_F(FP16MatrixMultiply, cl_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 1>); -BENCHMARK_REGISTER_F(FP16MatrixMultiply, cl_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 2>); - -BENCHMARK_DEFINE_F(FP32MatrixMultiply, cl_matrix_multiply) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(FP32MatrixMultiply, cl_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 0>); -BENCHMARK_REGISTER_F(FP32MatrixMultiply, cl_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 1>); -BENCHMARK_REGISTER_F(FP32MatrixMultiply, cl_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 2>); diff --git a/tests/benchmark/CL/GEMM.h b/tests/benchmark/CL/GEMM.h deleted file mode 100644 index ca3d9ad594..0000000000 --- a/tests/benchmark/CL/GEMM.h +++ /dev/null @@ -1,102 +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_BENCHMARK_CL_GEMM_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_CL_GEMM_H__ - -#include "TensorLibrary.h" -#include "Utils.h" -#include "dataset/GEMMDataset.h" - -#include <memory> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; - -namespace arm_compute -{ -namespace test -{ -namespace benchmark -{ -// FIXME: Merge with NEON/GEMM.h into common/GEMM.h after adding F16 support to NEON GEMM and QS8 support to CL GEMM -template <typename DataSet, typename TensorType, typename Accessor, typename Function, DataType data_type> -class GEMM : public ::benchmark::Fixture -{ -public: - void SetUp(::benchmark::State &state) override - { - ARM_COMPUTE_ERROR_ON_MSG(data_type != DataType::F16 && data_type != DataType::F32, "Unsupported data type for GEMM operation"); - - profiler.add(std::make_shared<WallClockTimer>()); - - const GEMMDataObject gemm_obj = *(DataSet().begin() + state.range(0)); - - TensorShape shape_a = gemm_obj.shape_a; - TensorShape shape_b = gemm_obj.shape_b; - TensorShape shape_c = gemm_obj.shape_c; - TensorShape shape_d = gemm_obj.shape_d; - - // Create tensors - a = create_tensor<CLTensor>(shape_a, data_type); - b = create_tensor<CLTensor>(shape_b, data_type); - c = create_tensor<CLTensor>(shape_c, data_type); - d = create_tensor<CLTensor>(shape_d, data_type); - - // Create and configure function - gemm_layer = std::unique_ptr<Function>(new Function()); - gemm_layer->configure(&a, &b, &c, &d, gemm_obj.alpha, gemm_obj.beta); - - // Allocate tensors - a.allocator()->allocate(); - b.allocator()->allocate(); - c.allocator()->allocate(); - d.allocator()->allocate(); - } - - void TearDown(::benchmark::State &state) override - { - gemm_layer.reset(); - - a.allocator()->free(); - b.allocator()->free(); - c.allocator()->free(); - d.allocator()->free(); - - profiler.submit(state); - } - - std::unique_ptr<Function> gemm_layer{ nullptr }; - Profiler profiler{}; - -private: - TensorType a{}; - TensorType b{}; - TensorType c{}; - TensorType d{}; -}; -} // namespace benchmark -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_BENCHMARK_CL_GEMM_H__ diff --git a/tests/benchmark/CL/NormalizationLayer.cpp b/tests/benchmark/CL/NormalizationLayer.cpp deleted file mode 100644 index 28f89dce1f..0000000000 --- a/tests/benchmark/CL/NormalizationLayer.cpp +++ /dev/null @@ -1,92 +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 "CL/CLAccessor.h" -#include "Globals.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::cl; - -#include "benchmark/common/NormalizationLayer.h" - -namespace -{ -using NormalizationLayerAlexNet = NormalizationLayer<AlexNetNormalizationLayerDataset, CLTensor, CLAccessor, CLNormalizationLayer>; -using NormalizationLayerGoogLeNet = NormalizationLayer<GoogLeNetNormalizationLayerDataset, CLTensor, CLAccessor, CLNormalizationLayer>; - -} // namespace - -BENCHMARK_DEFINE_F(NormalizationLayerAlexNet, cl_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - norm_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(NormalizationLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(NormalizationLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 1, 1, 4, 8>); - -BENCHMARK_DEFINE_F(NormalizationLayerGoogLeNet, cl_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - norm_layer->run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(NormalizationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetNormalizationLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(NormalizationLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetNormalizationLayerDataset, 1, 1, 4, 8>); diff --git a/tests/benchmark/CL/PoolingLayer.cpp b/tests/benchmark/CL/PoolingLayer.cpp deleted file mode 100644 index 05764a412a..0000000000 --- a/tests/benchmark/CL/PoolingLayer.cpp +++ /dev/null @@ -1,140 +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 "CL/CLAccessor.h" -#include "Globals.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::cl; - -#include "benchmark/common/PoolingLayer.h" - -namespace -{ -using PoolingLayerAlexNet = PoolingLayer<AlexNetPoolingLayerDataset, CLTensor, CLAccessor, CLPoolingLayer>; -using PoolingLayerLeNet5 = PoolingLayer<LeNet5PoolingLayerDataset, CLTensor, CLAccessor, CLPoolingLayer>; -using PoolingLayerGoogLeNet = PoolingLayer<GoogLeNetPoolingLayerDataset, CLTensor, CLAccessor, CLPoolingLayer>; -} // namespace - -BENCHMARK_DEFINE_F(PoolingLayerAlexNet, cl_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - pool_layer.run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(PoolingLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetPoolingLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetPoolingLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerAlexNet, cl_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetPoolingLayerDataset, 2, 1, 4, 8>); - -BENCHMARK_DEFINE_F(PoolingLayerLeNet5, cl_lenet5) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - pool_layer.run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(PoolingLayerLeNet5, cl_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5PoolingLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerLeNet5, cl_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5PoolingLayerDataset, 1, 1, 4, 8>); - -BENCHMARK_DEFINE_F(PoolingLayerGoogLeNet, cl_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - pool_layer.run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} - -// FIXME: Add support for 7x7 pooling layer pool5/7x7_s1 -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 4, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 5, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 6, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 7, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 8, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, cl_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 9, 1, 4, 8>); diff --git a/tests/benchmark/CMakeLists.txt b/tests/benchmark/CMakeLists.txt deleted file mode 100644 index 115333a1b0..0000000000 --- a/tests/benchmark/CMakeLists.txt +++ /dev/null @@ -1,100 +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. -cmake_minimum_required (VERSION 3.1) - -add_library(benchmark STATIC IMPORTED) -set_target_properties(benchmark PROPERTIES - IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/../3rdparty/linux/armv7a/libbenchmark.a" -) - -add_library(OpenCL SHARED IMPORTED) -set_target_properties(OpenCL PROPERTIES - IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/../build/opencl-1.2-stubs/libOpenCL.so" - IMPORTED_NO_SONAME 1 -) - -option(ENABLE_PMU_COUNTER "Compile with PMU counter support") - -set(ARM_COMPUTE_TARGETS_TO_MEASURE "all" CACHE STRING "Semicolon-separated list of targets to include in validation.") - -set(ARM_COMPUTE_ALL_TARGETS - NEON - CL -) - -if(ARM_COMPUTE_TARGETS_TO_MEASURE STREQUAL "all") - set(ARM_COMPUTE_TARGETS_TO_MEASURE ${ARM_COMPUTE_ALL_TARGETS}) -endif() - -list(REMOVE_DUPLICATES ARM_COMPUTE_TARGETS_TO_MEASURE) - -foreach(TARGET ${ARM_COMPUTE_TARGETS_TO_MEASURE}) - list(FIND ARM_COMPUTE_ALL_TARGETS ${TARGET} idx) - - if(${idx} LESS 0) - message(FATAL_ERROR "The target '${TARGET}' does not exist. It should be one of\n${ARM_COMPUTE_ALL_TARGETS}") - else() - add_subdirectory(${TARGET}) - endif() -endforeach() - -set(arm_compute_test_benchmark_SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Datasets.h - ${CMAKE_CURRENT_SOURCE_DIR}/Instrument.h - ${CMAKE_CURRENT_SOURCE_DIR}/Profiler.h - ${CMAKE_CURRENT_SOURCE_DIR}/Profiler.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/PerformanceProgramOptions.h - ${CMAKE_CURRENT_SOURCE_DIR}/PerformanceProgramOptions.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/PerformanceUserConfiguration.h - ${CMAKE_CURRENT_SOURCE_DIR}/PerformanceUserConfiguration.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/WallClockTimer.h - ${CMAKE_CURRENT_SOURCE_DIR}/WallClockTimer.cpp -) - -if(${ENABLE_PMU_COUNTER}) - list(APPEND arm_compute_test_benchmark_SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/PMUCounter.h - ${CMAKE_CURRENT_SOURCE_DIR}/PMUCounter.cpp - ) -endif() - -add_library(arm_compute_test_benchmark OBJECT - ${arm_compute_test_benchmark_SOURCE_FILES} -) - -add_definitions(${arm_compute_test_benchmark_TARGET_DEFINITIONS}) -include_directories(${arm_compute_test_benchmark_TARGET_INCLUDES}) - -add_executable(arm_compute_benchmark - $<TARGET_OBJECTS:arm_compute_test_benchmark> - ${arm_compute_test_benchmark_TARGET_OBJECTS} - $<TARGET_OBJECTS:tensor_library> - $<TARGET_OBJECTS:arm_compute_test> -) - -target_link_libraries(arm_compute_benchmark - benchmark - boost_program_options - arm_compute - ${arm_compute_test_benchmark_TARGET_LIBRARIES} -) diff --git a/tests/benchmark/Datasets.h b/tests/benchmark/Datasets.h deleted file mode 100644 index cb45b50589..0000000000 --- a/tests/benchmark/Datasets.h +++ /dev/null @@ -1,79 +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_BENCHMARK_DATASETS_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_DATASETS_H__ - -#include "dataset/ActivationLayerDataset.h" -#include "dataset/BorderModeDataset.h" -#include "dataset/ConvolutionLayerDataset.h" -#include "dataset/DataTypeDatasets.h" -#include "dataset/FullyConnectedLayerDataset.h" -#include "dataset/GEMMDataset.h" -#include "dataset/ImageDatasets.h" -#include "dataset/InterpolationPolicyDataset.h" -#include "dataset/NormalizationLayerDataset.h" -#include "dataset/PoolingLayerDataset.h" -#include "dataset/ShapeDatasets.h" - -#include "benchmark/benchmark_api.h" - -#include <array> - -namespace arm_compute -{ -namespace test -{ -namespace benchmark -{ -template <typename DataSet, int N> -void DataSetArg(::benchmark::internal::Benchmark *b) -{ - b->Arg(N); - b->ArgName(std::string(*(DataSet().begin() + N))); -} - -template <typename DataSet, int N, unsigned int... Args> -void DataSetArgBatched(::benchmark::internal::Benchmark *b) -{ - constexpr std::array<unsigned int, sizeof...(Args)> batches{ { Args... } }; - for(const auto &el : batches) - { - b->Args({ N, static_cast<int>(el) }); - } - b->ArgNames({ std::string(*(DataSet().begin() + N)), "batch_size" }); -} - -template <typename DataSet> -void DataSetArgs(::benchmark::internal::Benchmark *b) -{ - for(size_t i = 0; i < DataSet().size(); ++i) - { - b->Arg(i); - b->ArgName(*(DataSet().begin() + i)); - } -} -} -} -} -#endif /* __ARM_COMPUTE_TEST_BENCHMARK_DATASETS_H__ */ diff --git a/tests/benchmark/Instrument.h b/tests/benchmark/Instrument.h deleted file mode 100644 index 5034471091..0000000000 --- a/tests/benchmark/Instrument.h +++ /dev/null @@ -1,107 +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_BENCHMARK_INSTRUMENT_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_INSTRUMENT_H__ - -#include "Utils.h" - -#include <memory> -#include <string> - -namespace arm_compute -{ -namespace test -{ -namespace benchmark -{ -/** Interface for classes that can be used to measure performance. */ -class Instrument -{ -public: - /** Interface defining a measurement, e.g. time, cycles, ... */ - class IMeasurement - { - public: - IMeasurement() = default; - IMeasurement(const IMeasurement &) = default; - IMeasurement(IMeasurement &&) = default; - IMeasurement &operator=(const IMeasurement &) = default; - IMeasurement &operator=(IMeasurement &&) = default; - virtual ~IMeasurement() = default; - - virtual operator double() const = 0; - }; - - /** Implementation of a Measurement class for arihtmetic types. */ - template <typename T> - class Measurement : public IMeasurement - { - public: - /** Store the given value as measurement. - * - * @param[in] value Measured value. - */ - Measurement(T value); - - operator double() const override; - - private: - T _value; - }; - - Instrument() = default; - Instrument(const Instrument &) = default; - Instrument(Instrument &&) = default; - Instrument &operator=(const Instrument &) = default; - Instrument &operator=(Instrument &&) = default; - virtual ~Instrument() = default; - - /** Identifier for the instrument */ - virtual std::string id() const = 0; - - /** Start measuring. */ - virtual void start() = 0; - - /** Stop measuring. */ - virtual void stop() = 0; - - /** Return the latest measurement. */ - virtual std::unique_ptr<IMeasurement> get_measurement() const = 0; -}; - -template <typename T> -Instrument::Measurement<T>::Measurement(T value) - : _value{ value } -{ -} - -template <typename T> -Instrument::Measurement<T>::operator double() const -{ - return _value; -} -} // namespace benchmark -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BENCHMARK_INSTRUMENT_H__ */ diff --git a/tests/benchmark/NEON/ActivationLayer.cpp b/tests/benchmark/NEON/ActivationLayer.cpp deleted file mode 100644 index 9ea675e515..0000000000 --- a/tests/benchmark/NEON/ActivationLayer.cpp +++ /dev/null @@ -1,238 +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 "Globals.h" -#include "NEON/NEAccessor.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::neon; - -#include "benchmark/common/ActivationLayer.h" - -namespace -{ -using ActivationLayerAlexNetF32 = ActivationLayer<AlexNetActivationLayerDataset, Tensor, NEAccessor, NEActivationLayer>; -using ActivationLayerAlexNetQS8 = ActivationLayer<AlexNetActivationLayerDataset, Tensor, NEAccessor, NEActivationLayer, DataType::QS8>; -using ActivationLayerLeNet5 = ActivationLayer<LeNet5ActivationLayerDataset, Tensor, NEAccessor, NEActivationLayer, DataType::F32>; -using ActivationLayerGoogLeNet = ActivationLayer<GoogLeNetActivationLayerDataset, Tensor, NEAccessor, NEActivationLayer, DataType::F32>; -} // namespace - -// F32 -BENCHMARK_DEFINE_F(ActivationLayerAlexNetF32, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - act_layer.run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ActivationLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 4, 1, 4, 8>); - -// QS8 -BENCHMARK_DEFINE_F(ActivationLayerAlexNetQS8, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - act_layer.run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ActivationLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetActivationLayerDataset, 4, 1, 4, 8>); - -BENCHMARK_DEFINE_F(ActivationLayerLeNet5, neon_lenet5) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - act_layer.run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ActivationLayerLeNet5, neon_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5ActivationLayerDataset, 0, 1, 4, 8>); - -BENCHMARK_DEFINE_F(ActivationLayerGoogLeNet, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - act_layer.run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 4, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 5, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 6, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 7, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 8, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 9, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 10, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 11, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 12, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 13, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 14, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 15, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 16, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 17, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 18, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 19, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 20, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 21, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 22, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 23, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 24, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 25, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 26, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 27, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 28, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 29, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 30, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 31, 1, 4, 8>); -BENCHMARK_REGISTER_F(ActivationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetActivationLayerDataset, 32, 1, 4, 8>); diff --git a/tests/benchmark/NEON/BitwiseAnd.cpp b/tests/benchmark/NEON/BitwiseAnd.cpp deleted file mode 100644 index be68fd39e4..0000000000 --- a/tests/benchmark/NEON/BitwiseAnd.cpp +++ /dev/null @@ -1,126 +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 "Globals.h" -#include "NEON/NEAccessor.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBitwiseAnd.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "benchmark/benchmark_api.h" - -#include <memory> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::neon; - -namespace -{ -template <typename DataSet> -class BitwiseAnd : public ::benchmark::Fixture -{ -public: - void SetUp(::benchmark::State &state) override - { - profiler.add(std::make_shared<WallClockTimer>()); - - const std::string image_name = *(DataSet().begin() + state.range(0)); - const RawTensor &raw = library->get(image_name); - - // Create tensors - src1 = create_tensor<Tensor>(raw.shape(), DataType::U8); - src2 = create_tensor<Tensor>(raw.shape(), DataType::U8); - dst = create_tensor<Tensor>(raw.shape(), DataType::U8); - - // Create and configure function - band.configure(&src1, &src2, &dst); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill source tensors - library->fill(NEAccessor(src1), image_name, Channel::R); - library->fill(NEAccessor(src2), image_name, Channel::G); - } - - void TearDown(::benchmark::State &state) override - { - profiler.submit(state); - } - - NEBitwiseAnd band{}; - Profiler profiler{}; - -private: - Tensor src1{}; - Tensor src2{}; - Tensor dst{}; -}; - -using BitwiseAndSmall = BitwiseAnd<SmallImages>; -using BitwiseAndLarge = BitwiseAnd<LargeImages>; -} // namespace - -BENCHMARK_DEFINE_F(BitwiseAndSmall, neon_bitwise_and) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - band.run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(BitwiseAndSmall, neon_bitwise_and) -->Threads(1) -->Apply(DataSetArgs<SmallImages>); - -BENCHMARK_DEFINE_F(BitwiseAndLarge, neon_bitwise_and) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - band.run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(BitwiseAndLarge, neon_bitwise_and) -->Threads(1) -->Apply(DataSetArgs<LargeImages>); diff --git a/tests/benchmark/NEON/CMakeLists.txt b/tests/benchmark/NEON/CMakeLists.txt deleted file mode 100644 index 2cb3eb36c9..0000000000 --- a/tests/benchmark/NEON/CMakeLists.txt +++ /dev/null @@ -1,37 +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. -cmake_minimum_required (VERSION 3.1) - -set(arm_compute_test_benchmark_NEON_SOURCE_FILES - ${CMAKE_SOURCE_DIR}/NEON/NEAccessor.h - ${CMAKE_CURRENT_SOURCE_DIR}/Bitwise/BitwiseAnd.cpp -) - -add_library(arm_compute_test_benchmark_NEON OBJECT - ${arm_compute_test_benchmark_NEON_SOURCE_FILES} -) - -SET(arm_compute_test_benchmark_TARGET_OBJECTS - ${arm_compute_test_benchmark_TARGET_OBJECTS} - $<TARGET_OBJECTS:arm_compute_test_benchmark_NEON> - PARENT_SCOPE -) diff --git a/tests/benchmark/NEON/ConvolutionLayer.cpp b/tests/benchmark/NEON/ConvolutionLayer.cpp deleted file mode 100644 index a0b1236177..0000000000 --- a/tests/benchmark/NEON/ConvolutionLayer.cpp +++ /dev/null @@ -1,302 +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 "Globals.h" -#include "NEON/NEAccessor.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::neon; - -#include "benchmark/common/ConvolutionLayer.h" - -namespace -{ -using ConvolutionLayerAlexNetF32 = ConvolutionLayer<AlexNetConvolutionLayerDataset, Tensor, NEAccessor, NEConvolutionLayer>; -using ConvolutionLayerAlexNetQS8 = ConvolutionLayer<AlexNetConvolutionLayerDataset, Tensor, NEAccessor, NEConvolutionLayer, DataType::QS8>; -using ConvolutionLayerLeNet5 = ConvolutionLayer<LeNet5ConvolutionLayerDataset, Tensor, NEAccessor, NEConvolutionLayer>; -using ConvolutionLayerGoogLeNet1 = ConvolutionLayer<GoogLeNetConvolutionLayerDataset1, Tensor, NEAccessor, NEConvolutionLayer>; -using ConvolutionLayerGoogLeNet2 = ConvolutionLayer<GoogLeNetConvolutionLayerDataset2, Tensor, NEAccessor, NEConvolutionLayer>; -} // namespace - -// F32 -BENCHMARK_DEFINE_F(ConvolutionLayerAlexNetF32, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - conv_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 4, 1, 4, 8>); - -// QS8 -BENCHMARK_DEFINE_F(ConvolutionLayerAlexNetQS8, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - conv_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 4, 1, 4, 8>); - -BENCHMARK_DEFINE_F(ConvolutionLayerLeNet5, neon_lenet5) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - conv_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ConvolutionLayerLeNet5, neon_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5ConvolutionLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerLeNet5, neon_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5ConvolutionLayerDataset, 1, 1, 4, 8>); - -BENCHMARK_DEFINE_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - conv_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_DEFINE_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - conv_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 4, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 5, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 6, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 7, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 8, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 9, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 10, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 11, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 12, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 13, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 14, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 15, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 16, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 17, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 18, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 19, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 20, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 21, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 22, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 23, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 24, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 25, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 26, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 27, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 28, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 29, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 30, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset1, 31, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 4, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 5, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 6, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 7, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 8, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 9, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 10, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 11, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 12, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 13, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 14, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 15, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerGoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetConvolutionLayerDataset2, 16, 1, 4, 8>); diff --git a/tests/benchmark/NEON/ConvolutionLayerDirect.cpp b/tests/benchmark/NEON/ConvolutionLayerDirect.cpp deleted file mode 100644 index bbe5707e41..0000000000 --- a/tests/benchmark/NEON/ConvolutionLayerDirect.cpp +++ /dev/null @@ -1,73 +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 "Globals.h" -#include "NEON/NEAccessor.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" -#include "dataset/ConvolutionLayerDataset.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::neon; - -#include "benchmark/common/ConvolutionLayer.h" - -namespace -{ -using ConvolutionLayerDirectAlexNet = ConvolutionLayer<AlexNetConvolutionLayerDataset, Tensor, NEAccessor, NEDirectConvolutionLayer>; -} // namespace - -BENCHMARK_DEFINE_F(ConvolutionLayerDirectAlexNet, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - conv_layer->run(); - profiler.stop(); - } -} - -// Registr only the 3x3 convolution layers -BENCHMARK_REGISTER_F(ConvolutionLayerDirectAlexNet, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerDirectAlexNet, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(ConvolutionLayerDirectAlexNet, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 4, 1, 4, 8>); diff --git a/tests/benchmark/NEON/FullyConnectedLayer.cpp b/tests/benchmark/NEON/FullyConnectedLayer.cpp deleted file mode 100644 index 15c2a407e6..0000000000 --- a/tests/benchmark/NEON/FullyConnectedLayer.cpp +++ /dev/null @@ -1,131 +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 "Globals.h" -#include "NEON/NEAccessor.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::neon; - -#include "benchmark/common/FullyConnectedLayer.h" - -namespace -{ -using FullyConnectedLayerAlexNetF32 = FullyConnectedLayer<AlexNetFullyConnectedLayerDataset, Tensor, NEAccessor, NEFullyConnectedLayer>; -using FullyConnectedLayerAlexNetQS8 = FullyConnectedLayer<AlexNetFullyConnectedLayerDataset, Tensor, NEAccessor, NEFullyConnectedLayer, DataType::QS8>; -using FullyConnectedLayerLeNet5 = FullyConnectedLayer<LeNet5FullyConnectedLayerDataset, Tensor, NEAccessor, NEFullyConnectedLayer>; -using FullyConnectedLayerGoogLeNet = FullyConnectedLayer<GoogLeNetFullyConnectedLayerDataset, Tensor, NEAccessor, NEFullyConnectedLayer>; -} // namespace - -// F32 -BENCHMARK_DEFINE_F(FullyConnectedLayerAlexNetF32, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - fc_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(FullyConnectedLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetFullyConnectedLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(FullyConnectedLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetFullyConnectedLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(FullyConnectedLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetFullyConnectedLayerDataset, 2, 1, 4, 8>); - -// QS8 -BENCHMARK_DEFINE_F(FullyConnectedLayerAlexNetQS8, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - fc_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(FullyConnectedLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetFullyConnectedLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(FullyConnectedLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetFullyConnectedLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(FullyConnectedLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetFullyConnectedLayerDataset, 2, 1, 4, 8>); - -BENCHMARK_DEFINE_F(FullyConnectedLayerLeNet5, neon_lenet5) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - fc_layer->run(); - profiler.stop(); - } -} -BENCHMARK_REGISTER_F(FullyConnectedLayerLeNet5, neon_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5FullyConnectedLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(FullyConnectedLayerLeNet5, neon_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5FullyConnectedLayerDataset, 1, 1, 4, 8>); - -BENCHMARK_DEFINE_F(FullyConnectedLayerGoogLeNet, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - fc_layer->run(); - profiler.stop(); - } -} -BENCHMARK_REGISTER_F(FullyConnectedLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetFullyConnectedLayerDataset, 0, 1, 4, 8>); diff --git a/tests/benchmark/NEON/GEMM.cpp b/tests/benchmark/NEON/GEMM.cpp deleted file mode 100644 index 1655c32e2b..0000000000 --- a/tests/benchmark/NEON/GEMM.cpp +++ /dev/null @@ -1,777 +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 "Globals.h" -#include "NEON/NEAccessor.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEGEMM.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::neon; - -#include "benchmark/NEON/GEMM.h" - -namespace -{ -#ifdef ENABLE_FP16 -using GEMMFP16GoogLeNet1 = GEMM<GoogLeNetGEMMDataset1, Tensor, NEAccessor, NEGEMM, DataType::F16>; -using GEMMFP16GoogLeNet2 = GEMM<GoogLeNetGEMMDataset2, Tensor, NEAccessor, NEGEMM, DataType::F16>; -using FP16MatrixMultiply = GEMM<MatrixMultiplyDataset, Tensor, NEAccessor, NEGEMM, DataType::F16>; -#endif /* ENABLE_FP16 */ -using GEMMFP32GoogLeNet1 = GEMM<GoogLeNetGEMMDataset1, Tensor, NEAccessor, NEGEMM, DataType::F32>; -using GEMMFP32GoogLeNet2 = GEMM<GoogLeNetGEMMDataset2, Tensor, NEAccessor, NEGEMM, DataType::F32>; -using GEMMQS8GoogLeNet1 = GEMM<GoogLeNetGEMMDataset1, Tensor, NEAccessor, NEGEMM, DataType::QS8>; -using GEMMQS8GoogLeNet2 = GEMM<GoogLeNetGEMMDataset2, Tensor, NEAccessor, NEGEMM, DataType::QS8>; -using FP32MatrixMultiply = GEMM<MatrixMultiplyDataset, Tensor, NEAccessor, NEGEMM, DataType::F32>; -using QS8MatrixMultiply = GEMM<MatrixMultiplyDataset, Tensor, NEAccessor, NEGEMM, DataType::QS8>; -} // namespace -#ifdef ENABLE_FP16 -BENCHMARK_DEFINE_F(GEMMFP16GoogLeNet1, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_DEFINE_F(GEMMFP16GoogLeNet2, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 0>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 1>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 2>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 3>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 4>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 5>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 6>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 7>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 8>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 9>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 10>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 11>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 12>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 13>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 14>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 15>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 16>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 17>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 18>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 19>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 20>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 21>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 22>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 23>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 24>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 25>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 26>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 27>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 28>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 29>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 30>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 31>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 0>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 1>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 2>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 3>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 4>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 5>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 6>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 7>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 8>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 9>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 10>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 11>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 12>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 13>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 14>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 15>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 16>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 17>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 18>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 19>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 20>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 21>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 22>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 23>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 24>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 25>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 26>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 27>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 28>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 29>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 30>); -BENCHMARK_REGISTER_F(GEMMFP16GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 31>); - -BENCHMARK_DEFINE_F(FP16MatrixMultiply, neon_matrix_multiply) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(FP16MatrixMultiply, neon_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 0>); -BENCHMARK_REGISTER_F(FP16MatrixMultiply, neon_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 1>); -BENCHMARK_REGISTER_F(FP16MatrixMultiply, neon_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 2>); -#endif /* ENABLE_FP16 */ - -BENCHMARK_DEFINE_F(GEMMFP32GoogLeNet1, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_DEFINE_F(GEMMFP32GoogLeNet2, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 0>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 1>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 2>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 3>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 4>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 5>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 6>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 7>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 8>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 9>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 10>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 11>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 12>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 13>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 14>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 15>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 16>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 17>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 18>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 19>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 20>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 21>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 22>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 23>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 24>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 25>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 26>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 27>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 28>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 29>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 30>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 31>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 0>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 1>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 2>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 3>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 4>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 5>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 6>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 7>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 8>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 9>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 10>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 11>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 12>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 13>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 14>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 15>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 16>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 17>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 18>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 19>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 20>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 21>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 22>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 23>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 24>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 25>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 26>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 27>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 28>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 29>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 30>); -BENCHMARK_REGISTER_F(GEMMFP32GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 31>); - -BENCHMARK_DEFINE_F(GEMMQS8GoogLeNet1, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_DEFINE_F(GEMMQS8GoogLeNet2, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 0>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 1>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 2>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 3>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 4>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 5>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 6>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 7>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 8>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 9>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 10>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 11>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 12>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 13>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 14>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 15>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 16>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 17>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 18>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 19>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 20>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 21>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 22>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 23>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 24>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 25>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 26>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 27>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 28>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 29>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 30>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet1, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset1, 31>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 0>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 1>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 2>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 3>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 4>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 5>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 6>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 7>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 8>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 9>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 10>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 11>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 12>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 13>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 14>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 15>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 16>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 17>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 18>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 19>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 20>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 21>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 22>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 23>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 24>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 25>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 26>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 27>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 28>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 29>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 30>); -BENCHMARK_REGISTER_F(GEMMQS8GoogLeNet2, neon_googlenet) -->Threads(1) -->Apply(DataSetArg<GoogLeNetGEMMDataset2, 31>); - -BENCHMARK_DEFINE_F(FP32MatrixMultiply, neon_matrix_multiply) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(FP32MatrixMultiply, neon_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 0>); -BENCHMARK_REGISTER_F(FP32MatrixMultiply, neon_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 1>); -BENCHMARK_REGISTER_F(FP32MatrixMultiply, neon_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 2>); - -BENCHMARK_DEFINE_F(QS8MatrixMultiply, neon_matrix_multiply) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - gemm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(QS8MatrixMultiply, neon_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 0>); -BENCHMARK_REGISTER_F(QS8MatrixMultiply, neon_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 1>); -BENCHMARK_REGISTER_F(QS8MatrixMultiply, neon_matrix_multiply) -->Threads(1) -->Apply(DataSetArg<MatrixMultiplyDataset, 2>); diff --git a/tests/benchmark/NEON/GEMM.h b/tests/benchmark/NEON/GEMM.h deleted file mode 100644 index 4f0557d610..0000000000 --- a/tests/benchmark/NEON/GEMM.h +++ /dev/null @@ -1,106 +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_BENCHMARK_NEON_GEMM_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_NEON_GEMM_H__ - -#include "TensorLibrary.h" -#include "Utils.h" -#include "dataset/GEMMDataset.h" - -#include <memory> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; - -namespace arm_compute -{ -namespace test -{ -namespace benchmark -{ -// FIXME: Merge with CL/GEMM.h into common/GEMM.h after adding F16 support to NEON GEMM and QS8 support to CL GEMM -template <typename DataSet, typename TensorType, typename Accessor, typename Function, DataType data_type> -class GEMM : public ::benchmark::Fixture -{ -public: - void SetUp(::benchmark::State &state) override - { -#ifdef ENABLE_FP16 - ARM_COMPUTE_ERROR_ON_MSG(data_type != DataType::F16 && data_type != DataType::F32 && data_type != DataType::QS8, "Unsupported data type for GEMM operation"); -#else /* ENABLE_FP16 */ - ARM_COMPUTE_ERROR_ON_MSG(data_type != DataType::F32 && data_type != DataType::QS8, "Unsupported data type for GEMM operation"); -#endif /* ENABLE_FP16 */ - - profiler.add(std::make_shared<WallClockTimer>()); - - const GEMMDataObject gemm_obj = *(DataSet().begin() + state.range(0)); - - TensorShape shape_a = gemm_obj.shape_a; - TensorShape shape_b = gemm_obj.shape_b; - TensorShape shape_c = gemm_obj.shape_c; - TensorShape shape_d = gemm_obj.shape_d; - - // Create tensors - a = create_tensor<Tensor>(shape_a, data_type, 1, 4); - b = create_tensor<Tensor>(shape_b, data_type, 1, 4); - c = create_tensor<Tensor>(shape_c, data_type, 1, 4); - d = create_tensor<Tensor>(shape_d, data_type, 1, 4); - - // Create and configure function - gemm_layer = std::unique_ptr<Function>(new Function()); - gemm_layer->configure(&a, &b, &c, &d, gemm_obj.alpha, gemm_obj.beta); - - // Allocate tensors - a.allocator()->allocate(); - b.allocator()->allocate(); - c.allocator()->allocate(); - d.allocator()->allocate(); - } - - void TearDown(::benchmark::State &state) override - { - gemm_layer.reset(); - - a.allocator()->free(); - b.allocator()->free(); - c.allocator()->free(); - d.allocator()->free(); - - profiler.submit(state); - } - - std::unique_ptr<Function> gemm_layer{ nullptr }; - Profiler profiler{}; - -private: - TensorType a{}; - TensorType b{}; - TensorType c{}; - TensorType d{}; -}; -} // namespace benchmark -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_BENCHMARK_NEON_GEMM_H__ diff --git a/tests/benchmark/NEON/NormalizationLayer.cpp b/tests/benchmark/NEON/NormalizationLayer.cpp deleted file mode 100644 index 8ea8c95cda..0000000000 --- a/tests/benchmark/NEON/NormalizationLayer.cpp +++ /dev/null @@ -1,110 +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 "Globals.h" -#include "NEON/NEAccessor.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::neon; - -#include "benchmark/common/NormalizationLayer.h" - -namespace -{ -using NormalizationLayerAlexNetF32 = NormalizationLayer<AlexNetNormalizationLayerDataset, Tensor, NEAccessor, NENormalizationLayer>; -using NormalizationLayerAlexNetQS8 = NormalizationLayer<AlexNetNormalizationLayerDataset, Tensor, NEAccessor, NENormalizationLayer, DataType::QS8>; -using NormalizationLayerGoogLeNet = NormalizationLayer<GoogLeNetNormalizationLayerDataset, Tensor, NEAccessor, NENormalizationLayer>; -} // namespace - -// F32 -BENCHMARK_DEFINE_F(NormalizationLayerAlexNetF32, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - norm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(NormalizationLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(NormalizationLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 1, 1, 4, 8>); - -// QS8 -BENCHMARK_DEFINE_F(NormalizationLayerAlexNetQS8, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - norm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(NormalizationLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(NormalizationLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 1, 1, 4, 8>); - -BENCHMARK_DEFINE_F(NormalizationLayerGoogLeNet, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - norm_layer->run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(NormalizationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetNormalizationLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(NormalizationLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetNormalizationLayerDataset, 1, 1, 4, 8>); diff --git a/tests/benchmark/NEON/PoolingLayer.cpp b/tests/benchmark/NEON/PoolingLayer.cpp deleted file mode 100644 index dfa75497cd..0000000000 --- a/tests/benchmark/NEON/PoolingLayer.cpp +++ /dev/null @@ -1,161 +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 "Globals.h" -#include "NEON/NEAccessor.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::neon; - -#include "benchmark/common/PoolingLayer.h" - -namespace -{ -using PoolingLayerAlexNetF32 = PoolingLayer<AlexNetPoolingLayerDataset, Tensor, NEAccessor, NEPoolingLayer>; -using PoolingLayerAlexNetQS8 = PoolingLayer<AlexNetPoolingLayerDataset, Tensor, NEAccessor, NEPoolingLayer, DataType::QS8>; -using PoolingLayerLeNet5 = PoolingLayer<LeNet5PoolingLayerDataset, Tensor, NEAccessor, NEPoolingLayer>; -using PoolingLayerGoogLeNet = PoolingLayer<GoogLeNetPoolingLayerDataset, Tensor, NEAccessor, NEPoolingLayer>; -} // namespace - -// F32 -BENCHMARK_DEFINE_F(PoolingLayerAlexNetF32, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - pool_layer.run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(PoolingLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetPoolingLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetPoolingLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerAlexNetF32, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetPoolingLayerDataset, 2, 1, 4, 8>); - -// QS8 -BENCHMARK_DEFINE_F(PoolingLayerAlexNetQS8, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - pool_layer.run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(PoolingLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetPoolingLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetPoolingLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerAlexNetQS8, neon_alexnet) -->Threads(1) -->Apply(DataSetArgBatched<AlexNetPoolingLayerDataset, 2, 1, 4, 8>); - -BENCHMARK_DEFINE_F(PoolingLayerLeNet5, neon_lenet5) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - pool_layer.run(); - profiler.stop(); - } -} - -BENCHMARK_REGISTER_F(PoolingLayerLeNet5, neon_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5PoolingLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerLeNet5, neon_lenet5) -->Threads(1) -->Apply(DataSetArgBatched<LeNet5PoolingLayerDataset, 1, 1, 4, 8>); - -BENCHMARK_DEFINE_F(PoolingLayerGoogLeNet, neon_googlenet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run function - profiler.start(); - pool_layer.run(); - profiler.stop(); - } -} - -// FIXME: Add support for 7x7 pooling layer pool5/7x7_s1 -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 0, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 1, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 2, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 3, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 4, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 5, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 6, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 7, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 8, 1, 4, 8>); -BENCHMARK_REGISTER_F(PoolingLayerGoogLeNet, neon_googlenet) -->Threads(1) -->Apply(DataSetArgBatched<GoogLeNetPoolingLayerDataset, 9, 1, 4, 8>); diff --git a/tests/benchmark/PMUCounter.cpp b/tests/benchmark/PMUCounter.cpp deleted file mode 100644 index 6d59dae65d..0000000000 --- a/tests/benchmark/PMUCounter.cpp +++ /dev/null @@ -1,145 +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 "PMUCounter.h" - -#include "Utils.h" -#include "support/ToolchainSupport.h" - -#define _GNU_SOURCE 1 -#include <asm/unistd.h> -#include <csignal> -#include <cstdio> -#include <cstdlib> -#include <cstring> -#include <fcntl.h> -#include <linux/hw_breakpoint.h> -#include <linux/perf_event.h> -#include <stdexcept> -#include <sys/ioctl.h> -#include <unistd.h> - -namespace arm_compute -{ -namespace test -{ -namespace benchmark -{ -CycleCounter::CycleCounter() -{ - const pid_t pid = getpid(); - - struct perf_event_attr perf_config - { - }; - memset(&perf_config, 0, sizeof(struct perf_event_attr)); - - perf_config.config = PERF_COUNT_HW_CPU_CYCLES; - perf_config.size = sizeof(struct perf_event_attr); - perf_config.type = PERF_TYPE_HARDWARE; - // The inherit bit specifies that this counter should count events of child - // tasks as well as the task specified - perf_config.inherit = 1; - // Enables saving of event counts on context switch for inherited tasks - perf_config.inherit_stat = 1; - - _fd = syscall(__NR_perf_event_open, &perf_config, pid, -1, -1, 0); - - if(_fd < 0) - { - throw std::runtime_error("perf_event_open for cycles failed"); - } -} - -std::string CycleCounter::id() const -{ - return "Cycle Counter"; -} - -void CycleCounter::start() -{ - ioctl(_fd, PERF_EVENT_IOC_RESET, 0); - ioctl(_fd, PERF_EVENT_IOC_ENABLE, 0); -} - -void CycleCounter::stop() -{ - ioctl(_fd, PERF_EVENT_IOC_DISABLE, 0); - read(_fd, &_cycles, sizeof(_cycles)); -} - -std::unique_ptr<Instrument::IMeasurement> CycleCounter::get_measurement() const -{ - return support::cpp14::make_unique<Instrument::Measurement<long long>>(_cycles); -} - -InstructionCounter::InstructionCounter() -{ - const pid_t pid = getpid(); - - struct perf_event_attr perf_config - { - }; - memset(&perf_config, 0, sizeof(struct perf_event_attr)); - - perf_config.config = PERF_COUNT_HW_INSTRUCTIONS; - perf_config.size = sizeof(struct perf_event_attr); - perf_config.type = PERF_TYPE_HARDWARE; - // The inherit bit specifies that this counter should count events of child - // tasks as well as the task specified - perf_config.inherit = 1; - // Enables saving of event counts on context switch for inherited tasks - perf_config.inherit_stat = 1; - - _fd = syscall(__NR_perf_event_open, &perf_config, pid, -1, -1, 0); - - if(_fd < 0) - { - throw std::runtime_error("perf_event_open for instructions failed"); - } -} - -std::string InstructionCounter::id() const -{ - return "Instruction Counter"; -} - -void InstructionCounter::start() -{ - ioctl(_fd, PERF_EVENT_IOC_RESET, 0); - ioctl(_fd, PERF_EVENT_IOC_ENABLE, 0); -} - -void InstructionCounter::stop() -{ - ioctl(_fd, PERF_EVENT_IOC_DISABLE, 0); - read(_fd, &_instructions, sizeof(_instructions)); -} - -std::unique_ptr<Instrument::IMeasurement> InstructionCounter::get_measurement() const -{ - return std::unique_ptr<Instrument::IMeasurement>(new Instrument::Measurement<long long>(_instructions)); -} -} // namespace benchmark -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark/PMUCounter.h b/tests/benchmark/PMUCounter.h deleted file mode 100644 index c04b0e5760..0000000000 --- a/tests/benchmark/PMUCounter.h +++ /dev/null @@ -1,71 +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_BENCHMARK_PMU_COUNTER_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_PMU_COUNTER_H__ - -#include "Instrument.h" - -namespace arm_compute -{ -namespace test -{ -namespace benchmark -{ -/** Implementation of an instrument to count CPU cycles. */ -class CycleCounter : public Instrument -{ -public: - /** Initialise the cycle counter. */ - CycleCounter(); - - std::string id() const override; - void start() override; - void stop() override; - std::unique_ptr<Instrument::IMeasurement> get_measurement() const override; - -private: - long _fd{ -1 }; - long long _cycles{ 0 }; -}; - -/** Implementation of an instrument to count executed CPU instructions. */ -class InstructionCounter : public Instrument -{ -public: - /** Initialise the instruction counter. */ - InstructionCounter(); - - std::string id() const override; - void start() override; - void stop() override; - std::unique_ptr<Instrument::IMeasurement> get_measurement() const override; - -private: - long _fd{ -1 }; - long long _instructions{ 0 }; -}; -} // namespace benchmark -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BENCHMARK_PMU_COUNTER_H__ */ diff --git a/tests/benchmark/Profiler.cpp b/tests/benchmark/Profiler.cpp deleted file mode 100644 index f3ce94164f..0000000000 --- a/tests/benchmark/Profiler.cpp +++ /dev/null @@ -1,87 +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 "Profiler.h" - -#include <iostream> -#include <utility> - -namespace arm_compute -{ -namespace test -{ -namespace benchmark -{ -void Profiler::add(const std::shared_ptr<Instrument> &instrument) -{ - _instruments.push_back(instrument); -} - -void Profiler::start() -{ - for(auto &instrument : _instruments) - { - instrument->start(); - } -} - -void Profiler::stop() -{ - for(auto &instrument : _instruments) - { - instrument->stop(); - } - - for(const auto &instrument : _instruments) - { - _measurements[instrument->id()].push_back(*instrument->get_measurement()); - } -} - -void Profiler::submit(::benchmark::State &state) -{ - for(auto &instrument : _measurements) - { - double sum_values = std::accumulate(instrument.second.begin(), instrument.second.end(), 0.); - size_t num_values = instrument.second.size(); - - if(num_values > 2) - { - auto minmax_values = std::minmax_element(instrument.second.begin(), instrument.second.end()); - state.counters[instrument.first + "_min"] = *minmax_values.first; - state.counters[instrument.first + "_max"] = *minmax_values.second; - sum_values -= *minmax_values.first + *minmax_values.second; - num_values -= 2; - } - state.counters[instrument.first] = sum_values / num_values; - instrument.second.clear(); - } -} - -const Profiler::MeasurementsMap &Profiler::measurements() const -{ - return _measurements; -} -} // namespace benchmark -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark/Profiler.h b/tests/benchmark/Profiler.h deleted file mode 100644 index f2464949d0..0000000000 --- a/tests/benchmark/Profiler.h +++ /dev/null @@ -1,76 +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_BENCHMARK_PROFILER_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_PROFILER_H__ - -#include "Instrument.h" - -#include "benchmark/benchmark_api.h" - -#include <map> -#include <memory> -#include <string> -#include <vector> - -namespace arm_compute -{ -namespace test -{ -namespace benchmark -{ -class Profiler -{ -public: - /** Mapping from instrument ids to their measurements. */ - using MeasurementsMap = std::map<std::string, std::vector<double>>; - - /** Add @p instrument to the performance montior. - * - * All added instruments will be used when @ref start or @ref stop are - * called to make measurements. - * - * @param[in] instrument Instrument to be used to measure performance. - */ - void add(const std::shared_ptr<Instrument> &instrument); - - /** Start all added instruments to measure performance. */ - void start(); - - /** Stop all added instruments. */ - void stop(); - - /** Commit all measured values to the current active test. */ - void submit(::benchmark::State &state); - - /** Return measurements for all instruments. */ - const MeasurementsMap &measurements() const; - -private: - std::vector<std::shared_ptr<Instrument>> _instruments{}; - MeasurementsMap _measurements{}; -}; -} // namespace benchmark -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BENCHMARK_PROFILER_H__ */ diff --git a/tests/benchmark/common/FullyConnectedLayer.h b/tests/benchmark/common/FullyConnectedLayer.h deleted file mode 100644 index eeef1de28a..0000000000 --- a/tests/benchmark/common/FullyConnectedLayer.h +++ /dev/null @@ -1,108 +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_BENCHMARK_FULLYCONNECTED_LAYER_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_FULLYCONNECTED_LAYER_H__ - -#include "TensorLibrary.h" -#include "Utils.h" -#include "dataset/ConvolutionLayerDataset.h" - -#include <memory> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; - -namespace arm_compute -{ -namespace test -{ -namespace benchmark -{ -template <typename DataSet, typename TensorType, typename Accessor, typename Function, DataType dt = DataType::F32> -class FullyConnectedLayer : public ::benchmark::Fixture -{ -public: - void SetUp(::benchmark::State &state) override - { - profiler.add(std::make_shared<WallClockTimer>()); - - const FullyConnectedLayerDataObject fc_obj = *(DataSet().begin() + state.range(0)); - - // Set batched in source and destination shapes - const unsigned int batches = state.range(1); - const unsigned int fixed_point_position = 4; - TensorShape src_shape = fc_obj.src_shape; - TensorShape dst_shape = fc_obj.dst_shape; - src_shape.set(src_shape.num_dimensions(), batches); - dst_shape.set(dst_shape.num_dimensions(), batches); - - // Create tensors - src = create_tensor<TensorType>(src_shape, dt, 1, fixed_point_position); - weights = create_tensor<TensorType>(fc_obj.weights_shape, dt, 1, fixed_point_position); - bias = create_tensor<TensorType>(fc_obj.bias_shape, dt, 1, fixed_point_position); - dst = create_tensor<TensorType>(dst_shape, dt, 1, fixed_point_position); - - // Create and configure function - fc_layer = std::unique_ptr<Function>(new Function()); - fc_layer->configure(&src, &weights, &bias, &dst); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - bias.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(weights), 1); - library->fill_tensor_uniform(Accessor(bias), 2); - } - - void TearDown(::benchmark::State &state) override - { - fc_layer.reset(); - - src.allocator()->free(); - weights.allocator()->free(); - bias.allocator()->free(); - dst.allocator()->free(); - - profiler.submit(state); - } - - std::unique_ptr<Function> fc_layer{ nullptr }; - Profiler profiler{}; - -private: - TensorType src{}; - TensorType weights{}; - TensorType bias{}; - TensorType dst{}; -}; -} // namespace benchmark -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_BENCHMARK_FULLYCONNECTED_LAYER_H__ diff --git a/tests/benchmark/main.cpp b/tests/benchmark/main.cpp deleted file mode 100644 index 356490960c..0000000000 --- a/tests/benchmark/main.cpp +++ /dev/null @@ -1,98 +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 "Globals.h" -#include "PMUCounter.h" -#include "PerformanceProgramOptions.h" -#include "PerformanceUserConfiguration.h" -#include "TensorLibrary.h" -#include "Utils.h" -#include "WallClockTimer.h" - -#include "benchmark/benchmark_api.h" -#include "support/ToolchainSupport.h" - -#ifdef OPENCL -#include "arm_compute/runtime/CL/CLScheduler.h" -#endif /* OPENCL */ -#include "arm_compute/runtime/Scheduler.h" - -#include <iostream> -#include <memory> - -using namespace arm_compute::test; -using namespace arm_compute::test::performance; - -namespace arm_compute -{ -namespace test -{ -PerformanceUserConfiguration user_config; -std::unique_ptr<TensorLibrary> library; -} // namespace test -} // namespace arm_compute - -int main(int argc, char **argv) -{ - PerformanceProgramOptions options; - try - { - options.parse_commandline(argc, argv); - - if(options.wants_help()) - { - std::cout << "Usage: " << argv[0] << " [options] PATH\n"; - std::cout << options.get_help() << "\n"; - } - - user_config = PerformanceUserConfiguration(options); - } - catch(const boost::program_options::required_option &err) - { - std::cerr << "Error: " << err.what() << "\n"; - std::cout << "\nUsage: " << argv[0] << " [options] PATH\n"; - std::cout << options.get_help() << "\n"; - return 1; - } - - ::benchmark::Initialize(&argc, argv); - - if(user_config.seed.is_set()) - { - library = arm_compute::support::cpp14::make_unique<TensorLibrary>(user_config.path.get(), user_config.seed); - } - else - { - library = arm_compute::support::cpp14::make_unique<TensorLibrary>(user_config.path.get()); - } - -#ifdef OPENCL - arm_compute::CLScheduler::get().default_init(); -#endif /* OPENCL */ - - std::cout << "Using " << user_config.threads << " CPU " << (user_config.threads == 1 ? "thread" : "threads") << "\n"; - std::cout << "Seed: " << library->seed() << "\n"; - arm_compute::Scheduler::get().set_num_threads(user_config.threads); - - ::benchmark::RunSpecifiedBenchmarks(); -} diff --git a/tests/benchmark_new/CL/ActivationLayer.cpp b/tests/benchmark_new/CL/ActivationLayer.cpp new file mode 100644 index 0000000000..2ab23d292f --- /dev/null +++ b/tests/benchmark_new/CL/ActivationLayer.cpp @@ -0,0 +1,61 @@ +/* + * 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 "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/ActivationLayerDataset.h" +#include "tests/fixtures_new/ActivationLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using CLActivationLayerFixture = ActivationLayerFixture<CLTensor, CLActivationLayer, cl::CLAccessor>; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetActivationLayer, CLActivationLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetActivationLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ActivationLayer, CLActivationLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ActivationLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetActivationLayer, CLActivationLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetActivationLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark_new/CL/ConvolutionLayer.cpp b/tests/benchmark_new/CL/ConvolutionLayer.cpp new file mode 100644 index 0000000000..b0faf4ac0f --- /dev/null +++ b/tests/benchmark_new/CL/ConvolutionLayer.cpp @@ -0,0 +1,63 @@ +/* + * 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 "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/AlexNetConvolutionLayerDataset.h" +#include "tests/datasets_new/GoogLeNetConvolutionLayerDataset.h" +#include "tests/datasets_new/LeNet5ConvolutionLayerDataset.h" +#include "tests/fixtures_new/ConvolutionLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using CLConvolutionLayerFixture = ConvolutionLayerFixture<CLTensor, CLConvolutionLayer, cl::CLAccessor>; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetConvolutionLayer, CLConvolutionLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetConvolutionLayerDataset(), + framework::dataset::make("Data type", { DataType::F32 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ConvolutionLayer, CLConvolutionLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ConvolutionLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetConvolutionLayer, CLConvolutionLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetConvolutionLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark_new/CL/FullyConnectedLayer.cpp b/tests/benchmark_new/CL/FullyConnectedLayer.cpp new file mode 100644 index 0000000000..3c8d450498 --- /dev/null +++ b/tests/benchmark_new/CL/FullyConnectedLayer.cpp @@ -0,0 +1,63 @@ +/* + * 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, + * FITCLSS 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 CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/AlexNetFullyConnectedLayerDataset.h" +#include "tests/datasets_new/GoogLeNetFullyConnectedLayerDataset.h" +#include "tests/datasets_new/LeNet5FullyConnectedLayerDataset.h" +#include "tests/fixtures_new/FullyConnectedLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using CLFullyConnectedLayerFixture = FullyConnectedLayerFixture<CLTensor, CLFullyConnectedLayer, cl::CLAccessor>; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetFullyConnectedLayer, CLFullyConnectedLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetFullyConnectedLayerDataset(), + framework::dataset::make("Data type", { DataType::F32 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5FullyConnectedLayer, CLFullyConnectedLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5FullyConnectedLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetFullyConnectedLayer, CLFullyConnectedLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetFullyConnectedLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/PerformanceProgramOptions.cpp b/tests/benchmark_new/CL/GEMM.cpp index b4becc3c69..d75db500a0 100644 --- a/tests/benchmark/PerformanceProgramOptions.cpp +++ b/tests/benchmark_new/CL/GEMM.cpp @@ -21,28 +21,37 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "PerformanceProgramOptions.h" - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" -#include "boost/program_options.hpp" -#pragma GCC diagnostic pop +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLGEMM.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/GoogLeNetGEMMDataset.h" +#include "tests/fixtures_new/GEMMFixture.h" namespace arm_compute { namespace test { -namespace performance +namespace { -PerformanceProgramOptions::PerformanceProgramOptions() +auto data_types = framework::dataset::make("Data type", { - boost::program_options::options_description options("Performance options"); - options.add_options()("runs", boost::program_options::value<unsigned int>()->default_value(1), "Repetitions per test"); - options.add_options()("threads", boost::program_options::value<unsigned int>()->default_value(1), "Number of parallel CPU threads"); - add_options(options); -} -} // namespace performance +#if ARM_COMPUTE_ENABLE_FP16 + DataType::FP16, +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + DataType::F32 +}); +} // namespace + +using CLGEMMFixture = GEMMFixture<CLTensor, CLGEMM>; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetGEMM, CLGEMMFixture, framework::dataset::combine(datasets::GoogLeNetGEMMDataset(), std::move(data_types))); + +TEST_SUITE_END() } // namespace test } // namespace arm_compute diff --git a/tests/benchmark_new/CL/NormalizationLayer.cpp b/tests/benchmark_new/CL/NormalizationLayer.cpp new file mode 100644 index 0000000000..95e78c4a18 --- /dev/null +++ b/tests/benchmark_new/CL/NormalizationLayer.cpp @@ -0,0 +1,56 @@ +/* + * 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, + * FITCLSS 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 CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/NormalizationLayerDataset.h" +#include "tests/fixtures_new/NormalizationLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using CLNormalizationLayerFixture = NormalizationLayerFixture<CLTensor, CLNormalizationLayer, cl::CLAccessor>; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetNormalizationLayer, CLNormalizationLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetNormalizationLayerDataset(), + framework::dataset::make("Data type", { DataType::F32 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetNormalizationLayer, CLNormalizationLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetNormalizationLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark_new/CL/PoolingLayer.cpp b/tests/benchmark_new/CL/PoolingLayer.cpp new file mode 100644 index 0000000000..1f2229cb10 --- /dev/null +++ b/tests/benchmark_new/CL/PoolingLayer.cpp @@ -0,0 +1,63 @@ +/* + * 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 "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/AlexNetPoolingLayerDataset.h" +#include "tests/datasets_new/GoogLeNetPoolingLayerDataset.h" +#include "tests/datasets_new/LeNet5PoolingLayerDataset.h" +#include "tests/fixtures_new/PoolingLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using CLPoolingLayerFixture = PoolingLayerFixture<CLTensor, CLPoolingLayer, cl::CLAccessor>; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetPoolingLayer, CLPoolingLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetPoolingLayerDataset(), + framework::dataset::make("Data type", { DataType::F32 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5PoolingLayer, CLPoolingLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5PoolingLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetPoolingLayer, CLPoolingLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetPoolingLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/system_tests/CL/AlexNet.cpp b/tests/benchmark_new/CL/SYSTEM/AlexNet.cpp index 04b65b8c39..a0673b94df 100644 --- a/tests/benchmark/system_tests/CL/AlexNet.cpp +++ b/tests/benchmark_new/CL/SYSTEM/AlexNet.cpp @@ -21,16 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" #include "arm_compute/runtime/CL/CLSubTensor.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/CL/CLTensorAllocator.h" @@ -40,47 +32,36 @@ #include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" #include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" #include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/ActivationLayerDataset.h" +#include "tests/fixtures_new/AlexNetFixture.h" -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::cl; - -#include "benchmark/system_tests/common/AlexNet.h" - -namespace +namespace arm_compute { -using AlexNetSystemTest = AlexNetFixture<ICLTensor, +namespace test +{ +using CLAlexNetFixture = AlexNetFixture<ICLTensor, CLTensor, CLSubTensor, - CLAccessor, + cl::CLAccessor, CLActivationLayer, CLConvolutionLayer, CLFullyConnectedLayer, CLNormalizationLayer, CLPoolingLayer, CLSoftmaxLayer>; -} // namespace -BENCHMARK_DEFINE_F(AlexNetSystemTest, cl_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run AlexNet - profiler.start(); - network.run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} +TEST_SUITE(SYSTEM_TEST) +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNet, CLAlexNetFixture, + framework::dataset::combine(framework::dataset::make("Data type", DataType::F32), + framework::dataset::make("Batches", { 1, 4, 8 }))); -BENCHMARK_REGISTER_F(AlexNetSystemTest, cl_alexnet) -->Threads(1) -->Iterations(10) -->ArgName("batch_size") -->Arg(1) -->Arg(4) -->Arg(8);
\ No newline at end of file +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/system_tests/CL/LeNet5.cpp b/tests/benchmark_new/CL/SYSTEM/LeNet5.cpp index 60bb37a35b..0ee7c0177a 100644 --- a/tests/benchmark/system_tests/CL/LeNet5.cpp +++ b/tests/benchmark_new/CL/SYSTEM/LeNet5.cpp @@ -21,16 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/CL/CLTensorAllocator.h" #include "arm_compute/runtime/CL/functions/CLActivationLayer.h" @@ -38,44 +30,31 @@ #include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" #include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" #include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/fixtures_new/LeNet5Fixture.h" -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::cl; - -#include "benchmark/system_tests/common/LeNet5.h" - -namespace +namespace arm_compute { -using LeNet5SystemTest = LeNet5Fixture<CLTensor, - CLAccessor, +namespace test +{ +using CLLeNet5Fixture = LeNet5Fixture<CLTensor, + cl::CLAccessor, CLActivationLayer, CLConvolutionLayer, CLFullyConnectedLayer, CLPoolingLayer, CLSoftmaxLayer>; -} // namespace -BENCHMARK_DEFINE_F(LeNet5SystemTest, cl_lenet5) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run LeNet5 - profiler.start(); - network.run(); - CLScheduler::get().sync(); - profiler.stop(); - } -} +TEST_SUITE(SYSTEM_TEST) +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5, CLLeNet5Fixture, + framework::dataset::make("Batches", { 1, 4, 8 })); -BENCHMARK_REGISTER_F(LeNet5SystemTest, cl_lenet5) -->Threads(1) -->Iterations(10) -->ArgName("batch_size") -->Arg(1) -->Arg(16) -->Arg(32); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark_new/DEMO/Demo.cpp b/tests/benchmark_new/DEMO/Demo.cpp new file mode 100644 index 0000000000..27254bbded --- /dev/null +++ b/tests/benchmark_new/DEMO/Demo.cpp @@ -0,0 +1,162 @@ +/* + * 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 "framework/Macros.h" +#include "tests/DatasetManager.h" + +#include <vector> + +namespace arm_compute +{ +namespace test +{ +TEST_SUITE(DEMO) + +#if 0 +TEST_CASE(NoArgs) +{ + ARM_COMPUTE_EXPECT_EQUAL(6, 5); +} + +DATA_TEST_CASE(And, framework::dataset::make("Foo", { 5, 7, 9 }), int num) +{ + ARM_COMPUTE_EXPECT_EQUAL(6, num); +} + +DATA_TEST_CASE(And2, framework::dataset::zip(framework::dataset::make("Foo", 2), framework::dataset::make("Bar", 3.f)), int num, float count) +{ +} + +DATA_TEST_CASE(And3, framework::DatasetManager::get().shapesDataset(), arm_compute::TensorShape num) +{ +} + +DATA_TEST_CASE(And4, framework::dataset::zip(framework::dataset::make("Zip", std::vector<int> { 2, 3, 4 }), framework::dataset::make("Bar", std::vector<int> { -2, -3, -4 })), int num, float count) +{ + ARM_COMPUTE_ASSERT_EQUAL(num, count); +} + +DATA_TEST_CASE(And5, framework::dataset::make("Foo", { 2, 3, 4 }), int num) +{ +} + +DATA_TEST_CASE(And6, framework::dataset::combine(framework::dataset::make("Foo", std::vector<int> { 2, 3, 4 }), framework::dataset::make("Bar", std::vector<int> { -2, -3, -4 })), int num, int count) +{ + ARM_COMPUTE_EXPECT_EQUAL(num, count); +} + +DATA_TEST_CASE(And7, framework::dataset::combine(framework::dataset::combine(framework::dataset::make("Foo", std::vector<int> { 2, 3, 4 }), framework::dataset::make("Bar", std::vector<int> { -2, -3, -4 })), + framework::dataset::make("FooBar", std::vector<int> { 5, 6 })), + int num, + int count, int asd) +{ +} + +DATA_TEST_CASE(And8, framework::dataset::concat(framework::dataset::make("Foo", std::vector<int> { 2, 3, 4 }), framework::dataset::make("Bar", std::vector<int> { -2, -3, -4 })), int num) +{ +} + +class MyFixture : public framework::Fixture +{ +public: + MyFixture() + { + std::cout << "Created fixture!!!\n"; + } + + MyFixture(const MyFixture &) = default; + MyFixture(MyFixture &&) = default; + MyFixture &operator=(const MyFixture &) = default; + MyFixture &operator=(MyFixture &&) = default; + + void setup() + { + std::cout << "Set up fixture!!!\n"; + } + + void run() + { + std::cout << "Run fixture\n"; + } + + void teardown() + { + std::cout << "Tear down fixture!!!\n"; + } + + ~MyFixture() + { + std::cout << "Destroyed fixture!!!\n"; + } +}; + +class MyDataFixture : public framework::Fixture +{ +public: + MyDataFixture() + { + std::cout << "Created data fixture!!!\n"; + } + + MyDataFixture(const MyDataFixture &) = default; + MyDataFixture(MyDataFixture &&) = default; + MyDataFixture &operator=(const MyDataFixture &) = default; + MyDataFixture &operator=(MyDataFixture &&) = default; + + void setup(int num) + { + _num = num; + std::cout << "Set up fixture with num = " << _num << "\n"; + } + + void run() + { + std::cout << "Run fixture\n"; + } + + ~MyDataFixture() + { + std::cout << "Destroyed data fixture!!!\n"; + } + +protected: + int _num{}; +}; + +FIXTURE_TEST_CASE(And11, MyFixture) +{ + std::cout << "Running fixture test!!!\n"; +} + +FIXTURE_DATA_TEST_CASE(And12, MyDataFixture, framework::dataset::make("Foo", { 2, 3, 4 })) +{ + std::cout << "Running fixture test with value " << _num << "!!!\n"; +} + +REGISTER_FIXTURE_TEST_CASE(And13, MyFixture); +REGISTER_FIXTURE_DATA_TEST_CASE(And14, MyDataFixture, framework::dataset::make("Foo", { 2, 3, 4 })); +#endif /* 0 */ + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/ActivationLayer.cpp b/tests/benchmark_new/NEON/ActivationLayer.cpp new file mode 100644 index 0000000000..75e98c4ccb --- /dev/null +++ b/tests/benchmark_new/NEON/ActivationLayer.cpp @@ -0,0 +1,61 @@ +/* + * 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 "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/NEON/NEAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/ActivationLayerDataset.h" +#include "tests/fixtures_new/ActivationLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using NEActivationLayerFixture = ActivationLayerFixture<Tensor, NEActivationLayer, neon::NEAccessor>; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetActivationLayer, NEActivationLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetActivationLayerDataset(), + framework::dataset::make("Data type", { DataType::F32, DataType::QS8 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ActivationLayer, NEActivationLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ActivationLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetActivationLayer, NEActivationLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetActivationLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/ConvolutionLayer.cpp b/tests/benchmark_new/NEON/ConvolutionLayer.cpp new file mode 100644 index 0000000000..57d046e9a5 --- /dev/null +++ b/tests/benchmark_new/NEON/ConvolutionLayer.cpp @@ -0,0 +1,63 @@ +/* + * 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 "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/NEON/NEAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/AlexNetConvolutionLayerDataset.h" +#include "tests/datasets_new/GoogLeNetConvolutionLayerDataset.h" +#include "tests/datasets_new/LeNet5ConvolutionLayerDataset.h" +#include "tests/fixtures_new/ConvolutionLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using NEConvolutionLayerFixture = ConvolutionLayerFixture<Tensor, NEConvolutionLayer, neon::NEAccessor>; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetConvolutionLayer, NEConvolutionLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetConvolutionLayerDataset(), + framework::dataset::make("Data type", { DataType::F32, DataType::QS8 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ConvolutionLayer, NEConvolutionLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ConvolutionLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetConvolutionLayer, NEConvolutionLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetConvolutionLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/DirectConvolutionLayer.cpp b/tests/benchmark_new/NEON/DirectConvolutionLayer.cpp new file mode 100644 index 0000000000..a63cbae8e5 --- /dev/null +++ b/tests/benchmark_new/NEON/DirectConvolutionLayer.cpp @@ -0,0 +1,51 @@ +/* + * 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 "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/NEON/NEAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/DirectConvolutionLayerDataset.h" +#include "tests/fixtures_new/ConvolutionLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using NEDirectConvolutionLayerFixture = ConvolutionLayerFixture<Tensor, NEDirectConvolutionLayer, neon::NEAccessor>; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(DirectConvolutionLayer, NEDirectConvolutionLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::DirectConvolutionLayerDataset(), + framework::dataset::make("Data type", { DataType::F32, DataType::QS8 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/FullyConnectedLayer.cpp b/tests/benchmark_new/NEON/FullyConnectedLayer.cpp new file mode 100644 index 0000000000..75815ad363 --- /dev/null +++ b/tests/benchmark_new/NEON/FullyConnectedLayer.cpp @@ -0,0 +1,63 @@ +/* + * 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 "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/NEON/NEAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/AlexNetFullyConnectedLayerDataset.h" +#include "tests/datasets_new/GoogLeNetFullyConnectedLayerDataset.h" +#include "tests/datasets_new/LeNet5FullyConnectedLayerDataset.h" +#include "tests/fixtures_new/FullyConnectedLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using NEFullyConnectedLayerFixture = FullyConnectedLayerFixture<Tensor, NEFullyConnectedLayer, neon::NEAccessor>; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetFullyConnectedLayer, NEFullyConnectedLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetFullyConnectedLayerDataset(), + framework::dataset::make("Data type", { DataType::F32, DataType::QS8 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5FullyConnectedLayer, NEFullyConnectedLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5FullyConnectedLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetFullyConnectedLayer, NEFullyConnectedLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetFullyConnectedLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/PerformanceUserConfiguration.h b/tests/benchmark_new/NEON/GEMM.cpp index daf85a4332..2ba9a71664 100644 --- a/tests/benchmark/PerformanceUserConfiguration.h +++ b/tests/benchmark_new/NEON/GEMM.cpp @@ -21,37 +21,39 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_TEST_PERFORMANCE_PERFORMANCE_USER_CONFIGURATION_H__ -#define __ARM_COMPUTE_TEST_PERFORMANCE_PERFORMANCE_USER_CONFIGURATION_H__ - -#include "UserConfiguration.h" +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEGEMM.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/GoogLeNetGEMMDataset.h" +#include "tests/fixtures_new/GEMMFixture.h" namespace arm_compute { namespace test { -class ProgramOptions; - -namespace performance +namespace { -/** Specialisation of @ref UserConfiguration to provide performance specific - * configuration options. - */ -struct PerformanceUserConfiguration : public UserConfiguration +auto data_types = framework::dataset::make("Data type", { - PerformanceUserConfiguration() = default; +#if ARM_COMPUTE_ENABLE_FP16 + DataType::F16, +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + DataType::F32, + DataType::QS8 +}); +} // namespace + +using NEGEMMFixture = GEMMFixture<Tensor, NEGEMM>; - /** Initialise the configuration according to the program options. - * - * @param[in] options Parsed command line options. - */ - PerformanceUserConfiguration(const ProgramOptions &options); +TEST_SUITE(NEON) - Option<unsigned int> runs{}; -}; -} // namespace performance +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetGEMM, NEGEMMFixture, framework::dataset::combine(datasets::GoogLeNetGEMMDataset(), std::move(data_types))); -extern performance::PerformanceUserConfiguration user_config; +TEST_SUITE_END() } // namespace test } // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_PERFORMANCE_PERFORMANCE_USER_CONFIGURATION_H__ */ diff --git a/tests/benchmark_new/NEON/NormalizationLayer.cpp b/tests/benchmark_new/NEON/NormalizationLayer.cpp new file mode 100644 index 0000000000..d9f1323620 --- /dev/null +++ b/tests/benchmark_new/NEON/NormalizationLayer.cpp @@ -0,0 +1,56 @@ +/* + * 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 "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/NEON/NEAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/NormalizationLayerDataset.h" +#include "tests/fixtures_new/NormalizationLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using NENormalizationLayerFixture = NormalizationLayerFixture<Tensor, NENormalizationLayer, neon::NEAccessor>; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetNormalizationLayer, NENormalizationLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetNormalizationLayerDataset(), + framework::dataset::make("Data type", { DataType::F32, DataType::QS8 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetNormalizationLayer, NENormalizationLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetNormalizationLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/PoolingLayer.cpp b/tests/benchmark_new/NEON/PoolingLayer.cpp new file mode 100644 index 0000000000..fdaadd0493 --- /dev/null +++ b/tests/benchmark_new/NEON/PoolingLayer.cpp @@ -0,0 +1,63 @@ +/* + * 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 "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/NEON/NEAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/AlexNetPoolingLayerDataset.h" +#include "tests/datasets_new/GoogLeNetPoolingLayerDataset.h" +#include "tests/datasets_new/LeNet5PoolingLayerDataset.h" +#include "tests/fixtures_new/PoolingLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +using NEPoolingLayerFixture = PoolingLayerFixture<Tensor, NEPoolingLayer, neon::NEAccessor>; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetPoolingLayer, NEPoolingLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetPoolingLayerDataset(), + framework::dataset::make("Data type", { DataType::F32, DataType::QS8 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5PoolingLayer, NEPoolingLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5PoolingLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetPoolingLayer, NEPoolingLayerFixture, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetPoolingLayerDataset(), + framework::dataset::make("Data type", DataType::F32)), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/system_tests/NEON/AlexNet.cpp b/tests/benchmark_new/NEON/SYSTEM/AlexNet.cpp index 530c400ae3..2a50bc9d85 100644 --- a/tests/benchmark/system_tests/NEON/AlexNet.cpp +++ b/tests/benchmark_new/NEON/SYSTEM/AlexNet.cpp @@ -21,14 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "Globals.h" -#include "NEON/NEAccessor.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" #include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" #include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" @@ -39,81 +32,36 @@ #include "arm_compute/runtime/SubTensor.h" #include "arm_compute/runtime/Tensor.h" #include "arm_compute/runtime/TensorAllocator.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/NEON/NEAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/datasets_new/ActivationLayerDataset.h" +#include "tests/fixtures_new/AlexNetFixture.h" -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::neon; - -#include "benchmark/system_tests/common/AlexNet.h" - -namespace +namespace arm_compute { -using AlexNetSystemTestF32 = AlexNetFixture<ITensor, - Tensor, - SubTensor, - NEAccessor, - NEActivationLayer, - NEConvolutionLayer, - NEFullyConnectedLayer, - NENormalizationLayer, - NEPoolingLayer, - NESoftmaxLayer, - DataType::F32>; - -using AlexNetSystemTestQS8 = AlexNetFixture<ITensor, +namespace test +{ +using NEAlexNetFixture = AlexNetFixture<ITensor, Tensor, SubTensor, - NEAccessor, + neon::NEAccessor, NEActivationLayer, NEConvolutionLayer, NEFullyConnectedLayer, NENormalizationLayer, NEPoolingLayer, - NESoftmaxLayer, - DataType::QS8>; -} // namespace - -// F32 -BENCHMARK_DEFINE_F(AlexNetSystemTestF32, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run AlexNet - profiler.start(); - network.run(); - profiler.stop(); - } -} + NESoftmaxLayer>; -BENCHMARK_REGISTER_F(AlexNetSystemTestF32, neon_alexnet) -->Threads(1) -->Iterations(10) -->ArgName("batch_size") -->Arg(1) -->Arg(4) -->Arg(8); +TEST_SUITE(SYSTEM_TEST) +TEST_SUITE(NEON) -// QS8 -BENCHMARK_DEFINE_F(AlexNetSystemTestQS8, neon_alexnet) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run AlexNet - profiler.start(); - network.run(); - profiler.stop(); - } -} +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNet, NEAlexNetFixture, + framework::dataset::combine(framework::dataset::make("Data type", { DataType::F32, DataType::QS8 }), + framework::dataset::make("Batches", { 1, 4, 8 }))); -BENCHMARK_REGISTER_F(AlexNetSystemTestQS8, neon_alexnet) -->Threads(1) -->Iterations(10) -->ArgName("batch_size") -->Arg(1) -->Arg(4) -->Arg(8);
\ No newline at end of file +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/system_tests/NEON/LeNet5.cpp b/tests/benchmark_new/NEON/SYSTEM/LeNet5.cpp index 8724d8ba3a..3957ce76b9 100644 --- a/tests/benchmark/system_tests/NEON/LeNet5.cpp +++ b/tests/benchmark_new/NEON/SYSTEM/LeNet5.cpp @@ -21,14 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "Globals.h" -#include "NEON/NEAccessor.h" -#include "TensorLibrary.h" -#include "benchmark/Datasets.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" #include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" #include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" @@ -37,43 +30,31 @@ #include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" #include "arm_compute/runtime/Tensor.h" #include "arm_compute/runtime/TensorAllocator.h" +#include "framework/Macros.h" +#include "framework/datasets/Datasets.h" +#include "tests/NEON/NEAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/fixtures_new/LeNet5Fixture.h" -#include "benchmark/benchmark_api.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; -using namespace arm_compute::test::neon; - -#include "benchmark/system_tests/common/LeNet5.h" - -namespace +namespace arm_compute { -using LeNet5SystemTest = LeNet5Fixture<Tensor, - NEAccessor, +namespace test +{ +using NELeNet5Fixture = LeNet5Fixture<Tensor, + neon::NEAccessor, NEActivationLayer, NEConvolutionLayer, NEFullyConnectedLayer, NEPoolingLayer, NESoftmaxLayer>; -} // namespace -BENCHMARK_DEFINE_F(LeNet5SystemTest, neon_lenet5) -(::benchmark::State &state) -{ - while(state.KeepRunning()) - { - // Run LeNet5 - profiler.start(); - network.run(); - profiler.stop(); - } -} +TEST_SUITE(SYSTEM_TEST) +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5, NELeNet5Fixture, + framework::dataset::make("Batches", { 1, 4, 8 })); -BENCHMARK_REGISTER_F(LeNet5SystemTest, neon_lenet5) -->Threads(1) -->Iterations(10) -->ArgName("batch_size") -->Arg(1) -->Arg(16) -->Arg(32); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark_new/main.cpp b/tests/benchmark_new/main.cpp new file mode 100644 index 0000000000..2db5fc8cef --- /dev/null +++ b/tests/benchmark_new/main.cpp @@ -0,0 +1,213 @@ +/* + * 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 "framework/Macros.h" +#include "framework/command_line/CommandLineOptions.h" +#include "framework/command_line/CommandLineParser.h" +#include "framework/instruments/Instruments.h" +#include "framework/printers/Printers.h" +#include "support/ToolchainSupport.h" +#include "tests/DatasetManager.h" +#include "tests/TensorLibrary.h" + +#ifdef OPENCL +#include "arm_compute/runtime/CL/CLScheduler.h" +#endif /* OPENCL */ +#include "arm_compute/runtime/Scheduler.h" + +#include <fstream> +#include <initializer_list> +#include <iostream> +#include <memory> +#include <random> +#include <utility> + +using namespace arm_compute; +using namespace arm_compute::test; + +namespace arm_compute +{ +namespace test +{ +std::unique_ptr<TensorLibrary> library; +} // namespace test +} // namespace arm_compute + +int main(int argc, char **argv) +{ +#ifdef OPENCL + CLScheduler::get().default_init(); +#endif /* OPENCL */ + + framework::Framework &framework = framework::Framework::get(); + + framework::CommandLineParser parser; + + std::set<framework::InstrumentType> allowed_instruments + { + framework::InstrumentType::ALL, + framework::InstrumentType::NONE, + }; + + for(const auto &type : framework.available_instruments()) + { + allowed_instruments.insert(type); + } + + std::set<DatasetManager::DatasetMode> allowed_modes + { + DatasetManager::DatasetMode::PRECOMMIT, + DatasetManager::DatasetMode::NIGHTLY, + DatasetManager::DatasetMode::ALL + }; + + std::set<framework::LogFormat> supported_log_formats + { + framework::LogFormat::NONE, + framework::LogFormat::PRETTY, + framework::LogFormat::JSON, + }; + + auto help = parser.add_option<framework::ToggleOption>("help"); + help->set_help("Show this help message"); + auto dataset_mode = parser.add_option<framework::EnumOption<DatasetManager::DatasetMode>>("mode", allowed_modes, DatasetManager::DatasetMode::ALL); + dataset_mode->set_help("For managed datasets select which group to use"); + auto instruments = parser.add_option<framework::EnumListOption<framework::InstrumentType>>("instruments", allowed_instruments, std::initializer_list<framework::InstrumentType> { framework::InstrumentType::ALL }); + instruments->set_help("Set the profiling instruments to use"); + auto iterations = parser.add_option<framework::SimpleOption<int>>("iterations", 1); + iterations->set_help("Number of iterations per test case"); + auto threads = parser.add_option<framework::SimpleOption<int>>("threads", 1); + threads->set_help("Number of threads to use"); + auto log_format = parser.add_option<framework::EnumOption<framework::LogFormat>>("log-format", supported_log_formats, framework::LogFormat::PRETTY); + log_format->set_help("Output format for measurements and failures"); + auto filter = parser.add_option<framework::SimpleOption<std::string>>("filter", ".*"); + filter->set_help("Regular expression to select test cases"); + auto filter_id = parser.add_option<framework::SimpleOption<std::string>>("filter-id", ".*"); + filter_id->set_help("Regular expression to select test cases by id"); + auto log_file = parser.add_option<framework::SimpleOption<std::string>>("log-file"); + log_file->set_help("Write output to file instead of to the console"); + auto throw_errors = parser.add_option<framework::ToggleOption>("throw-errors"); + throw_errors->set_help("Don't catch errors (useful for debugging)"); + auto seed = parser.add_option<framework::SimpleOption<std::random_device::result_type>>("seed", std::random_device()()); + seed->set_help("Global seed for random number generation"); + auto color_output = parser.add_option<framework::ToggleOption>("color-output", true); + color_output->set_help("Produce colored output on the console"); + auto list_tests = parser.add_option<framework::ToggleOption>("list-tests", false); + list_tests->set_help("List all test names"); + auto assets = parser.add_positional_option<framework::SimpleOption<std::string>>("assets"); + assets->set_help("Path to the assets directory"); + assets->set_required(true); + + try + { + parser.parse(argc, argv); + + if(help->is_set() && help->value()) + { + parser.print_help(argv[0]); + return 0; + } + + if(!parser.validate()) + { + return 1; + } + + std::unique_ptr<framework::Printer> printer; + std::ofstream log_stream; + + switch(log_format->value()) + { + case framework::LogFormat::JSON: + printer = support::cpp14::make_unique<framework::JSONPrinter>(); + break; + case framework::LogFormat::NONE: + break; + case framework::LogFormat::PRETTY: + default: + { + auto pretty_printer = support::cpp14::make_unique<framework::PrettyPrinter>(); + pretty_printer->set_color_output(color_output->value()); + printer = std::move(pretty_printer); + break; + } + } + + if(printer != nullptr) + { + if(log_file->is_set()) + { + log_stream.open(log_file->value()); + printer->set_stream(log_stream); + } + } + + DatasetManager::get().set_mode(dataset_mode->value()); + library = support::cpp14::make_unique<TensorLibrary>(assets->value(), seed->value()); + Scheduler::get().set_num_threads(threads->value()); + + printer->print_global_header(); + printer->print_entry("Seed", support::cpp11::to_string(seed->value())); + printer->print_entry("Iterations", support::cpp11::to_string(iterations->value())); + printer->print_entry("Threads", support::cpp11::to_string(threads->value())); + { + using support::cpp11::to_string; + printer->print_entry("Dataset mode", to_string(dataset_mode->value())); + } + + framework.init(instruments->value(), iterations->value(), filter->value(), filter_id->value()); + framework.set_printer(printer.get()); + framework.set_throw_errors(throw_errors->value()); + + bool success = true; + + if(list_tests->value()) + { + for(const auto &id : framework.test_ids()) + { + std::cout << "[" << id.first << "] " << id.second << "\n"; + } + } + else + { + success = framework.run(); + } + + printer->print_global_footer(); + + return (success ? 0 : 1); + } + catch(const std::exception &error) + { + std::cerr << error.what() << "\n"; + + if(throw_errors->value()) + { + throw; + } + + return 1; + } + + return 0; +} diff --git a/tests/datasets_new/ActivationLayerDataset.h b/tests/datasets_new/ActivationLayerDataset.h new file mode 100644 index 0000000000..02f58034d2 --- /dev/null +++ b/tests/datasets_new/ActivationLayerDataset.h @@ -0,0 +1,158 @@ +/* + * 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_ACTIVATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_ACTIVATION_LAYER_DATASET + +#include "framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class AlexNetActivationLayerDataset final : public + framework::dataset::CartesianProductDataset<framework::dataset::InitializerListDataset<TensorShape>, framework::dataset::SingletonDataset<ActivationLayerInfo>> +{ +public: + AlexNetActivationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { + TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 256U), + TensorShape(13U, 13U, 384U), TensorShape(13U, 13U, 256U), + TensorShape(4096U) }), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) + } + { + } + AlexNetActivationLayerDataset(AlexNetActivationLayerDataset &&) = default; + ~AlexNetActivationLayerDataset() = default; +}; + +class LeNet5ActivationLayerDataset final : public + framework::dataset::CartesianProductDataset<framework::dataset::SingletonDataset<TensorShape>, framework::dataset::SingletonDataset<ActivationLayerInfo>> +{ +public: + LeNet5ActivationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", TensorShape(500U)), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) + } + { + } + LeNet5ActivationLayerDataset(LeNet5ActivationLayerDataset &&) = default; + ~LeNet5ActivationLayerDataset() = default; +}; + +class GoogLeNetActivationLayerDataset final : public + framework::dataset::CartesianProductDataset<framework::dataset::InitializerListDataset<TensorShape>, framework::dataset::SingletonDataset<ActivationLayerInfo>> +{ +public: + GoogLeNetActivationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { // conv1/relu_7x7 + TensorShape(112U, 112U, 64U), + // conv2/relu_3x3_reduce + TensorShape(56U, 56U, 64U), + // conv2/relu_3x3 + TensorShape(56U, 56U, 192U), + // inception_3a/relu_1x1, inception_3b/relu_pool_proj + TensorShape(28U, 28U, 64U), + // inception_3a/relu_3x3_reduce, inception_3b/relu_5x5 + TensorShape(28U, 28U, 96U), + // inception_3a/relu_3x3, inception_3b/relu_1x1, inception_3b/relu_3x3_reduce + TensorShape(28U, 28U, 128U), + // inception_3a/relu_5x5_reduce + TensorShape(28U, 28U, 16U), + // inception_3a/relu_5x5, inception_3a/relu_pool_proj, inception_3b/relu_5x5_reduce + TensorShape(28U, 28U, 32U), + // inception_3b/relu_3x3 + TensorShape(28U, 28U, 192U), + // inception_4a/relu_1x1 + TensorShape(14U, 14U, 192U), + // inception_4a/relu_3x3_reduce + TensorShape(14U, 14U, 96U), + // inception_4a/relu_3x3 + TensorShape(14U, 14U, 208U), + // inception_4a/relu_5x5_reduce + TensorShape(14U, 14U, 16U), + // inception_4a/relu_5x5 + TensorShape(14U, 14U, 48U), + // inception_4a/relu_pool_proj, inception_4b/relu_5x5, inception_4b/relu_pool_proj, inception_4c/relu_5x5, inception_4c/relu_pool_proj, inception_4d/relu_5x5, inception_4d/relu_pool_proj + TensorShape(14U, 14U, 64U), + // inception_4b/relu_1x1, inception_4e/relu_3x3_reduce + TensorShape(14U, 14U, 160U), + // inception_4b/relu_3x3_reduce, inception_4d/relu_1x1 + TensorShape(14U, 14U, 112U), + // inception_4b/relu_3x3 + TensorShape(14U, 14U, 224U), + // inception_4b/relu_5x5_reduce, inception_4c/relu_5x5_reduce + TensorShape(14U, 14U, 24U), + // inception_4c/relu_1x1, inception_4c/relu_3x3_reduce, inception_4e/relu_5x5, inception_4e/relu_pool_proj + TensorShape(14U, 14U, 128U), + // inception_4c/relu_3x3, inception_4e/relu_1x1 + TensorShape(14U, 14U, 256U), + // inception_4d/relu_3x3_reduce + TensorShape(14U, 14U, 144U), + // inception_4d/relu_3x3 + TensorShape(14U, 14U, 288U), + // inception_4d/relu_5x5_reduce, inception_4e/relu_5x5_reduce + TensorShape(14U, 14U, 32U), + // inception_4e/relu_3x3 + TensorShape(14U, 14U, 320U), + // inception_5a/relu_1x1 + TensorShape(7U, 7U, 256U), + // inception_5a/relu_3x3_reduce + TensorShape(7U, 7U, 160U), + // inception_5a/relu_3x3 + TensorShape(7U, 7U, 320U), + // inception_5a/relu_5x5_reduce + TensorShape(7U, 7U, 32U), + // inception_5a/relu_5x5, inception_5a/relu_pool_proj, inception_5b/relu_5x5, inception_5b/relu_pool_proj + TensorShape(7U, 7U, 128U), + // inception_5b/relu_1x1, inception_5b/relu_3x3 + TensorShape(7U, 7U, 384U), + // inception_5b/relu_3x3_reduce + TensorShape(7U, 7U, 192U), + // inception_5b/relu_5x5_reduce + TensorShape(7U, 7U, 48U) }), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) + } + { + } + GoogLeNetActivationLayerDataset(GoogLeNetActivationLayerDataset &&) = default; + ~GoogLeNetActivationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets_new/AlexNetConvolutionLayerDataset.h b/tests/datasets_new/AlexNetConvolutionLayerDataset.h new file mode 100644 index 0000000000..0341555638 --- /dev/null +++ b/tests/datasets_new/AlexNetConvolutionLayerDataset.h @@ -0,0 +1,55 @@ +/* + * 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_ALEXNET_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_ALEXNET_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets_new/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class AlexNetConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + AlexNetConvolutionLayerDataset() + { + add_config(TensorShape(227U, 227U, 3U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U), PadStrideInfo(4, 4, 0, 0)); + add_config(TensorShape(27U, 27U, 96U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U), PadStrideInfo(1, 1, 2, 2)); + add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ALEXNET_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/AlexNetFullyConnectedLayerDataset.h b/tests/datasets_new/AlexNetFullyConnectedLayerDataset.h new file mode 100644 index 0000000000..4aa4f4d861 --- /dev/null +++ b/tests/datasets_new/AlexNetFullyConnectedLayerDataset.h @@ -0,0 +1,53 @@ +/* + * 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_ALEXNET_FULLYCONNECTED_LAYER_DATASET +#define ARM_COMPUTE_TEST_ALEXNET_FULLYCONNECTED_LAYER_DATASET + +#include "tests/datasets_new/FullyConnectedLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class AlexNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset +{ +public: + AlexNetFullyConnectedLayerDataset() + { + add_config(TensorShape(6U, 6U, 256U), TensorShape(9216U, 4096U), TensorShape(4096U), TensorShape(4096U)); + add_config(TensorShape(4096U), TensorShape(4096U, 4096U), TensorShape(4096U), TensorShape(4096U)); + add_config(TensorShape(4096U), TensorShape(4096U, 1000U), TensorShape(1000U), TensorShape(1000U)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ALEXNET_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets_new/AlexNetPoolingLayerDataset.h b/tests/datasets_new/AlexNetPoolingLayerDataset.h new file mode 100644 index 0000000000..714bca0777 --- /dev/null +++ b/tests/datasets_new/AlexNetPoolingLayerDataset.h @@ -0,0 +1,53 @@ +/* + * 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_ALEXNET_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_ALEXNET_POOLING_LAYER_DATASET + +#include "tests/datasets_new/PoolingLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class AlexNetPoolingLayerDataset final : public PoolingLayerDataset +{ +public: + AlexNetPoolingLayerDataset() + { + add_config(TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 96U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + add_config(TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + add_config(TensorShape(13U, 13U, 256U), TensorShape(6U, 6U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ALEXNET_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/ConvolutionLayerDataset.h b/tests/datasets_new/ConvolutionLayerDataset.h new file mode 100644 index 0000000000..ba11bd5d6d --- /dev/null +++ b/tests/datasets_new/ConvolutionLayerDataset.h @@ -0,0 +1,126 @@ +/* + * 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_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_CONVOLUTION_LAYER_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class ConvolutionLayerDataset +{ +public: + using type = std::tuple<TensorShape, TensorShape, TensorShape, TensorShape, PadStrideInfo>; + + struct iterator + { + iterator(std::vector<TensorShape>::const_iterator src_it, + std::vector<TensorShape>::const_iterator weights_it, + std::vector<TensorShape>::const_iterator biases_it, + std::vector<TensorShape>::const_iterator dst_it, + std::vector<PadStrideInfo>::const_iterator infos_it) + : _src_it{ std::move(src_it) }, + _weights_it{ std::move(weights_it) }, + _biases_it{ std::move(biases_it) }, + _dst_it{ std::move(dst_it) }, + _infos_it{ std::move(infos_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_src_it << ":"; + description << "Weights=" << *_weights_it << ":"; + description << "Biases=" << *_biases_it << ":"; + description << "Out=" << *_dst_it << ":"; + description << "Info=" << *_infos_it; + return description.str(); + } + + ConvolutionLayerDataset::type operator*() const + { + return std::make_tuple(*_src_it, *_weights_it, *_biases_it, *_dst_it, *_infos_it); + } + + iterator &operator++() + { + ++_src_it; + ++_weights_it; + ++_biases_it; + ++_dst_it; + ++_infos_it; + + return *this; + } + + private: + std::vector<TensorShape>::const_iterator _src_it; + std::vector<TensorShape>::const_iterator _weights_it; + std::vector<TensorShape>::const_iterator _biases_it; + std::vector<TensorShape>::const_iterator _dst_it; + std::vector<PadStrideInfo>::const_iterator _infos_it; + }; + + iterator begin() const + { + return iterator(_src_shapes.begin(), _weight_shapes.begin(), _bias_shapes.begin(), _dst_shapes.begin(), _infos.begin()); + } + + int size() const + { + return std::min(_src_shapes.size(), std::min(_weight_shapes.size(), std::min(_bias_shapes.size(), std::min(_dst_shapes.size(), _infos.size())))); + } + + void add_config(TensorShape src, TensorShape weights, TensorShape biases, TensorShape dst, PadStrideInfo info) + { + _src_shapes.emplace_back(std::move(src)); + _weight_shapes.emplace_back(std::move(weights)); + _bias_shapes.emplace_back(std::move(biases)); + _dst_shapes.emplace_back(std::move(dst)); + _infos.emplace_back(std::move(info)); + } + +protected: + ConvolutionLayerDataset() = default; + ConvolutionLayerDataset(ConvolutionLayerDataset &&) = default; + +private: + std::vector<TensorShape> _src_shapes{}; + std::vector<TensorShape> _weight_shapes{}; + std::vector<TensorShape> _bias_shapes{}; + std::vector<TensorShape> _dst_shapes{}; + std::vector<PadStrideInfo> _infos{}; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/DirectConvolutionLayerDataset.h b/tests/datasets_new/DirectConvolutionLayerDataset.h new file mode 100644 index 0000000000..ae1538dbef --- /dev/null +++ b/tests/datasets_new/DirectConvolutionLayerDataset.h @@ -0,0 +1,54 @@ +/* + * 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_DIRECT_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_DIRECT_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets_new/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +/** Stripped down version of AlexNet as not all kernel sizes and strides are supported. */ +class DirectConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + DirectConvolutionLayerDataset() + { + add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DIRECT_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/FullyConnectedLayerDataset.h b/tests/datasets_new/FullyConnectedLayerDataset.h new file mode 100644 index 0000000000..562295f00f --- /dev/null +++ b/tests/datasets_new/FullyConnectedLayerDataset.h @@ -0,0 +1,119 @@ +/* + * 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_FULLYCONNECTED_LAYER_DATASET +#define ARM_COMPUTE_TEST_FULLYCONNECTED_LAYER_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class FullyConnectedLayerDataset +{ +public: + using type = std::tuple<TensorShape, TensorShape, TensorShape, TensorShape>; + + struct iterator + { + iterator(std::vector<TensorShape>::const_iterator src_it, + std::vector<TensorShape>::const_iterator weights_it, + std::vector<TensorShape>::const_iterator biases_it, + std::vector<TensorShape>::const_iterator dst_it) + : _src_it{ std::move(src_it) }, + _weights_it{ std::move(weights_it) }, + _biases_it{ std::move(biases_it) }, + _dst_it{ std::move(dst_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_src_it << ":"; + description << "Weights=" << *_weights_it << ":"; + description << "Biases=" << *_biases_it << ":"; + description << "Out=" << *_dst_it << ":"; + return description.str(); + } + + FullyConnectedLayerDataset::type operator*() const + { + return std::make_tuple(*_src_it, *_weights_it, *_biases_it, *_dst_it); + } + + iterator &operator++() + { + ++_src_it; + ++_weights_it; + ++_biases_it; + ++_dst_it; + + return *this; + } + + private: + std::vector<TensorShape>::const_iterator _src_it; + std::vector<TensorShape>::const_iterator _weights_it; + std::vector<TensorShape>::const_iterator _biases_it; + std::vector<TensorShape>::const_iterator _dst_it; + }; + + iterator begin() const + { + return iterator(_src_shapes.begin(), _weight_shapes.begin(), _bias_shapes.begin(), _dst_shapes.begin()); + } + + int size() const + { + return std::min(_src_shapes.size(), std::min(_weight_shapes.size(), std::min(_bias_shapes.size(), _dst_shapes.size()))); + } + + void add_config(TensorShape src, TensorShape weights, TensorShape biases, TensorShape dst) + { + _src_shapes.emplace_back(std::move(src)); + _weight_shapes.emplace_back(std::move(weights)); + _bias_shapes.emplace_back(std::move(biases)); + _dst_shapes.emplace_back(std::move(dst)); + } + +protected: + FullyConnectedLayerDataset() = default; + FullyConnectedLayerDataset(FullyConnectedLayerDataset &&) = default; + +private: + std::vector<TensorShape> _src_shapes{}; + std::vector<TensorShape> _weight_shapes{}; + std::vector<TensorShape> _bias_shapes{}; + std::vector<TensorShape> _dst_shapes{}; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets_new/GEMMDataset.h b/tests/datasets_new/GEMMDataset.h new file mode 100644 index 0000000000..8c080aa0a9 --- /dev/null +++ b/tests/datasets_new/GEMMDataset.h @@ -0,0 +1,132 @@ +/* + * 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_GEMM_DATASET +#define ARM_COMPUTE_TEST_GEMM_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GEMMDataset +{ +public: + using type = std::tuple<TensorShape, TensorShape, TensorShape, TensorShape, float, float>; + + struct iterator + { + iterator(std::vector<TensorShape>::const_iterator a_it, + std::vector<TensorShape>::const_iterator b_it, + std::vector<TensorShape>::const_iterator c_it, + std::vector<TensorShape>::const_iterator dst_it, + std::vector<float>::const_iterator alpha_it, + std::vector<float>::const_iterator beta_it) + : _a_it{ std::move(a_it) }, + _b_it{ std::move(b_it) }, + _c_it{ std::move(c_it) }, + _dst_it{ std::move(dst_it) }, + _alpha_it{ std::move(alpha_it) }, + _beta_it{ std::move(beta_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "A=" << *_a_it << ":"; + description << "B=" << *_b_it << ":"; + description << "C=" << *_c_it << ":"; + description << "Out=" << *_dst_it << ":"; + description << "Alpha=" << *_alpha_it; + description << "Beta=" << *_beta_it; + return description.str(); + } + + GEMMDataset::type operator*() const + { + return std::make_tuple(*_a_it, *_b_it, *_c_it, *_dst_it, *_alpha_it, *_beta_it); + } + + iterator &operator++() + { + ++_a_it; + ++_b_it; + ++_c_it; + ++_dst_it; + ++_alpha_it; + ++_beta_it; + + return *this; + } + + private: + std::vector<TensorShape>::const_iterator _a_it; + std::vector<TensorShape>::const_iterator _b_it; + std::vector<TensorShape>::const_iterator _c_it; + std::vector<TensorShape>::const_iterator _dst_it; + std::vector<float>::const_iterator _alpha_it; + std::vector<float>::const_iterator _beta_it; + }; + + iterator begin() const + { + return iterator(_a_shapes.begin(), _b_shapes.begin(), _c_shapes.begin(), _dst_shapes.begin(), _alpha.begin(), _beta.begin()); + } + + int size() const + { + return std::min(_a_shapes.size(), std::min(_b_shapes.size(), std::min(_c_shapes.size(), std::min(_dst_shapes.size(), std::min(_alpha.size(), _beta.size()))))); + } + + void add_config(TensorShape a, TensorShape b, TensorShape c, TensorShape dst, float alpha, float beta) + { + _a_shapes.emplace_back(std::move(a)); + _b_shapes.emplace_back(std::move(b)); + _c_shapes.emplace_back(std::move(c)); + _dst_shapes.emplace_back(std::move(dst)); + _alpha.emplace_back(std::move(alpha)); + _beta.emplace_back(std::move(beta)); + } + +protected: + GEMMDataset() = default; + GEMMDataset(GEMMDataset &&) = default; + +private: + std::vector<TensorShape> _a_shapes{}; + std::vector<TensorShape> _b_shapes{}; + std::vector<TensorShape> _c_shapes{}; + std::vector<TensorShape> _dst_shapes{}; + std::vector<float> _alpha{}; + std::vector<float> _beta{}; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GEMM_DATASET */ diff --git a/tests/datasets_new/GoogLeNetConvolutionLayerDataset.h b/tests/datasets_new/GoogLeNetConvolutionLayerDataset.h new file mode 100644 index 0000000000..e69178a042 --- /dev/null +++ b/tests/datasets_new/GoogLeNetConvolutionLayerDataset.h @@ -0,0 +1,148 @@ +/* + * 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_GOOGLENET_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENET_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets_new/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + GoogLeNetConvolutionLayerDataset() + { + // conv1/7x7_s2 + add_config(TensorShape(224U, 224U, 3U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U), PadStrideInfo(2, 2, 3, 3)); + // conv2/3x3_reduce + add_config(TensorShape(56U, 56U, 64U), TensorShape(1U, 1U, 64U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(1, 1, 0, 0)); + // conv2/3x3 + add_config(TensorShape(56U, 56U, 64U), TensorShape(3U, 3U, 64U, 192U), TensorShape(192U), TensorShape(56U, 56U, 192U), PadStrideInfo(1, 1, 1, 1)); + // inception_3a/1x1 + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_3a/3x3_reduce + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 0, 0)); + // inception_3a/3x3 + add_config(TensorShape(28U, 28U, 96U), TensorShape(3U, 3U, 96U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 1, 1)); + // inception_3a/5x5_reduce + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 16U), TensorShape(16U), TensorShape(28U, 28U, 16U), PadStrideInfo(1, 1, 0, 0)); + // inception_3a/5x5 + add_config(TensorShape(28U, 28U, 16U), TensorShape(5U, 5U, 16U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 2, 2)); + // inception_3a/pool_proj + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_3b/1x1, inception_3b/3x3_reduce + add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_3b/3x3 + add_config(TensorShape(28U, 28U, 128U), TensorShape(3U, 3U, 128U, 192U), TensorShape(192U), TensorShape(28U, 28U, 192U), PadStrideInfo(1, 1, 1, 1)); + // inception_3b/5x5_reduce + add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_3b/5x5 + add_config(TensorShape(28U, 28U, 32U), TensorShape(5U, 5U, 32U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 2, 2)); + // inception_3b/pool_proj + add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/1x1 + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 192U), TensorShape(192U), TensorShape(14U, 14U, 192U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/3x3_reduce + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 96U), TensorShape(96U), TensorShape(14U, 14U, 96U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/3x3 + add_config(TensorShape(14U, 14U, 96U), TensorShape(3U, 3U, 96U, 208U), TensorShape(208U), TensorShape(14U, 14U, 208U), PadStrideInfo(1, 1, 1, 1)); + // inception_4a/5x5_reduce + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 16U), TensorShape(16U), TensorShape(14U, 14U, 16U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/5x5 + add_config(TensorShape(14U, 14U, 16U), TensorShape(5U, 5U, 16U, 48U), TensorShape(48U), TensorShape(14U, 14U, 48U), PadStrideInfo(1, 1, 2, 2)); + // inception_4a/pool_proj + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/1x1 + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/3x3_reduce, inception_4d/1x1 + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 112U), TensorShape(112U), TensorShape(14U, 14U, 112U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/3x3 + add_config(TensorShape(14U, 14U, 112U), TensorShape(3U, 3U, 112U, 224U), TensorShape(224U), TensorShape(14U, 14U, 224U), PadStrideInfo(1, 1, 1, 1)); + // inception_4b/5x5_reduce, inception_4c/5x5_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 24U), TensorShape(24U), TensorShape(14U, 14U, 24U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/5x5, inception_4c/5x5 + add_config(TensorShape(14U, 14U, 24U), TensorShape(5U, 5U, 24U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2)); + // inception_4b/pool_proj, inception_4c/pool_proj, inception_4d/pool_proj + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_4c/1x1, inception_4c/3x3_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_4c/3x3 + add_config(TensorShape(14U, 14U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 1, 1)); + // inception_4d/3x3_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 144U), TensorShape(144U), TensorShape(14U, 14U, 144U), PadStrideInfo(1, 1, 0, 0)); + // inception_4d/3x3 + add_config(TensorShape(14U, 14U, 144U), TensorShape(3U, 3U, 144U, 288U), TensorShape(288U), TensorShape(14U, 14U, 288U), PadStrideInfo(1, 1, 1, 1)); + // inception_4d/5x5_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_4d/5x5 + add_config(TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2)); + // inception_4e/1x1 + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 0, 0)); + // inception_4e/3x3_reduce + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0)); + // inception_4e/3x3 + add_config(TensorShape(14U, 14U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(14U, 14U, 320U), PadStrideInfo(1, 1, 1, 1)); + // inception_4e/5x5_reduce + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_4e/5x5 + add_config(TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 2, 2)); + // inception_4e/pool_proj + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/1x1 + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 256U), TensorShape(256U), TensorShape(7U, 7U, 256U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/3x3_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 160U), TensorShape(160U), TensorShape(7U, 7U, 160U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/3x3 + add_config(TensorShape(7U, 7U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(7U, 7U, 320U), PadStrideInfo(1, 1, 1, 1)); + // inception_5a/5x5_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 32U), TensorShape(32U), TensorShape(7U, 7U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/5x5 + add_config(TensorShape(7U, 7U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2)); + // inception_5a/pool_proj, inception_5b/pool_proj + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/1x1 + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/3x3_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 192U), TensorShape(192U), TensorShape(7U, 7U, 192U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/3x3 + add_config(TensorShape(7U, 7U, 192U), TensorShape(3U, 3U, 192U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 1, 1)); + // inception_5b/5x5_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 48U), TensorShape(48U), TensorShape(7U, 7U, 48U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/5x5 + add_config(TensorShape(7U, 7U, 48U), TensorShape(5U, 5U, 48U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENET_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/benchmark/PerformanceUserConfiguration.cpp b/tests/datasets_new/GoogLeNetFullyConnectedLayerDataset.h index ca412d660a..435bf8505d 100644 --- a/tests/benchmark/PerformanceUserConfiguration.cpp +++ b/tests/datasets_new/GoogLeNetFullyConnectedLayerDataset.h @@ -21,25 +21,31 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "PerformanceUserConfiguration.h" +#ifndef ARM_COMPUTE_TEST_GOOGLENET_FULLYCONNECTED_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENET_FULLYCONNECTED_LAYER_DATASET -#include "ProgramOptions.h" +#include "tests/datasets_new/FullyConnectedLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" namespace arm_compute { namespace test { -namespace performance +namespace datasets { -PerformanceUserConfiguration::PerformanceUserConfiguration(const ProgramOptions &options) - : UserConfiguration(options) +class GoogLeNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset { - unsigned int tmp_runs = 0; - if(options.get("runs", tmp_runs)) +public: + GoogLeNetFullyConnectedLayerDataset() { - runs = tmp_runs; + add_config(TensorShape(1024U), TensorShape(1024U, 1000U), TensorShape(1000U), TensorShape(1000U)); } -} -} // namespace performance +}; +} // namespace datasets } // namespace test } // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENET_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets_new/GoogLeNetGEMMDataset.h b/tests/datasets_new/GoogLeNetGEMMDataset.h new file mode 100644 index 0000000000..84f2a48c3e --- /dev/null +++ b/tests/datasets_new/GoogLeNetGEMMDataset.h @@ -0,0 +1,113 @@ +/* + * 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_GOOGLENET_GEMM_DATASET +#define ARM_COMPUTE_TEST_GOOGLENET_GEMM_DATASET + +#include "tests/datasets_new/GEMMDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetGEMMDataset final : public GEMMDataset +{ +public: + GoogLeNetGEMMDataset() + { + add_config(TensorShape(147U, 12544U), TensorShape(64U, 147U), TensorShape(64U, 12544U), TensorShape(64U, 12544U), 1.0f, 0.0f); + add_config(TensorShape(64U, 3136U), TensorShape(64U, 64U), TensorShape(64U, 3136U), TensorShape(64U, 3136U), 1.0f, 0.0f); + add_config(TensorShape(576U, 3136U), TensorShape(192U, 576U), TensorShape(192U, 3136U), TensorShape(192U, 3136U), 1.0f, 0.0f); + add_config(TensorShape(192U, 784U), TensorShape(64U, 192U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f); + add_config(TensorShape(192U, 784U), TensorShape(96U, 192U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f); + add_config(TensorShape(864U, 784U), TensorShape(128U, 864U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f); + add_config(TensorShape(192U, 784U), TensorShape(16U, 192U), TensorShape(16U, 784U), TensorShape(16U, 784U), 1.0f, 0.0f); + add_config(TensorShape(400U, 784U), TensorShape(32U, 400U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f); + add_config(TensorShape(192U, 784U), TensorShape(32U, 192U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f); + add_config(TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f); + add_config(TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f); + add_config(TensorShape(1152U, 784U), TensorShape(192U, 1152U), TensorShape(192U, 784U), TensorShape(192U, 784U), 1.0f, 0.0f); + add_config(TensorShape(256U, 784U), TensorShape(32U, 256U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f); + add_config(TensorShape(800U, 784U), TensorShape(96U, 800U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f); + add_config(TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f); + add_config(TensorShape(480U, 196U), TensorShape(192U, 480U), TensorShape(192U, 196U), TensorShape(192U, 196U), 1.0f, 0.0f); + add_config(TensorShape(480U, 196U), TensorShape(96U, 480U), TensorShape(96U, 196U), TensorShape(96U, 196U), 1.0f, 0.0f); + add_config(TensorShape(864U, 196U), TensorShape(204U, 864U), TensorShape(204U, 196U), TensorShape(204U, 196U), 1.0f, 0.0f); + add_config(TensorShape(480U, 196U), TensorShape(16U, 480U), TensorShape(16U, 196U), TensorShape(16U, 196U), 1.0f, 0.0f); + add_config(TensorShape(400U, 196U), TensorShape(48U, 400U), TensorShape(48U, 196U), TensorShape(48U, 196U), 1.0f, 0.0f); + add_config(TensorShape(480U, 196U), TensorShape(64U, 480U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(508U, 196U), TensorShape(160U, 508U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f); + add_config(TensorShape(508U, 196U), TensorShape(112U, 508U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f); + add_config(TensorShape(1008U, 196U), TensorShape(224U, 1008U), TensorShape(224U, 196U), TensorShape(224U, 196U), 1.0f, 0.0f); + add_config(TensorShape(508U, 196U), TensorShape(24U, 508U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f); + add_config(TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(508U, 196U), TensorShape(64U, 508U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); + add_config(TensorShape(1152U, 196U), TensorShape(256U, 1152U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(24U, 512U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f); + add_config(TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(112U, 512U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(144U, 512U), TensorShape(144U, 196U), TensorShape(144U, 196U), 1.0f, 0.0f); + add_config(TensorShape(1296U, 196U), TensorShape(288U, 1296U), TensorShape(288U, 196U), TensorShape(288U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(32U, 512U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f); + add_config(TensorShape(800U, 196U), TensorShape(64U, 800U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(528U, 196U), TensorShape(256U, 528U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f); + add_config(TensorShape(528U, 196U), TensorShape(160U, 528U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f); + add_config(TensorShape(1440U, 196U), TensorShape(320U, 1440U), TensorShape(320U, 196U), TensorShape(320U, 196U), 1.0f, 0.0f); + add_config(TensorShape(528U, 196U), TensorShape(32U, 528U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f); + add_config(TensorShape(800U, 196U), TensorShape(128U, 800U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); + add_config(TensorShape(528U, 196U), TensorShape(128U, 528U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(256U, 832U), TensorShape(256U, 49U), TensorShape(256U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(160U, 832U), TensorShape(160U, 49U), TensorShape(160U, 49U), 1.0f, 0.0f); + add_config(TensorShape(1440U, 49U), TensorShape(320U, 1440U), TensorShape(320U, 49U), TensorShape(320U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f); + add_config(TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(384U, 832U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(192U, 832U), TensorShape(192U, 49U), TensorShape(192U, 49U), 1.0f, 0.0f); + add_config(TensorShape(1728U, 49U), TensorShape(384U, 1728U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f); + add_config(TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); + add_config(TensorShape(508U, 16U), TensorShape(128U, 508U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f); + add_config(TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f); + add_config(TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f); + add_config(TensorShape(528U, 16U), TensorShape(128U, 528U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f); + add_config(TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f); + add_config(TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f); + add_config(TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENET_GEMM_DATASET */ diff --git a/tests/datasets_new/GoogLeNetPoolingLayerDataset.h b/tests/datasets_new/GoogLeNetPoolingLayerDataset.h new file mode 100644 index 0000000000..24d5da190d --- /dev/null +++ b/tests/datasets_new/GoogLeNetPoolingLayerDataset.h @@ -0,0 +1,71 @@ +/* + * 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_GOOGLENET_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENET_POOLING_LAYER_DATASET + +#include "tests/datasets_new/PoolingLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetPoolingLayerDataset final : public PoolingLayerDataset +{ +public: + GoogLeNetPoolingLayerDataset() + { + // FIXME: Add support for 7x7 pooling layer pool5/7x7_s1 + // pool1/3x3_s2 + add_config(TensorShape(112U, 112U, 64U), TensorShape(56U, 56U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool2/3x3_s2 + add_config(TensorShape(56U, 56U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // inception_3a/pool + add_config(TensorShape(28U, 28U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // inception_3b/pool + add_config(TensorShape(28U, 28U, 256U), TensorShape(28U, 28U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // pool3/3x3_s2 + add_config(TensorShape(28U, 28U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // inception_4a/pool + add_config(TensorShape(14U, 14U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // inception_4b/pool, inception_4c/pool, inception_4d/pool + add_config(TensorShape(14U, 14U, 512U), TensorShape(14U, 14U, 512U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // inception_4e/pool + add_config(TensorShape(14U, 14U, 528U), TensorShape(14U, 14U, 528U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // pool4/3x3_s2 + add_config(TensorShape(14U, 14U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // inception_5a/pool, inception_5b/pool + add_config(TensorShape(7U, 7U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENET_POOLING_LAYER_DATASET */ diff --git a/tests/benchmark/WallClockTimer.h b/tests/datasets_new/LeNet5ConvolutionLayerDataset.h index 85a8b86213..446a413663 100644 --- a/tests/benchmark/WallClockTimer.h +++ b/tests/datasets_new/LeNet5ConvolutionLayerDataset.h @@ -21,33 +21,32 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_TEST_BENCHMARK_WALL_CLOCK_TIMER_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_WALL_CLOCK_TIMER_H__ +#ifndef ARM_COMPUTE_TEST_LENET5_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_LENET5_CONVOLUTION_LAYER_DATASET -#include "Instrument.h" +#include "tests/datasets_new/ConvolutionLayerDataset.h" -#include <chrono> +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" namespace arm_compute { namespace test { -namespace benchmark +namespace datasets { -/** Implementation of an instrument to measure elapsed wall-clock time in milliseconds. */ -class WallClockTimer : public Instrument +class LeNet5ConvolutionLayerDataset final : public ConvolutionLayerDataset { public: - std::string id() const override; - void start() override; - void stop() override; - std::unique_ptr<Instrument::IMeasurement> get_measurement() const override; - -private: - std::chrono::high_resolution_clock::time_point _start{}; - std::chrono::high_resolution_clock::time_point _stop{}; + LeNet5ConvolutionLayerDataset() + { + add_config(TensorShape(28U, 28U, 1U), TensorShape(5U, 5U, 1U, 20U), TensorShape(20U), TensorShape(24U, 24U, 20U), PadStrideInfo(1, 1, 0, 0)); + add_config(TensorShape(12U, 12U, 20U), TensorShape(5U, 5U, 20U, 50U), TensorShape(50U), TensorShape(8U, 8U, 50U), PadStrideInfo(1, 1, 0, 0)); + } }; -} // namespace benchmark +} // namespace datasets } // namespace test } // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BENCHMARK_WALL_CLOCK_TIMER_H__ */ +#endif /* ARM_COMPUTE_TEST_LENET5_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/benchmark/WallClockTimer.cpp b/tests/datasets_new/LeNet5FullyConnectedLayerDataset.h index 717fe04b31..bbbf7121c3 100644 --- a/tests/benchmark/WallClockTimer.cpp +++ b/tests/datasets_new/LeNet5FullyConnectedLayerDataset.h @@ -21,37 +21,34 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "WallClockTimer.h" +#ifndef ARM_COMPUTE_TEST_LENET5_FULLYCONNECTED_LAYER_DATASET +#define ARM_COMPUTE_TEST_LENET5_FULLYCONNECTED_LAYER_DATASET -#include "Utils.h" -#include "support/ToolchainSupport.h" +#include "tests/datasets_new/FullyConnectedLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +using namespace arm_compute; namespace arm_compute { namespace test { -namespace benchmark +namespace datasets { -std::string WallClockTimer::id() const -{ - return "Wall clock"; -} - -void WallClockTimer::start() -{ - _start = std::chrono::high_resolution_clock::now(); -} - -void WallClockTimer::stop() -{ - _stop = std::chrono::high_resolution_clock::now(); -} - -std::unique_ptr<Instrument::IMeasurement> WallClockTimer::get_measurement() const +class LeNet5FullyConnectedLayerDataset final : public FullyConnectedLayerDataset { - const std::chrono::duration<float, std::milli> delta = _stop - _start; - return support::cpp14::make_unique<Instrument::Measurement<float>>(delta.count()); -} -} // namespace benchmark +public: + LeNet5FullyConnectedLayerDataset() + { + add_config(TensorShape(4U, 4U, 50U), TensorShape(800U, 500U), TensorShape(500U), TensorShape(500U)); + add_config(TensorShape(500U), TensorShape(500U, 10U), TensorShape(10U), TensorShape(10U)); + } +}; +} // namespace datasets } // namespace test } // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LENET5_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/benchmark/PerformanceProgramOptions.h b/tests/datasets_new/LeNet5PoolingLayerDataset.h index e9c7a38b3f..bc234d858c 100644 --- a/tests/benchmark/PerformanceProgramOptions.h +++ b/tests/datasets_new/LeNet5PoolingLayerDataset.h @@ -21,25 +21,32 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_TEST_PERFORMANCE_PROGRAM_OPTIONS_H__ -#define __ARM_COMPUTE_TEST_PERFORMANCE_PROGRAM_OPTIONS_H__ +#ifndef ARM_COMPUTE_TEST_LENET5_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_LENET5_POOLING_LAYER_DATASET -#include "ProgramOptions.h" +#include "tests/datasets_new/PoolingLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" namespace arm_compute { namespace test { -namespace performance +namespace datasets { -/** Subclass of @ref ProgramOptions that adds performance specific options. */ -class PerformanceProgramOptions : public ProgramOptions +class LeNet5PoolingLayerDataset final : public PoolingLayerDataset { public: - /** Defines additonal options. */ - PerformanceProgramOptions(); + LeNet5PoolingLayerDataset() + { + add_config(TensorShape(24U, 24U, 20U), TensorShape(12U, 12U, 20U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); + add_config(TensorShape(8U, 8U, 50U), TensorShape(4U, 4U, 50U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); + } }; -} // namespace performance +} // namespace datasets } // namespace test } // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_PERFORMANCE_PROGRAM_OPTIONS_H__ */ +#endif /* ARM_COMPUTE_TEST_LENET5_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/NormalizationLayerDataset.h b/tests/datasets_new/NormalizationLayerDataset.h new file mode 100644 index 0000000000..73e215be48 --- /dev/null +++ b/tests/datasets_new/NormalizationLayerDataset.h @@ -0,0 +1,77 @@ +/* + * 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_NORMALIZATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_NORMALIZATION_LAYER_DATASET + +#include "framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class AlexNetNormalizationLayerDataset final : public + framework::dataset::CartesianProductDataset<framework::dataset::InitializerListDataset<TensorShape>, framework::dataset::SingletonDataset<NormalizationLayerInfo>> +{ +public: + AlexNetNormalizationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 256U) }), + framework::dataset::make("Info", NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)) + } + { + } + AlexNetNormalizationLayerDataset(AlexNetNormalizationLayerDataset &&) = default; + ~AlexNetNormalizationLayerDataset() = default; +}; + +class GoogLeNetNormalizationLayerDataset final : public + framework::dataset::CartesianProductDataset<framework::dataset::InitializerListDataset<TensorShape>, framework::dataset::SingletonDataset<NormalizationLayerInfo>> +{ +public: + GoogLeNetNormalizationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { // conv2/norm2 + TensorShape(56U, 56U, 192U), + // pool1/norm1 + TensorShape(56U, 56U, 64U) }), + framework::dataset::make("Info", NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)) + } + { + } + GoogLeNetNormalizationLayerDataset(GoogLeNetNormalizationLayerDataset &&) = default; + ~GoogLeNetNormalizationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_NORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets_new/PoolingLayerDataset.h b/tests/datasets_new/PoolingLayerDataset.h new file mode 100644 index 0000000000..8b35ac6076 --- /dev/null +++ b/tests/datasets_new/PoolingLayerDataset.h @@ -0,0 +1,112 @@ +/* + * 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_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_POOLING_LAYER_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class PoolingLayerDataset +{ +public: + using type = std::tuple<TensorShape, TensorShape, PoolingLayerInfo>; + + struct iterator + { + iterator(std::vector<TensorShape>::const_iterator src_it, + std::vector<TensorShape>::const_iterator dst_it, + std::vector<PoolingLayerInfo>::const_iterator infos_it) + : _src_it{ std::move(src_it) }, + _dst_it{ std::move(dst_it) }, + _infos_it{ std::move(infos_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_src_it << ":"; + description << "Out=" << *_dst_it << ":"; + description << "Info=" << *_infos_it; + return description.str(); + } + + PoolingLayerDataset::type operator*() const + { + return std::make_tuple(*_src_it, *_dst_it, *_infos_it); + } + + iterator &operator++() + { + ++_src_it; + ++_dst_it; + ++_infos_it; + + return *this; + } + + private: + std::vector<TensorShape>::const_iterator _src_it; + std::vector<TensorShape>::const_iterator _dst_it; + std::vector<PoolingLayerInfo>::const_iterator _infos_it; + }; + + iterator begin() const + { + return iterator(_src_shapes.begin(), _dst_shapes.begin(), _infos.begin()); + } + + int size() const + { + return std::min(_src_shapes.size(), std::min(_dst_shapes.size(), _infos.size())); + } + + void add_config(TensorShape src, TensorShape dst, PoolingLayerInfo info) + { + _src_shapes.emplace_back(std::move(src)); + _dst_shapes.emplace_back(std::move(dst)); + _infos.emplace_back(std::move(info)); + } + +protected: + PoolingLayerDataset() = default; + PoolingLayerDataset(PoolingLayerDataset &&) = default; + +private: + std::vector<TensorShape> _src_shapes{}; + std::vector<TensorShape> _dst_shapes{}; + std::vector<PoolingLayerInfo> _infos{}; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_POOLING_LAYER_DATASET */ diff --git a/tests/benchmark/common/NormalizationLayer.h b/tests/fixtures_new/ActivationLayerFixture.h index 580dca6c48..bb03fa2ed0 100644 --- a/tests/benchmark/common/NormalizationLayer.h +++ b/tests/fixtures_new/ActivationLayerFixture.h @@ -21,49 +21,36 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_TEST_BENCHMARK_NORMALIZATION_LAYER_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_NORMALIZATION_LAYER_H__ +#ifndef ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE -#include "TensorLibrary.h" -#include "Utils.h" -#include "dataset/NormalizationLayerDataset.h" - -#include <memory> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "framework/Fixture.h" +#include "tests/Globals.h" +#include "tests/Utils.h" namespace arm_compute { namespace test { -namespace benchmark -{ -template <typename DataSet, typename TensorType, typename Accessor, typename Function, DataType dt = DataType::F32> -class NormalizationLayer : public ::benchmark::Fixture +/** Fixture that can be used for NEON and CL */ +template <typename TensorType, typename Function, typename Accessor> +class ActivationLayerFixture : public framework::Fixture { public: - void SetUp(::benchmark::State &state) override + void setup(TensorShape shape, ActivationLayerInfo info, DataType data_type, int batches) { - profiler.add(std::make_shared<WallClockTimer>()); - - const NormalizationLayerDataObject norm_obj = *(DataSet().begin() + state.range(0)); - // Set batched in source and destination shapes - const unsigned int batches = state.range(1); - const unsigned int fixed_point_position = 4; - TensorShape shape = norm_obj.shape; shape.set(shape.num_dimensions(), batches); // Create tensors - src = create_tensor<TensorType>(shape, dt, 1, fixed_point_position); - dst = create_tensor<TensorType>(shape, dt, 1, fixed_point_position); + const int fixed_point_position = 4; + src = create_tensor<TensorType>(shape, data_type, 1, fixed_point_position); + dst = create_tensor<TensorType>(shape, data_type, 1, fixed_point_position); // Create and configure function - norm_layer = std::unique_ptr<Function>(new Function()); - norm_layer->configure(&src, &dst, norm_obj.info); + act_layer.configure(&src, &dst, info); // Allocate tensors src.allocator()->allocate(); @@ -73,24 +60,22 @@ public: library->fill_tensor_uniform(Accessor(src), 0); } - void TearDown(::benchmark::State &state) override + void run() { - norm_layer.reset(); + act_layer.run(); + } + void teardown() + { src.allocator()->free(); dst.allocator()->free(); - - profiler.submit(state); } - std::unique_ptr<Function> norm_layer{ nullptr }; - Profiler profiler{}; - private: TensorType src{}; TensorType dst{}; + Function act_layer{}; }; -} // namespace benchmark } // namespace test } // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_BENCHMARK_NORMALIZATION_LAYER_H__ +#endif /* ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE */ diff --git a/tests/benchmark/system_tests/common/AlexNet.h b/tests/fixtures_new/AlexNetFixture.h index 46e26bf723..fcac1b2236 100644 --- a/tests/benchmark/system_tests/common/AlexNet.h +++ b/tests/fixtures_new/AlexNetFixture.h @@ -21,27 +21,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_TEST_BENCHMARK_ALEXNET_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_ALEXNET_H__ +#ifndef ARM_COMPUTE_TEST_ALEXNETFIXTURE +#define ARM_COMPUTE_TEST_ALEXNETFIXTURE +#include "framework/Fixture.h" +#include "networks_new/AlexNetNetwork.h" #include "tests/TensorLibrary.h" #include "tests/Utils.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "model_objects/AlexNet.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; - namespace arm_compute { namespace test { -namespace benchmark -{ template <typename ITensorType, typename TensorType, typename SubTensorType, @@ -51,45 +42,45 @@ template <typename ITensorType, typename FullyConnectedLayerFunction, typename NormalizationLayerFunction, typename PoolingLayerFunction, - typename SoftmaxLayerFunction, - DataType dt = DataType::F32> -class AlexNetFixture : public ::benchmark::Fixture + typename SoftmaxLayerFunction> + +class AlexNetFixture : public framework::Fixture { public: - void SetUp(::benchmark::State &state) override + void setup(DataType data_type, int batches) { - profiler.add(std::make_shared<WallClockTimer>()); + constexpr bool weights_transposed = true; + constexpr int fixed_point_position = 4; - const unsigned int batches = static_cast<unsigned int>(state.range(0)); - const bool weights_transposed = true; - - network.init_weights(batches, weights_transposed); + network.init(data_type, fixed_point_position, batches, weights_transposed); network.build(); network.allocate(); network.fill_random(); } - void TearDown(::benchmark::State &state) override + void run() + { + network.run(); + } + + void teardown() { - profiler.submit(state); network.clear(); } - Profiler profiler{}; - model_objects::AlexNet<ITensorType, - TensorType, - SubTensorType, - Accessor, - ActivationLayerFunction, - ConvolutionLayerFunction, - FullyConnectedLayerFunction, - NormalizationLayerFunction, - PoolingLayerFunction, - SoftmaxLayerFunction, - dt> - network{}; +private: + networks::AlexNetNetwork<ITensorType, + TensorType, + SubTensorType, + Accessor, + ActivationLayerFunction, + ConvolutionLayerFunction, + FullyConnectedLayerFunction, + NormalizationLayerFunction, + PoolingLayerFunction, + SoftmaxLayerFunction> + network{}; }; -} // namespace benchmark } // namespace test } // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_BENCHMARK_ALEXNET_H__ +#endif /* ARM_COMPUTE_TEST_ALEXNETFIXTURE */ diff --git a/tests/benchmark/common/ConvolutionLayer.h b/tests/fixtures_new/ConvolutionLayerFixture.h index a777a95bde..65426103e2 100644 --- a/tests/benchmark/common/ConvolutionLayer.h +++ b/tests/fixtures_new/ConvolutionLayerFixture.h @@ -21,87 +21,72 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_TEST_BENCHMARK_CONVOLUTION_LAYER_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_CONVOLUTION_LAYER_H__ +#ifndef ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE -#include "TensorLibrary.h" -#include "Utils.h" -#include "dataset/ConvolutionLayerDataset.h" - -#include <memory> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "framework/Fixture.h" +#include "tests/Globals.h" +#include "tests/Utils.h" namespace arm_compute { namespace test { -namespace benchmark -{ -template <typename DataSet, typename TensorType, typename Accessor, typename Function, DataType dt = DataType::F32> -class ConvolutionLayer : public ::benchmark::Fixture +/** Fixture that can be used for NEON and CL */ +template <typename TensorType, typename Function, typename Accessor> +class ConvolutionLayerFixture : public framework::Fixture { public: - void SetUp(::benchmark::State &state) override + void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape biases_shape, TensorShape dst_shape, PadStrideInfo info, DataType data_type, int batches) { - profiler.add(std::make_shared<WallClockTimer>()); - - const ConvolutionLayerDataObject conv_obj = *(DataSet().begin() + state.range(0)); - // Set batched in source and destination shapes - const unsigned int batches = state.range(1); const unsigned int fixed_point_position = 4; - TensorShape src_shape = conv_obj.src_shape; - TensorShape dst_shape = conv_obj.dst_shape; src_shape.set(3 /* batch */, batches); dst_shape.set(3 /* batch */, batches); // Create tensors - src = create_tensor<TensorType>(src_shape, dt, 1, fixed_point_position); - weights = create_tensor<TensorType>(conv_obj.weights_shape, dt, 1, fixed_point_position); - bias = create_tensor<TensorType>(conv_obj.bias_shape, dt, 1, fixed_point_position); - dst = create_tensor<TensorType>(dst_shape, dt, 1, fixed_point_position); + src = create_tensor<TensorType>(src_shape, data_type, 1, fixed_point_position); + weights = create_tensor<TensorType>(weights_shape, data_type, 1, fixed_point_position); + biases = create_tensor<TensorType>(biases_shape, data_type, 1, fixed_point_position); + dst = create_tensor<TensorType>(dst_shape, data_type, 1, fixed_point_position); // Create and configure function - conv_layer = std::unique_ptr<Function>(new Function()); - conv_layer->configure(&src, &weights, &bias, &dst, conv_obj.info); + conv_layer.configure(&src, &weights, &biases, &dst, info); // Allocate tensors src.allocator()->allocate(); weights.allocator()->allocate(); - bias.allocator()->allocate(); + biases.allocator()->allocate(); dst.allocator()->allocate(); // Fill tensors library->fill_tensor_uniform(Accessor(src), 0); library->fill_tensor_uniform(Accessor(weights), 1); - library->fill_tensor_uniform(Accessor(bias), 2); + library->fill_tensor_uniform(Accessor(biases), 2); } - void TearDown(::benchmark::State &state) override + void run() { - conv_layer.reset(); + conv_layer.run(); + } + void teardown() + { src.allocator()->free(); weights.allocator()->free(); - bias.allocator()->free(); + biases.allocator()->free(); dst.allocator()->free(); - - profiler.submit(state); } - std::unique_ptr<Function> conv_layer{ nullptr }; - Profiler profiler{}; - private: TensorType src{}; TensorType weights{}; - TensorType bias{}; + TensorType biases{}; TensorType dst{}; + Function conv_layer{}; }; -} // namespace benchmark } // namespace test } // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_BENCHMARK_CONVOLUTION_LAYER_H__ +#endif /* ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE */ diff --git a/tests/fixtures_new/FullyConnectedLayerFixture.h b/tests/fixtures_new/FullyConnectedLayerFixture.h new file mode 100644 index 0000000000..9bf18a9689 --- /dev/null +++ b/tests/fixtures_new/FullyConnectedLayerFixture.h @@ -0,0 +1,92 @@ +/* + * 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_FULLYCONNECTEDLAYERFIXTURE +#define ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "framework/Fixture.h" +#include "tests/Globals.h" +#include "tests/Utils.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template <typename TensorType, typename Function, typename Accessor> +class FullyConnectedLayerFixture : public framework::Fixture +{ +public: + void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape biases_shape, TensorShape dst_shape, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(src_shape.num_dimensions() /* batch */, batches); + dst_shape.set(dst_shape.num_dimensions() /* batch */, batches); + + // Create tensors + src = create_tensor<TensorType>(src_shape, data_type, 1, fixed_point_position); + weights = create_tensor<TensorType>(weights_shape, data_type, 1, fixed_point_position); + biases = create_tensor<TensorType>(biases_shape, data_type, 1, fixed_point_position); + dst = create_tensor<TensorType>(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + fc_layer.configure(&src, &weights, &biases, &dst); + + // Allocate tensors + src.allocator()->allocate(); + weights.allocator()->allocate(); + biases.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(weights), 1); + library->fill_tensor_uniform(Accessor(biases), 2); + } + + void run() + { + fc_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + weights.allocator()->free(); + biases.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType weights{}; + TensorType biases{}; + TensorType dst{}; + Function fc_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE */ diff --git a/tests/fixtures_new/GEMMFixture.h b/tests/fixtures_new/GEMMFixture.h new file mode 100644 index 0000000000..cd357789e5 --- /dev/null +++ b/tests/fixtures_new/GEMMFixture.h @@ -0,0 +1,84 @@ +/* + * 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_GEMMFIXTURE +#define ARM_COMPUTE_TEST_GEMMFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "framework/Fixture.h" +#include "tests/Globals.h" +#include "tests/Utils.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template <typename TensorType, typename Function> +class GEMMFixture : public framework::Fixture +{ +public: + void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape shape_dst, float alpha, float beta, DataType data_type) + { + constexpr int fixed_point_position = 4; + + // Create tensors + a = create_tensor<TensorType>(shape_a, data_type, 1, fixed_point_position); + b = create_tensor<TensorType>(shape_b, data_type, 1, fixed_point_position); + c = create_tensor<TensorType>(shape_c, data_type, 1, fixed_point_position); + dst = create_tensor<TensorType>(shape_dst, data_type, 1, fixed_point_position); + + // Create and configure function + gemm.configure(&a, &b, &c, &dst, alpha, beta); + + // Allocate tensors + a.allocator()->allocate(); + b.allocator()->allocate(); + c.allocator()->allocate(); + dst.allocator()->allocate(); + } + + void run() + { + gemm.run(); + } + + void teardown() + { + a.allocator()->free(); + b.allocator()->free(); + c.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType a{}; + TensorType b{}; + TensorType c{}; + TensorType dst{}; + Function gemm{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GEMMFIXTURE */ diff --git a/tests/benchmark/system_tests/common/LeNet5.h b/tests/fixtures_new/LeNet5Fixture.h index a2d0cd577c..3f36628c60 100644 --- a/tests/benchmark/system_tests/common/LeNet5.h +++ b/tests/fixtures_new/LeNet5Fixture.h @@ -21,27 +21,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_TEST_BENCHMARK_LENET5_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_LENET5_H__ +#ifndef ARM_COMPUTE_TEST_LENET5FIXTURE +#define ARM_COMPUTE_TEST_LENET5FIXTURE +#include "framework/Fixture.h" +#include "networks_new/LeNet5Network.h" #include "tests/TensorLibrary.h" #include "tests/Utils.h" -#include "benchmark/Profiler.h" -#include "benchmark/WallClockTimer.h" - -#include "model_objects/LeNet5.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; - namespace arm_compute { namespace test { -namespace benchmark -{ template <typename TensorType, typename Accessor, typename ActivationLayerFunction, @@ -49,34 +40,37 @@ template <typename TensorType, typename FullyConnectedLayerFunction, typename PoolingLayerFunction, typename SoftmaxLayerFunction> -class LeNet5Fixture : public ::benchmark::Fixture +class LeNet5Fixture : public framework::Fixture { public: - void SetUp(::benchmark::State &state) override + void setup(int batches) { - profiler.add(std::make_shared<WallClockTimer>()); - - network.build(static_cast<unsigned int>(state.range(0))); + network.init(batches); + network.build(); + network.allocate(); network.fill_random(); } - void TearDown(::benchmark::State &state) override + void run() + { + network.run(); + } + + void teardown() { - profiler.submit(state); network.clear(); } - Profiler profiler{}; - model_objects::LeNet5<TensorType, - Accessor, - ActivationLayerFunction, - ConvolutionLayerFunction, - FullyConnectedLayerFunction, - PoolingLayerFunction, - SoftmaxLayerFunction> - network{}; +private: + networks::LeNet5Network<TensorType, + Accessor, + ActivationLayerFunction, + ConvolutionLayerFunction, + FullyConnectedLayerFunction, + PoolingLayerFunction, + SoftmaxLayerFunction> + network{}; }; -} // namespace benchmark } // namespace test } // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BENCHMARK_LENET5_H__ */ +#endif /* ARM_COMPUTE_TEST_LENET5FIXTURE */ diff --git a/tests/benchmark/common/ActivationLayer.h b/tests/fixtures_new/NormalizationLayerFixture.h index 8e22281025..63d2d42c88 100644 --- a/tests/benchmark/common/ActivationLayer.h +++ b/tests/fixtures_new/NormalizationLayerFixture.h @@ -21,47 +21,36 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_TEST_BENCHMARK_ACTIVATION_LAYER_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_ACTIVATION_LAYER_H__ +#ifndef ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE -#include "TensorLibrary.h" -#include "Utils.h" -#include "dataset/ActivationLayerDataset.h" - -#include <memory> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "framework/Fixture.h" +#include "tests/Globals.h" +#include "tests/Utils.h" namespace arm_compute { namespace test { -namespace benchmark -{ -template <typename DataSet, typename TensorType, typename Accessor, typename Function, DataType dt = DataType::F32> -class ActivationLayer : public ::benchmark::Fixture +/** Fixture that can be used for NEON and CL */ +template <typename TensorType, typename Function, typename Accessor> +class NormalizationLayerFixture : public framework::Fixture { public: - void SetUp(::benchmark::State &state) override + void setup(TensorShape shape, NormalizationLayerInfo info, DataType data_type, int batches) { - profiler.add(std::make_shared<WallClockTimer>()); - - const ActivationLayerDataObject act_obj = *(DataSet().begin() + state.range(0)); - // Set batched in source and destination shapes - const unsigned int batches = state.range(1); const unsigned int fixed_point_position = 4; - TensorShape shape = act_obj.shape; shape.set(shape.num_dimensions(), batches); // Create tensors - src = create_tensor<TensorType>(shape, dt, 1, fixed_point_position); - dst = create_tensor<TensorType>(shape, dt, 1, fixed_point_position); + src = create_tensor<TensorType>(shape, data_type, 1, fixed_point_position); + dst = create_tensor<TensorType>(shape, data_type, 1, fixed_point_position); // Create and configure function - act_layer.configure(&src, &dst, act_obj.info); + norm_layer.configure(&src, &dst, info); // Allocate tensors src.allocator()->allocate(); @@ -71,22 +60,22 @@ public: library->fill_tensor_uniform(Accessor(src), 0); } - void TearDown(::benchmark::State &state) override + void run() + { + norm_layer.run(); + } + + void teardown() { src.allocator()->free(); dst.allocator()->free(); - - profiler.submit(state); } - Function act_layer{}; - Profiler profiler{}; - private: TensorType src{}; TensorType dst{}; + Function norm_layer{}; }; -} // namespace benchmark } // namespace test } // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_BENCHMARK_ACTIVATION_LAYER_H__ +#endif /* ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE */ diff --git a/tests/benchmark/common/PoolingLayer.h b/tests/fixtures_new/PoolingLayerFixture.h index 96ff905568..a09b421ad0 100644 --- a/tests/benchmark/common/PoolingLayer.h +++ b/tests/fixtures_new/PoolingLayerFixture.h @@ -21,49 +21,37 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_TEST_BENCHMARK_POOLING_LAYER_H__ -#define __ARM_COMPUTE_TEST_BENCHMARK_POOLING_LAYER_H__ +#ifndef ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE +#define ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE -#include "TensorLibrary.h" -#include "Utils.h" -#include "dataset/PoolingLayerDataset.h" - -#include <memory> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::benchmark; +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "framework/Fixture.h" +#include "tests/Globals.h" +#include "tests/Utils.h" namespace arm_compute { namespace test { -namespace benchmark -{ -template <typename DataSet, typename TensorType, typename Accessor, typename Function, DataType dt = DataType::F32> -class PoolingLayer : public ::benchmark::Fixture +/** Fixture that can be used for NEON and CL */ +template <typename TensorType, typename Function, typename Accessor> +class PoolingLayerFixture : public framework::Fixture { public: - void SetUp(::benchmark::State &state) override + void setup(TensorShape src_shape, TensorShape dst_shape, PoolingLayerInfo info, DataType data_type, int batches) { - profiler.add(std::make_shared<WallClockTimer>()); - - const PoolingLayerDataObject pool_obj = *(DataSet().begin() + state.range(0)); - // Set batched in source and destination shapes - const unsigned int batches = state.range(1); const unsigned int fixed_point_position = 4; - TensorShape src_shape = pool_obj.src_shape; - TensorShape dst_shape = pool_obj.dst_shape; src_shape.set(src_shape.num_dimensions(), batches); dst_shape.set(dst_shape.num_dimensions(), batches); // Create tensors - src = create_tensor<TensorType>(src_shape, dt, 1, fixed_point_position); - dst = create_tensor<TensorType>(dst_shape, dt, 1, fixed_point_position); + src = create_tensor<TensorType>(src_shape, data_type, 1, fixed_point_position); + dst = create_tensor<TensorType>(dst_shape, data_type, 1, fixed_point_position); // Create and configure function - pool_layer.configure(&src, &dst, pool_obj.info); + pool_layer.configure(&src, &dst, info); // Allocate tensors src.allocator()->allocate(); @@ -73,23 +61,22 @@ public: library->fill_tensor_uniform(Accessor(src), 0); } - void TearDown(::benchmark::State &state) override + void run() + { + pool_layer.run(); + } + + void teardown() { - // Free allocators src.allocator()->free(); dst.allocator()->free(); - - profiler.submit(state); } - Function pool_layer{}; - Profiler profiler{}; - private: TensorType src{}; TensorType dst{}; + Function pool_layer{}; }; -} // namespace benchmark } // namespace test } // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_BENCHMARK_POOLING_LAYER_H__ +#endif /* ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE */ diff --git a/tests/networks_new/AlexNetNetwork.h b/tests/networks_new/AlexNetNetwork.h new file mode 100644 index 0000000000..27b9ef43b5 --- /dev/null +++ b/tests/networks_new/AlexNetNetwork.h @@ -0,0 +1,536 @@ +/* + * 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_MODEL_OBJECTS_ALEXNET_H__ +#define __ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ + +#include "Globals.h" +#include "TensorLibrary.h" +#include "Utils.h" + +#include <memory> + +namespace arm_compute +{ +namespace test +{ +namespace networks +{ +/** AlexNet model object */ +template <typename ITensorType, + typename TensorType, + typename SubTensorType, + typename Accessor, + typename ActivationLayerFunction, + typename ConvolutionLayerFunction, + typename FullyConnectedLayerFunction, + typename NormalizationLayerFunction, + typename PoolingLayerFunction, + typename SoftmaxLayerFunction> +class AlexNetNetwork +{ +public: + void init(DataType data_type, int fixed_point_position, int batches, bool reshaped_weights = false) + { + _data_type = data_type; + _fixed_point_position = fixed_point_position; + _batches = batches; + _reshaped_weights = reshaped_weights; + + // Initialize weights and biases + if(!_reshaped_weights) + { + init_weights(); + } + else + { + init_reshaped_weights(); + } + } + + void build() + { + input.allocator()->init(TensorInfo(TensorShape(227U, 227U, 3U, _batches), 1, _data_type, _fixed_point_position)); + output.allocator()->init(TensorInfo(TensorShape(1000U, _batches), 1, _data_type, _fixed_point_position)); + + // Initialize intermediate tensors + // Layer 1 + conv1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, _data_type, _fixed_point_position)); + act1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, _data_type, _fixed_point_position)); + norm1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, _data_type, _fixed_point_position)); + pool1_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 96U, _batches), 1, _data_type, _fixed_point_position)); + pool11_out = std::unique_ptr<SubTensorType>(new SubTensorType(&pool1_out, TensorShape(27U, 27U, 48U, _batches), Coordinates())); + pool12_out = std::unique_ptr<SubTensorType>(new SubTensorType(&pool1_out, TensorShape(27U, 27U, 48U, _batches), Coordinates(0, 0, 48))); + // Layer 2 + conv2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, _data_type, _fixed_point_position)); + conv21_out = std::unique_ptr<SubTensorType>(new SubTensorType(&conv2_out, TensorShape(27U, 27U, 128U, _batches), Coordinates())); + conv22_out = std::unique_ptr<SubTensorType>(new SubTensorType(&conv2_out, TensorShape(27U, 27U, 128U, _batches), Coordinates(0, 0, 128))); + act2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, _data_type, _fixed_point_position)); + norm2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, _data_type, _fixed_point_position)); + pool2_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, _data_type, _fixed_point_position)); + // Layer 3 + conv3_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); + act3_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); + act31_out = std::unique_ptr<SubTensorType>(new SubTensorType(&act3_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); + act32_out = std::unique_ptr<SubTensorType>(new SubTensorType(&act3_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); + // Layer 4 + conv4_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); + conv41_out = std::unique_ptr<SubTensorType>(new SubTensorType(&conv4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); + conv42_out = std::unique_ptr<SubTensorType>(new SubTensorType(&conv4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); + act4_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); + act41_out = std::unique_ptr<SubTensorType>(new SubTensorType(&act4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); + act42_out = std::unique_ptr<SubTensorType>(new SubTensorType(&act4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); + // Layer 5 + conv5_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, _data_type, _fixed_point_position)); + conv51_out = std::unique_ptr<SubTensorType>(new SubTensorType(&conv5_out, TensorShape(13U, 13U, 128U, _batches), Coordinates())); + conv52_out = std::unique_ptr<SubTensorType>(new SubTensorType(&conv5_out, TensorShape(13U, 13U, 128U, _batches), Coordinates(0, 0, 128))); + act5_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, _data_type, _fixed_point_position)); + pool5_out.allocator()->init(TensorInfo(TensorShape(6U, 6U, 256U, _batches), 1, _data_type, _fixed_point_position)); + // Layer 6 + fc6_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); + act6_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); + // Layer 7 + fc7_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); + act7_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); + // Layer 8 + fc8_out.allocator()->init(TensorInfo(TensorShape(1000U, _batches), 1, _data_type, _fixed_point_position)); + + // Configure Layers + // Layer 1 + TensorType *b0 = _reshaped_weights ? nullptr : &b[0]; + conv1.configure(&input, &w[0], b0, &conv1_out, PadStrideInfo(4, 4, 0, 0), WeightsInfo(_reshaped_weights, 11U, 11U)); + act1.configure(&conv1_out, &act1_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + norm1.configure(&act1_out, &norm1_out, NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)); + pool1.configure(&norm1_out, &pool1_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + // Layer 2 + conv21.configure(pool11_out.get(), w21.get(), b21.get(), conv21_out.get(), PadStrideInfo(1, 1, 2, 2), WeightsInfo(_reshaped_weights, 5U, 5U)); + conv22.configure(pool12_out.get(), w22.get(), b22.get(), conv22_out.get(), PadStrideInfo(1, 1, 2, 2), WeightsInfo(_reshaped_weights, 5U, 5U)); + act2.configure(&conv2_out, &act2_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + norm2.configure(&act2_out, &norm2_out, NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)); + pool2.configure(&norm2_out, &pool2_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + // Layer 3 + TensorType *b2 = _reshaped_weights ? nullptr : &b[2]; + conv3.configure(&pool2_out, &w[2], b2, &conv3_out, PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U)); + act3.configure(&conv3_out, &act3_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 4 + conv41.configure(act31_out.get(), w41.get(), b41.get(), conv41_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U)); + conv42.configure(act32_out.get(), w42.get(), b42.get(), conv42_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U)); + act4.configure(&conv4_out, &act4_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 5 + conv51.configure(act41_out.get(), w51.get(), b51.get(), conv51_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U)); + conv52.configure(act42_out.get(), w52.get(), b52.get(), conv52_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U)); + act5.configure(&conv5_out, &act5_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + pool5.configure(&act5_out, &pool5_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + // Layer 6 + fc6.configure(&pool5_out, &w[5], &b[5], &fc6_out, true, _reshaped_weights); + act6.configure(&fc6_out, &act6_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 7 + fc7.configure(&act6_out, &w[6], &b[6], &fc7_out, true, _reshaped_weights); + act7.configure(&fc7_out, &act7_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 8 + fc8.configure(&act7_out, &w[7], &b[7], &fc8_out, true, _reshaped_weights); + // Softmax + smx.configure(&fc8_out, &output); + } + + void allocate() + { + input.allocator()->allocate(); + output.allocator()->allocate(); + + if(!_reshaped_weights) + { + for(auto &wi : w) + { + wi.allocator()->allocate(); + } + + for(auto &bi : b) + { + bi.allocator()->allocate(); + } + } + else + { + w[0].allocator()->allocate(); + w[2].allocator()->allocate(); + w[5].allocator()->allocate(); + w[6].allocator()->allocate(); + w[7].allocator()->allocate(); + + b[5].allocator()->allocate(); + b[6].allocator()->allocate(); + b[7].allocator()->allocate(); + + dynamic_cast<TensorType *>(w21.get())->allocator()->allocate(); + dynamic_cast<TensorType *>(w22.get())->allocator()->allocate(); + dynamic_cast<TensorType *>(w41.get())->allocator()->allocate(); + dynamic_cast<TensorType *>(w42.get())->allocator()->allocate(); + dynamic_cast<TensorType *>(w51.get())->allocator()->allocate(); + dynamic_cast<TensorType *>(w52.get())->allocator()->allocate(); + } + + conv1_out.allocator()->allocate(); + act1_out.allocator()->allocate(); + norm1_out.allocator()->allocate(); + pool1_out.allocator()->allocate(); + conv2_out.allocator()->allocate(); + act2_out.allocator()->allocate(); + norm2_out.allocator()->allocate(); + pool2_out.allocator()->allocate(); + conv3_out.allocator()->allocate(); + act3_out.allocator()->allocate(); + conv4_out.allocator()->allocate(); + act4_out.allocator()->allocate(); + conv5_out.allocator()->allocate(); + act5_out.allocator()->allocate(); + pool5_out.allocator()->allocate(); + fc6_out.allocator()->allocate(); + act6_out.allocator()->allocate(); + fc7_out.allocator()->allocate(); + act7_out.allocator()->allocate(); + fc8_out.allocator()->allocate(); + } + + /** Fills the trainable parameters and input with random data. */ + void fill_random() + { + library->fill_tensor_uniform(Accessor(input), 0); + + if(!_reshaped_weights) + { + for(unsigned int i = 0; i < w.size(); ++i) + { + library->fill_tensor_uniform(Accessor(w[i]), i + 1); + library->fill_tensor_uniform(Accessor(b[i]), i + 10); + } + } + else + { + library->fill_tensor_uniform(Accessor(w[0]), 1); + library->fill_tensor_uniform(Accessor(w[2]), 2); + + library->fill_tensor_uniform(Accessor(w[5]), 3); + library->fill_tensor_uniform(Accessor(b[5]), 4); + library->fill_tensor_uniform(Accessor(w[6]), 5); + library->fill_tensor_uniform(Accessor(b[6]), 6); + library->fill_tensor_uniform(Accessor(w[7]), 7); + library->fill_tensor_uniform(Accessor(b[7]), 8); + + library->fill_tensor_uniform(Accessor(*dynamic_cast<TensorType *>(w21.get())), 9); + library->fill_tensor_uniform(Accessor(*dynamic_cast<TensorType *>(w22.get())), 10); + library->fill_tensor_uniform(Accessor(*dynamic_cast<TensorType *>(w41.get())), 11); + library->fill_tensor_uniform(Accessor(*dynamic_cast<TensorType *>(w42.get())), 12); + library->fill_tensor_uniform(Accessor(*dynamic_cast<TensorType *>(w51.get())), 13); + library->fill_tensor_uniform(Accessor(*dynamic_cast<TensorType *>(w52.get())), 14); + } + } + +#ifdef INTERNAL_ONLY + /** Fills the trainable parameters from binary files + * + * @param weights Files names containing the weights data + * @param biases Files names containing the bias data + */ + void fill(std::vector<std::string> weights, std::vector<std::string> biases) + { + ARM_COMPUTE_ERROR_ON(weights.size() != w.size()); + ARM_COMPUTE_ERROR_ON(biases.size() != b.size()); + ARM_COMPUTE_ERROR_ON(_reshaped_weights); + + for(unsigned int i = 0; i < weights.size(); ++i) + { + library->fill_layer_data(Accessor(w[i]), weights[i]); + library->fill_layer_data(Accessor(b[i]), biases[i]); + } + } + + /** Feed input to network from file. + * + * @param name File name of containing the input data. + */ + void feed(std::string name) + { + library->fill_layer_data(Accessor(input), name); + } +#endif /* INTERNAL_ONLY */ + + /** Get the classification results. + * + * @return Vector containing the classified labels + */ + std::vector<unsigned int> get_classifications() + { + std::vector<unsigned int> classified_labels; + Accessor output_accessor(output); + + Window window; + window.set(Window::DimX, Window::Dimension(0, 1, 1)); + for(unsigned int d = 1; d < output_accessor.shape().num_dimensions(); ++d) + { + window.set(d, Window::Dimension(0, output_accessor.shape()[d], 1)); + } + + execute_window_loop(window, [&](const Coordinates & id) + { + int max_idx = 0; + float val = 0; + const void *const out_ptr = output_accessor(id); + for(unsigned int l = 0; l < output_accessor.shape().x(); ++l) + { + float curr_val = reinterpret_cast<const float *>(out_ptr)[l]; + if(curr_val > val) + { + max_idx = l; + val = curr_val; + } + } + classified_labels.push_back(max_idx); + }); + return classified_labels; + } + + /** Clear all allocated memory from the tensor objects */ + void clear() + { + // Free allocations + input.allocator()->free(); + output.allocator()->free(); + + if(!_reshaped_weights) + { + for(auto &wi : w) + { + wi.allocator()->free(); + } + + for(auto &bi : b) + { + bi.allocator()->free(); + } + } + else + { + w[0].allocator()->free(); + w[2].allocator()->free(); + w[5].allocator()->free(); + w[6].allocator()->free(); + w[7].allocator()->free(); + + b[5].allocator()->free(); + b[6].allocator()->free(); + b[7].allocator()->free(); + } + + w21.reset(); + w22.reset(); + b21.reset(); + b21.reset(); + w41.reset(); + w42.reset(); + b41.reset(); + b42.reset(); + w51.reset(); + w52.reset(); + b51.reset(); + b52.reset(); + + conv1_out.allocator()->free(); + act1_out.allocator()->free(); + norm1_out.allocator()->free(); + pool1_out.allocator()->free(); + conv2_out.allocator()->free(); + act2_out.allocator()->free(); + norm2_out.allocator()->free(); + pool2_out.allocator()->free(); + conv3_out.allocator()->free(); + act3_out.allocator()->free(); + conv4_out.allocator()->free(); + act4_out.allocator()->free(); + conv5_out.allocator()->free(); + act5_out.allocator()->free(); + pool5_out.allocator()->free(); + fc6_out.allocator()->free(); + act6_out.allocator()->free(); + fc7_out.allocator()->free(); + act7_out.allocator()->free(); + fc8_out.allocator()->free(); + } + + /** Runs the model */ + void run() + { + // Layer 1 + conv1.run(); + act1.run(); + norm1.run(); + pool1.run(); + // Layer 2 + conv21.run(); + conv22.run(); + act2.run(); + norm2.run(); + pool2.run(); + // Layer 3 + conv3.run(); + act3.run(); + // Layer 4 + conv41.run(); + conv42.run(); + act4.run(); + // Layer 5 + conv51.run(); + conv52.run(); + act5.run(); + pool5.run(); + // Layer 6 + fc6.run(); + act6.run(); + // Layer 7 + fc7.run(); + act7.run(); + // Layer 8 + fc8.run(); + // Softmax + smx.run(); + } + +private: + void init_weights() + { + w[0].allocator()->init(TensorInfo(TensorShape(11U, 11U, 3U, 96U), 1, _data_type, _fixed_point_position)); + b[0].allocator()->init(TensorInfo(TensorShape(96U), 1, _data_type, _fixed_point_position)); + w[1].allocator()->init(TensorInfo(TensorShape(5U, 5U, 48U, 256U), 1, _data_type, _fixed_point_position)); + b[1].allocator()->init(TensorInfo(TensorShape(256U), 1, _data_type, _fixed_point_position)); + w[2].allocator()->init(TensorInfo(TensorShape(3U, 3U, 256U, 384U), 1, _data_type, _fixed_point_position)); + b[2].allocator()->init(TensorInfo(TensorShape(384U), 1, _data_type, _fixed_point_position)); + w[3].allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 384U), 1, _data_type, _fixed_point_position)); + b[3].allocator()->init(TensorInfo(TensorShape(384U), 1, _data_type, _fixed_point_position)); + w[4].allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 256U), 1, _data_type, _fixed_point_position)); + b[4].allocator()->init(TensorInfo(TensorShape(256U), 1, _data_type, _fixed_point_position)); + w[5].allocator()->init(TensorInfo(TensorShape(9216U, 4096U), 1, _data_type, _fixed_point_position)); + b[5].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); + w[6].allocator()->init(TensorInfo(TensorShape(4096U, 4096U), 1, _data_type, _fixed_point_position)); + b[6].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); + w[7].allocator()->init(TensorInfo(TensorShape(4096U, 1000U), 1, _data_type, _fixed_point_position)); + b[7].allocator()->init(TensorInfo(TensorShape(1000U), 1, _data_type, _fixed_point_position)); + + w21 = std::unique_ptr<SubTensorType>(new SubTensorType(&w[1], TensorShape(5U, 5U, 48U, 128U), Coordinates())); + w22 = std::unique_ptr<SubTensorType>(new SubTensorType(&w[1], TensorShape(5U, 5U, 48U, 128U), Coordinates(0, 0, 0, 128))); + b21 = std::unique_ptr<SubTensorType>(new SubTensorType(&b[1], TensorShape(128U), Coordinates())); + b22 = std::unique_ptr<SubTensorType>(new SubTensorType(&b[1], TensorShape(128U), Coordinates(128))); + + w41 = std::unique_ptr<SubTensorType>(new SubTensorType(&w[3], TensorShape(3U, 3U, 192U, 192U), Coordinates())); + w42 = std::unique_ptr<SubTensorType>(new SubTensorType(&w[3], TensorShape(3U, 3U, 192U, 192U), Coordinates(0, 0, 0, 192))); + b41 = std::unique_ptr<SubTensorType>(new SubTensorType(&b[3], TensorShape(192U), Coordinates())); + b42 = std::unique_ptr<SubTensorType>(new SubTensorType(&b[3], TensorShape(192U), Coordinates(192))); + + w51 = std::unique_ptr<SubTensorType>(new SubTensorType(&w[4], TensorShape(3U, 3U, 192U, 128U), Coordinates())); + w52 = std::unique_ptr<SubTensorType>(new SubTensorType(&w[4], TensorShape(3U, 3U, 192U, 128U), Coordinates(0, 0, 0, 128))); + b51 = std::unique_ptr<SubTensorType>(new SubTensorType(&b[4], TensorShape(128U), Coordinates())); + b52 = std::unique_ptr<SubTensorType>(new SubTensorType(&b[4], TensorShape(128U), Coordinates(128))); + } + + void init_reshaped_weights() + { + const unsigned int data_type_size = 16 / arm_compute::data_size_from_type(_data_type); + + // Create tensor for the reshaped weights + auto w21_tensor = std::unique_ptr<TensorType>(new TensorType()); + auto w22_tensor = std::unique_ptr<TensorType>(new TensorType()); + auto w41_tensor = std::unique_ptr<TensorType>(new TensorType()); + auto w42_tensor = std::unique_ptr<TensorType>(new TensorType()); + auto w51_tensor = std::unique_ptr<TensorType>(new TensorType()); + auto w52_tensor = std::unique_ptr<TensorType>(new TensorType()); + + w[0].allocator()->init(TensorInfo(TensorShape(366U * data_type_size, 96U / data_type_size), 1, _data_type, _fixed_point_position)); + w21_tensor->allocator()->init(TensorInfo(TensorShape(1248U * data_type_size, 128U / data_type_size), 1, _data_type, _fixed_point_position)); + w22_tensor->allocator()->init(TensorInfo(TensorShape(1248U * data_type_size, 128U / data_type_size), 1, _data_type, _fixed_point_position)); + w[2].allocator()->init(TensorInfo(TensorShape(2560U * data_type_size, 384U / data_type_size), 1, _data_type, _fixed_point_position)); + w41_tensor->allocator()->init(TensorInfo(TensorShape(1920U * data_type_size, 192U / data_type_size), 1, _data_type, _fixed_point_position)); + w42_tensor->allocator()->init(TensorInfo(TensorShape(1920U * data_type_size, 192U / data_type_size), 1, _data_type, _fixed_point_position)); + w51_tensor->allocator()->init(TensorInfo(TensorShape(1920U * data_type_size, 128U / data_type_size), 1, _data_type, _fixed_point_position)); + w52_tensor->allocator()->init(TensorInfo(TensorShape(1920U * data_type_size, 128U / data_type_size), 1, _data_type, _fixed_point_position)); + + w21 = std::move(w21_tensor); + w22 = std::move(w22_tensor); + w41 = std::move(w41_tensor); + w42 = std::move(w42_tensor); + w51 = std::move(w51_tensor); + w52 = std::move(w52_tensor); + + b[5].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); + b[6].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); + b[7].allocator()->init(TensorInfo(TensorShape(1000U), 1, _data_type, _fixed_point_position)); + + if(_batches > 1) + { + w[5].allocator()->init(TensorInfo(TensorShape(9216U * data_type_size, 4096U / data_type_size), 1, _data_type, _fixed_point_position)); + w[6].allocator()->init(TensorInfo(TensorShape(4096U * data_type_size, 4096U / data_type_size), 1, _data_type, _fixed_point_position)); + w[7].allocator()->init(TensorInfo(TensorShape(4096U * data_type_size, 1000U / data_type_size), 1, _data_type, _fixed_point_position)); + } + else + { + w[5].allocator()->init(TensorInfo(TensorShape(4096U, 9216U), 1, _data_type, _fixed_point_position)); + w[6].allocator()->init(TensorInfo(TensorShape(4096U, 4096U), 1, _data_type, _fixed_point_position)); + w[7].allocator()->init(TensorInfo(TensorShape(1000U, 4096U), 1, _data_type, _fixed_point_position)); + } + } + + DataType _data_type{ DataType::UNKNOWN }; + int _fixed_point_position{ 0 }; + unsigned int _batches{ 0 }; + bool _reshaped_weights{ false }; + + ActivationLayerFunction act1{}, act2{}, act3{}, act4{}, act5{}, act6{}, act7{}; + ConvolutionLayerFunction conv1{}, conv21{}, conv22{}, conv3{}, conv41{}, conv42{}, conv51{}, conv52{}; + FullyConnectedLayerFunction fc6{}, fc7{}, fc8{}; + NormalizationLayerFunction norm1{}, norm2{}; + PoolingLayerFunction pool1{}, pool2{}, pool5{}; + SoftmaxLayerFunction smx{}; + + TensorType input{}, output{}; + std::array<TensorType, 8> w{ {} }, b{ {} }; + std::unique_ptr<ITensorType> w21{ nullptr }, w22{ nullptr }, b21{ nullptr }, b22{ nullptr }; + std::unique_ptr<ITensorType> w41{ nullptr }, w42{ nullptr }, b41{ nullptr }, b42{ nullptr }; + std::unique_ptr<ITensorType> w51{ nullptr }, w52{ nullptr }, b51{ nullptr }, b52{ nullptr }; + + TensorType conv1_out{}, act1_out{}, norm1_out{}, pool1_out{}; + TensorType conv2_out{}, act2_out{}, pool2_out{}, norm2_out{}; + TensorType conv3_out{}, act3_out{}; + TensorType conv4_out{}, act4_out{}; + TensorType conv5_out{}, act5_out{}, pool5_out{}; + TensorType fc6_out{}, act6_out{}; + TensorType fc7_out{}, act7_out{}; + TensorType fc8_out{}; + + std::unique_ptr<SubTensorType> pool11_out{}, pool12_out{}; + std::unique_ptr<SubTensorType> conv21_out{}, conv22_out{}; + std::unique_ptr<SubTensorType> act31_out{}, act32_out{}; + std::unique_ptr<SubTensorType> conv41_out{}, conv42_out{}, act41_out{}, act42_out{}; + std::unique_ptr<SubTensorType> conv51_out{}, conv52_out{}; +}; +} // namespace networks +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ diff --git a/tests/networks_new/LeNet5Network.h b/tests/networks_new/LeNet5Network.h new file mode 100644 index 0000000000..17421d9047 --- /dev/null +++ b/tests/networks_new/LeNet5Network.h @@ -0,0 +1,255 @@ +/* + * 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_MODEL_OBJECTS_LENET5_H__ +#define __ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ + +#include "Globals.h" +#include "TensorLibrary.h" +#include "Utils.h" + +#include <memory> + +using namespace arm_compute; +using namespace arm_compute::test; + +namespace arm_compute +{ +namespace test +{ +namespace networks +{ +/** Lenet5 model object */ +template <typename TensorType, + typename Accessor, + typename ActivationLayerFunction, + typename ConvolutionLayerFunction, + typename FullyConnectedLayerFunction, + typename PoolingLayerFunction, + typename SoftmaxLayerFunction> +class LeNet5Network +{ +public: + void init(int batches) + { + _batches = batches; + + // Initialize input, output, weights and biases + input.allocator()->init(TensorInfo(TensorShape(28U, 28U, 1U, _batches), 1, DataType::F32)); + output.allocator()->init(TensorInfo(TensorShape(10U, _batches), 1, DataType::F32)); + w[0].allocator()->init(TensorInfo(TensorShape(5U, 5U, 1U, 20U), 1, DataType::F32)); + b[0].allocator()->init(TensorInfo(TensorShape(20U), 1, DataType::F32)); + w[1].allocator()->init(TensorInfo(TensorShape(5U, 5U, 20U, 50U), 1, DataType::F32)); + b[1].allocator()->init(TensorInfo(TensorShape(50U), 1, DataType::F32)); + w[2].allocator()->init(TensorInfo(TensorShape(800U, 500U), 1, DataType::F32)); + b[2].allocator()->init(TensorInfo(TensorShape(500U), 1, DataType::F32)); + w[3].allocator()->init(TensorInfo(TensorShape(500U, 10U), 1, DataType::F32)); + b[3].allocator()->init(TensorInfo(TensorShape(10U), 1, DataType::F32)); + } + + /** Build the model. */ + void build() + { + // Initialize intermediate tensors + // Layer 1 + conv1_out.allocator()->init(TensorInfo(TensorShape(24U, 24U, 20U, _batches), 1, DataType::F32)); + pool1_out.allocator()->init(TensorInfo(TensorShape(12U, 12U, 20U, _batches), 1, DataType::F32)); + // Layer 2 + conv2_out.allocator()->init(TensorInfo(TensorShape(8U, 8U, 50U, _batches), 1, DataType::F32)); + pool2_out.allocator()->init(TensorInfo(TensorShape(4U, 4U, 50U, _batches), 1, DataType::F32)); + // Layer 3 + fc1_out.allocator()->init(TensorInfo(TensorShape(500U, _batches), 1, DataType::F32)); + act1_out.allocator()->init(TensorInfo(TensorShape(500U, _batches), 1, DataType::F32)); + // Layer 6 + fc2_out.allocator()->init(TensorInfo(TensorShape(10U, _batches), 1, DataType::F32)); + + // Configure Layers + conv1.configure(&input, &w[0], &b[0], &conv1_out, PadStrideInfo(1, 1, 0, 0)); + pool1.configure(&conv1_out, &pool1_out, PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); + conv2.configure(&pool1_out, &w[1], &b[1], &conv2_out, PadStrideInfo(1, 1, 0, 0)); + pool2.configure(&conv2_out, &pool2_out, PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); + fc1.configure(&pool2_out, &w[2], &b[2], &fc1_out); + act1.configure(&fc1_out, &act1_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + fc2.configure(&act1_out, &w[3], &b[3], &fc2_out); + smx.configure(&fc2_out, &output); + } + + void allocate() + { + // Allocate tensors + input.allocator()->allocate(); + output.allocator()->allocate(); + for(auto &wi : w) + { + wi.allocator()->allocate(); + } + for(auto &bi : b) + { + bi.allocator()->allocate(); + } + conv1_out.allocator()->allocate(); + pool1_out.allocator()->allocate(); + conv2_out.allocator()->allocate(); + pool2_out.allocator()->allocate(); + fc1_out.allocator()->allocate(); + act1_out.allocator()->allocate(); + fc2_out.allocator()->allocate(); + } + + /** Fills the trainable parameters and input with random data. */ + void fill_random() + { + std::uniform_real_distribution<> distribution(-1, 1); + library->fill(Accessor(input), distribution, 0); + for(unsigned int i = 0; i < w.size(); ++i) + { + library->fill(Accessor(w[i]), distribution, i + 1); + library->fill(Accessor(b[i]), distribution, i + 10); + } + } + +#ifdef INTERNAL_ONLY + /** Fills the trainable parameters from binary files + * + * @param weights Files names containing the weights data + * @param biases Files names containing the bias data + */ + void fill(std::vector<std::string> weights, std::vector<std::string> biases) + { + ARM_COMPUTE_ERROR_ON(weights.size() != w.size()); + ARM_COMPUTE_ERROR_ON(biases.size() != b.size()); + + for(unsigned int i = 0; i < weights.size(); ++i) + { + library->fill_layer_data(Accessor(w[i]), weights[i]); + library->fill_layer_data(Accessor(b[i]), biases[i]); + } + } + + /** Feed input to network from file. + * + * @param name File name of containing the input data. + */ + void feed(std::string name) + { + library->fill_layer_data(Accessor(input), name); + } +#endif /* INTERNAL_ONLY */ + + /** Get the classification results. + * + * @return Vector containing the classified labels + */ + std::vector<unsigned int> get_classifications() + { + std::vector<unsigned int> classified_labels; + Accessor output_accessor(output); + + Window window; + window.set(Window::DimX, Window::Dimension(0, 1, 1)); + for(unsigned int d = 1; d < output_accessor.shape().num_dimensions(); ++d) + { + window.set(d, Window::Dimension(0, output_accessor.shape()[d], 1)); + } + + execute_window_loop(window, [&](const Coordinates & id) + { + int max_idx = 0; + float val = 0; + const void *const out_ptr = output_accessor(id); + for(unsigned int l = 0; l < output_accessor.shape().x(); ++l) + { + float curr_val = reinterpret_cast<const float *>(out_ptr)[l]; + if(curr_val > val) + { + max_idx = l; + val = curr_val; + } + } + classified_labels.push_back(max_idx); + }); + return classified_labels; + } + + /** Clear all allocated memory from the tensor objects */ + void clear() + { + input.allocator()->free(); + output.allocator()->free(); + for(auto &wi : w) + { + wi.allocator()->free(); + } + for(auto &bi : b) + { + bi.allocator()->free(); + } + + conv1_out.allocator()->free(); + pool1_out.allocator()->free(); + conv2_out.allocator()->free(); + pool2_out.allocator()->free(); + fc1_out.allocator()->free(); + act1_out.allocator()->free(); + fc2_out.allocator()->free(); + } + + /** Runs the model */ + void run() + { + // Layer 1 + conv1.run(); + pool1.run(); + // Layer 2 + conv2.run(); + pool2.run(); + // Layer 3 + fc1.run(); + act1.run(); + // Layer 4 + fc2.run(); + // Softmax + smx.run(); + } + +private: + unsigned int _batches{ 0 }; + + ActivationLayerFunction act1{}; + ConvolutionLayerFunction conv1{}, conv2{}; + FullyConnectedLayerFunction fc1{}, fc2{}; + PoolingLayerFunction pool1{}, pool2{}; + SoftmaxLayerFunction smx{}; + + TensorType input{}, output{}; + std::array<TensorType, 4> w{ {} }, b{ {} }; + + TensorType conv1_out{}, pool1_out{}; + TensorType conv2_out{}, pool2_out{}; + TensorType fc1_out{}, act1_out{}; + TensorType fc2_out{}; +}; +} // namespace networks +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ |