Skip to content

Commit

Permalink
[GPU] Fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-paramuzov committed Aug 3, 2021
1 parent 910323b commit ab8b87b
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 34 deletions.
6 changes: 0 additions & 6 deletions inference-engine/src/cldnn_engine/cldnn_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "ngraph/ops.hpp"
#include "ngraph_ops/nms_ie_internal.hpp"
#include "cldnn_itt.h"
#include "cldnn/runtime/debug_configuration.hpp"

using namespace InferenceEngine;
using namespace InferenceEngine::details;
Expand Down Expand Up @@ -178,16 +177,11 @@ std::shared_ptr<cldnn::program> Program::BuildProgram(const std::vector<std::sha
bool createTopologyOnly) {
OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "Program::BuildProgram");
cldnn::build_options options;
GPU_DEBUG_GET_INSTANCE(debug_config);

if (!m_config.graph_dumps_dir.empty()) {
options.set_option(cldnn::build_option::graph_dumps_dir(m_config.graph_dumps_dir));
}

GPU_DEBUG_IF(!debug_config->dump_graphs.empty()) {
options.set_option(cldnn::build_option::graph_dumps_dir(debug_config->dump_graphs));
}

options.set_option(cldnn::build_option::optimize_data(true));
options.set_option(cldnn::build_option::tuning_config(m_config.tuningConfig));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class primitive_inst;
struct network {
public:
using ptr = std::shared_ptr<network>;
explicit network(program::ptr program, stream::ptr stream, bool is_internal = false, bool is_primary_stream = false);
explicit network(program::ptr program, stream::ptr stream, bool is_internal = false, bool is_primary_stream = true);
network(engine& engine,
const topology& topo,
const build_options& options = build_options(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ struct program {
int32_t get_processing_number(program_node* node) const {
return get_processing_number(get_processing_iterator(*node));
}
// int32_t get_processing_number(const_iterator iter) const { return 1+(int32_t)std::distance(begin(), iter); }
int32_t get_processing_number(node_iterator iter) const {
return 1 + (int32_t)std::distance(_processing_order.begin(), const_iterator(iter));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class debug_configuration {
int print_multi_kernel_perf; // Print execution time of each kernel in multi-kernel primitimive
int disable_usm; // Disable usm usage
std::string dump_graphs; // Dump optimized graph
std::string dump_sources; // Dump opencl sources
std::string dump_layers_path; // Enable dumping intermediate buffers and set the dest path
std::string dump_layers; // Dump intermediate buffers of specified layers only, separated by space
int dump_layers_dst_only; // Dump only output of layers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ debug_configuration::debug_configuration()
, print_multi_kernel_perf(0)
, disable_usm(0)
, dump_graphs(std::string())
, dump_sources(std::string())
, dump_layers_path(std::string())
, dump_layers(std::string())
, dump_layers_dst_only(0) {
Expand All @@ -107,6 +108,7 @@ debug_configuration::debug_configuration()
get_gpu_debug_env_var("PrintMultiKernelPerf", print_multi_kernel_perf);
get_gpu_debug_env_var("DisableUsm", disable_usm);
get_gpu_debug_env_var("DumpGraphs", dump_graphs);
get_gpu_debug_env_var("DumpSources", dump_sources);
get_gpu_debug_env_var("DumpLayersPath", dump_layers_path);
get_gpu_debug_env_var("DumpLayers", dump_layers);
get_gpu_debug_env_var("DumpLayersDstOnly", dump_layers_dst_only);
Expand Down
10 changes: 8 additions & 2 deletions inference-engine/thirdparty/clDNN/runtime/kernels_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//

#include "kernels_factory.hpp"
#include "kernels_cache.hpp"
#include "ocl/ocl_engine.hpp"
#include "cldnn/runtime/kernels_cache.hpp"
#include "cldnn/runtime/debug_configuration.hpp"

#include <algorithm>
Expand Down Expand Up @@ -279,12 +279,18 @@ void kernels_cache::build_batch(const engine& build_engine, const batch_program&
auto& cl_build_engine = dynamic_cast<const ocl::ocl_engine&>(build_engine);

bool dump_sources = !_engine.configuration().sources_dumps_dir.empty() || batch.dump_custom_program;
std::string dump_sources_dir = _engine.configuration().sources_dumps_dir;
GPU_DEBUG_GET_INSTANCE(debug_config);
GPU_DEBUG_IF(!debug_config->dump_sources.empty()) {
dump_sources = true;
dump_sources_dir = debug_config->dump_sources;
}

std::string err_log; // accumulated build log from all program's parts (only contains messages from parts which

std::string current_dump_file_name = "";
if (dump_sources) {
current_dump_file_name = _engine.configuration().sources_dumps_dir;
current_dump_file_name = dump_sources_dir;
if (!current_dump_file_name.empty() && current_dump_file_name.back() != '/')
current_dump_file_name += '/';

Expand Down
2 changes: 1 addition & 1 deletion inference-engine/thirdparty/clDNN/src/gather_elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ std::string gather_elements_inst::to_string(gather_elements_node const& node) {
return primitive_description.str();
}

gather_elements_inst::typed_primitive_inst(network_impl& network, gather_elements_node const& node) : parent(network, node) {}
gather_elements_inst::typed_primitive_inst(network& network, gather_elements_node const& node) : parent(network, node) {}

} // namespace cldnn
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ struct typed_program_node<condition> : public typed_program_node_base<condition>
void set(const program_node& node) {
add_or_change_input_layout(node);
_program = program::build_program(node.get_program().get_engine(),
_topology,
node.get_program().get_options(),
true); // rebuild program
_topology,
node.get_program().get_options(),
true); // rebuild program
}
program::ptr get() const { return _program; }

private:
topology _topology;
program::ptr _program = (program::ptr) nullptr;
program::ptr _program = nullptr;

void add_or_change_input_layout(const program_node& node) {
auto layout = node.get_dependency(0).get_output_layout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class typed_primitive_inst<gather_elements> : public typed_primitive_inst_base<g
static std::string to_string(gather_elements_node const& node);

public:
typed_primitive_inst(network_impl& network, gather_elements_node const& desc);
typed_primitive_inst(network& network, gather_elements_node const& desc);
};

using gather_elements_inst = typed_primitive_inst<gather_elements>;
Expand Down
2 changes: 1 addition & 1 deletion inference-engine/thirdparty/clDNN/src/kernel_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////

#include "kernel_runner.h"
#include "cldnn/runtime/kernels_cache.hpp"
#include "runtime/kernels_cache.hpp"
#include "cldnn/runtime/stream.hpp"
#include "weight_bias_params.h"
#include "kernel_selector_helper.h"
Expand Down
24 changes: 12 additions & 12 deletions inference-engine/thirdparty/clDNN/src/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ network::network(program::ptr program, stream::ptr stream, bool is_internal, boo
validate_primitives();
}

network::network(engine& engine,
const topology& topo,
const build_options& options,
bool is_internal)
: network(program::build_program(engine, topo, options, is_internal), engine.create_stream(), is_internal) {}

network::network(engine& engine,
const std::set<std::shared_ptr<program_node>>& nodes,
const build_options& options,
bool is_internal)
: network(program::build_program(engine, nodes, options, is_internal), engine.create_stream(), is_internal) {}

network::network(program::ptr program, uint16_t stream_id)
: network(program, program->get_engine().create_stream(), false, stream_id ==0) {}

Expand Down Expand Up @@ -248,18 +260,6 @@ network::ptr network::build_network(engine& engine,
return std::make_shared<network>(engine, nodes, options, is_internal);
}

network::network(engine& engine,
const topology& topo,
const build_options& options,
bool is_internal)
: network(program::build_program(engine, topo, options, is_internal), engine.create_stream(), is_internal) {}

network::network(engine& engine,
const std::set<std::shared_ptr<program_node>>& nodes,
const build_options& options,
bool is_internal)
: network(program::build_program(engine, nodes, options, is_internal), engine.create_stream(), is_internal) {}

void network::validate_primitives() {
for (auto const& prim : _exec_order) {
bool valid = prim->validate();
Expand Down
16 changes: 11 additions & 5 deletions inference-engine/thirdparty/clDNN/src/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
///////////////////////////////////////////////////////////////////////////////////////////////////

#include "cldnn/runtime/error_handler.hpp"
#include "cldnn/runtime/kernels_cache.hpp"
#include "cldnn/runtime/memory.hpp"
#include "cldnn/runtime/engine.hpp"
#include "cldnn/runtime/debug_configuration.hpp"
#include "cldnn/graph/program.hpp"

#include "kernel_selector_helper.h"
#include "device_cache_reader.h"
#include "auto_tuner.h"
#include "layout_optimizer.h"
#include "pass_manager.h"
#include "primitive_type.h"
#include "program_dump_graph.h"
#include "cldnn/graph/program.hpp"
#include "sliding_window_utils.h"
#include "program_helpers.h"

Expand Down Expand Up @@ -57,13 +60,11 @@
#include "loop_inst.h"
#include "to_string_utils.h"
#include "runtime/cldnn_itt.hpp"
#include "runtime/kernels_cache.hpp"
#include "impls/ocl/register.hpp"
#include "impls/cpu/register.hpp"
#include "impls/common/register.hpp"

#include "cldnn/runtime/memory.hpp"
#include "cldnn/runtime/engine.hpp"

#include "kernel_base.h"

#include <algorithm>
Expand Down Expand Up @@ -401,6 +402,11 @@ void program::set_options() {
throw std::invalid_argument("Engine must be created with profiling enabled in tune_and_cache mode!");
}

GPU_DEBUG_GET_INSTANCE(debug_config);
GPU_DEBUG_IF(!debug_config->dump_graphs.empty()) {
options.set_option(cldnn::build_option::graph_dumps_dir(debug_config->dump_graphs));
}

if (!options.get<build_option_type::force_implementations>()->forcing.empty()) {
options.set_option(build_option::optimize_data(true));
}
Expand Down

0 comments on commit ab8b87b

Please sign in to comment.