From 050471e40fc58cb5ea745701a43ec5b2b9586b81 Mon Sep 17 00:00:00 2001 From: Vidhya Sudhan Loganathan Date: Thu, 25 Apr 2019 09:27:24 +0100 Subject: COMPMID-1974 : Extend CLTuner to support different of level of tuning Change-Id: I52e4a00a25e7f7a17050038cee7c30e508553722 Signed-off-by: Vidhya Sudhan Loganathan Reviewed-on: https://review.mlplatform.org/c/977 Comments-Addressed: Pablo Marquez Reviewed-by: Gian Marco Iodice Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- utils/CommonGraphOptions.cpp | 14 +++++++++++++- utils/CommonGraphOptions.h | 5 ++++- utils/TypePrinter.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/CommonGraphOptions.cpp b/utils/CommonGraphOptions.cpp index 4247b2d3e5..7334d038ba 100644 --- a/utils/CommonGraphOptions.cpp +++ b/utils/CommonGraphOptions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -83,6 +83,7 @@ namespace utils os << "Data type : " << common_params.data_type << std::endl; os << "Data layout : " << common_params.data_layout << std::endl; os << "Tuner enabled? : " << (common_params.enable_tuner ? true_str : false_str) << std::endl; + os << "Tuner mode : " << common_params.tuner_mode << std::endl; os << "Tuner file : " << common_params.tuner_file << std::endl; os << "Fast math enabled? : " << (common_params.fast_math_hint == FastMathHint::Enabled ? true_str : false_str) << std::endl; if(!common_params.data_path.empty()) @@ -117,6 +118,7 @@ CommonGraphOptions::CommonGraphOptions(CommandLineParser &parser) data_type(), data_layout(), enable_tuner(parser.add_option("enable-tuner")), + tuner_mode(), fast_math_hint(parser.add_option("fast-math")), data_path(parser.add_option>("data")), image(parser.add_option>("image")), @@ -146,9 +148,17 @@ CommonGraphOptions::CommonGraphOptions(CommandLineParser &parser) DataLayout::NCHW, }; + const std::set supported_tuner_modes + { + CLTunerMode::EXHAUSTIVE, + CLTunerMode::NORMAL, + CLTunerMode::RAPID + }; + target = parser.add_option>("target", supported_targets, Target::NEON); data_type = parser.add_option>("type", supported_data_types, DataType::F32); data_layout = parser.add_option>("layout", supported_data_layouts); + tuner_mode = parser.add_option>("tuner-mode", supported_tuner_modes, CLTunerMode::EXHAUSTIVE); help->set_help("Show this help message"); threads->set_help("Number of threads to use"); @@ -156,6 +166,7 @@ CommonGraphOptions::CommonGraphOptions(CommandLineParser &parser) data_type->set_help("Data type to use"); data_layout->set_help("Data layout to use"); enable_tuner->set_help("Enable OpenCL dynamic tuner"); + tuner_mode->set_help("Configures the time taken by the tuner to tune. Slow tuner produces the most performant LWS configuration"); fast_math_hint->set_help("Enable fast math"); data_path->set_help("Path where graph parameters reside"); image->set_help("Input image for the graph"); @@ -181,6 +192,7 @@ CommonGraphParams consume_common_graph_parameters(CommonGraphOptions &options) common_params.data_layout = options.data_layout->value(); } common_params.enable_tuner = options.enable_tuner->is_set() ? options.enable_tuner->value() : false; + common_params.tuner_mode = options.tuner_mode->value(); common_params.fast_math_hint = options.fast_math_hint->is_set() ? fast_math_hint_value : FastMathHint::Disabled; common_params.data_path = options.data_path->value(); common_params.image = options.image->value(); diff --git a/utils/CommonGraphOptions.h b/utils/CommonGraphOptions.h index 921889d7c7..d81cd8fbdb 100644 --- a/utils/CommonGraphOptions.h +++ b/utils/CommonGraphOptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -29,6 +29,7 @@ #include "arm_compute/graph/TypeLoader.h" #include "arm_compute/graph/TypePrinter.h" +#include "arm_compute/runtime/CL/CLTunerTypes.h" namespace arm_compute { @@ -93,6 +94,7 @@ struct CommonGraphParams arm_compute::DataType data_type{ DataType::F32 }; arm_compute::DataLayout data_layout{ DataLayout::NHWC }; bool enable_tuner{ false }; + arm_compute::CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; arm_compute::graph::FastMathHint fast_math_hint{ arm_compute::graph::FastMathHint::Disabled }; std::string data_path{}; std::string image{}; @@ -147,6 +149,7 @@ public: EnumOption *data_type; /**< Graph data type */ EnumOption *data_layout; /**< Graph data layout */ ToggleOption *enable_tuner; /**< Enable tuner */ + SimpleOption *tuner_mode; /**< Tuner mode */ ToggleOption *fast_math_hint; /**< Fast math hint */ SimpleOption *data_path; /**< Trainable parameters path */ SimpleOption *image; /**< Image */ diff --git a/utils/TypePrinter.h b/utils/TypePrinter.h index 70196882de..a71e03696a 100644 --- a/utils/TypePrinter.h +++ b/utils/TypePrinter.h @@ -34,6 +34,7 @@ #include "arm_compute/core/Strides.h" #include "arm_compute/core/TensorInfo.h" #include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTunerTypes.h" #include #include @@ -2218,6 +2219,49 @@ inline std::string to_string(const T &val) return support::cpp11::to_string(val); } +/** Convert a CLTunerMode value to a string + * + * @param val CLTunerMode value to be converted + * + * @return String representing the corresponding CLTunerMode. + */ +inline std::string to_string(const CLTunerMode val) +{ + switch(val) + { + case CLTunerMode::EXHAUSTIVE: + { + return std::string("Exhaustive"); + } + case CLTunerMode::NORMAL: + { + return std::string("Normal"); + } + case CLTunerMode::RAPID: + { + return std::string("Rapid"); + } + default: + { + ARM_COMPUTE_ERROR("Invalid tuner mode."); + return std::string("UNDEFINED"); + } + } +} +/** [Print CLTunerMode type] **/ +/** Formatted output of the CLTunerMode type. + * + * @param[out] os Output stream. + * @param[in] val CLTunerMode to output. + * + * @return Modified output stream. + */ +inline ::std::ostream &operator<<(::std::ostream &os, const CLTunerMode &val) +{ + os << to_string(val); + return os; +} + } // namespace arm_compute #endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */ -- cgit v1.2.1