Add debug config for forcing impl type of fc (#11713)

+ Added new debugging config OV_GPU_ForceImplType to set impl type

Signed-off-by: Min, Byungil <byungil.min@intel.com>
This commit is contained in:
Min, Byungil authored and GitHub committed 2022-06-06 23:02:34 +09:00
1 parent bb3868d8cd
commit 104a9d8d52
4 files changed
+28 -1

No files matched your search

@@ -40,6 +40,7 @@ public:
int base_batch_for_memory_estimation; // Base batch size to be used in memory estimation
std::vector<std::string> after_proc; // Start inference after the listed processes
int serialize_compile; // Serialize creating primitives and compiling kernels
std::string forced_impl_type; // Force implementation type either ocl or onednn
static const debug_configuration *get_instance();
bool is_dumped_layer(const std::string& layerName) const;
};
@@ -189,6 +189,7 @@ public:
bool all_users_simple_format_until_output(program_node& origin_node, program_node& cur_node, int32_t cur_depth, int32_t max_depth);
impl_types get_preferred_impl_type(program_node& node, format preferred_format);
impl_types get_forced_impl_type_by_config(program_node& node);
bool are_data_types_suitable_for_onednn(program_node& node);
bool are_layouts_suitable_for_onednn(program_node& node);
bool is_format_supported(program_node& node, format::type fmt);
@@ -6,6 +6,7 @@
#include "primitive_inst.h"
#include "program_helpers.h"
#include "intel_gpu/runtime/error_handler.hpp"
#include "intel_gpu/runtime/debug_configuration.hpp"
#include "data_inst.h"
#include "reorder_inst.h"
#include "resample_inst.h"
@@ -1330,6 +1331,22 @@ bool layout_optimizer::are_layouts_suitable_for_onednn(program_node& node) {
return true;
}
impl_types layout_optimizer::get_forced_impl_type_by_config(program_node& node) {
#ifdef GPU_DEBUG_CONFIG
GPU_DEBUG_GET_INSTANCE(debug_config);
GPU_DEBUG_IF(!debug_config->forced_impl_type.empty()) {
if (node.is_type<fully_connected>()) {
if (debug_config->forced_impl_type == "fc:ocl")
return impl_types::ocl;
else if (debug_config->forced_impl_type == "fc:onednn")
return impl_types::onednn;
}
}
#endif
return impl_types::any;
}
impl_types layout_optimizer::get_preferred_impl_type(program_node& node, format preferred_format) {
impl_types preferred_impl = impl_types::any;
if (!_forcing_map.empty() && _forcing_map.count(node.id()) != 0) {
@@ -1508,6 +1525,10 @@ impl_types layout_optimizer::get_preferred_impl_type(program_node& node, format
}
// TODO: uncomment this code when onednn gemm implementations will have real perf improvements vs cldnn
} else if (node.is_type<fully_connected>()/* || node.is_type<gemm>()*/) {
auto forced_impl = get_forced_impl_type_by_config(node);
if (forced_impl != impl_types::any)
return forced_impl;
if (!_optimization_attributes.use_onednn_impls)
return impl_types::ocl;
@@ -117,6 +117,8 @@ static void print_help_messages() {
message_list.emplace_back("OV_GPU_AfterProc", "Run inference after the specified process PIDs are finished, separated by space."
" Supported on only on linux.");
message_list.emplace_back("OV_GPU_SerialCompile", "Serialize creating primitives and compiling kernels");
message_list.emplace_back("OV_GPU_ForceImplType", "Force implementation type, either ocl or onednn, of a target primitive. [primitive]:[impl_type]"
" Currently, only fc:onednn and fc:cldnn are supported.");
auto max_name_length_item = std::max_element(message_list.begin(), message_list.end(),
[](std::pair<std::string, std::string>& a, std::pair<std::string, std::string>& b){
@@ -145,7 +147,8 @@ debug_configuration::debug_configuration()
, disable_onednn(0)
, dump_layers_limit_batch(std::numeric_limits<int>::max())
, base_batch_for_memory_estimation(-1)
, serialize_compile(0) {
, serialize_compile(0)
, forced_impl_type(std::string()) {
#ifdef GPU_DEBUG_CONFIG
get_gpu_debug_env_var("Help", help);
get_common_debug_env_var("Verbose", verbose);
@@ -164,6 +167,7 @@ debug_configuration::debug_configuration()
std::string after_proc_str;
get_gpu_debug_env_var("AfterProc", after_proc_str);
get_gpu_debug_env_var("SerialCompile", serialize_compile);
get_gpu_debug_env_var("ForceImplType", forced_impl_type);
if (help > 0) {
print_help_messages();