From 277a23b8e42740ddfa4d687d4af8b0e1d1b9eedc Mon Sep 17 00:00:00 2001 From: Andrew Kwangwoong Park Date: Sat, 18 Sep 2021 03:12:53 +0900 Subject: [PATCH] [GPU] Update debug config verbose option to show the name of tensors allocated (#7407) Signed-off-by: Andrew Kwangwoong Park --- .../src/cldnn_engine/cldnn_infer_request.cpp | 9 +++++++++ .../src/cldnn_engine/ops/constant.cpp | 5 +++++ .../src/cldnn_engine/ops/ctc_greedy_decoder.cpp | 5 +++++ .../src/cldnn_engine/ops/non_max_suppression.cpp | 8 ++++++++ .../src/cldnn_engine/ops/proposal.cpp | 5 +++++ inference-engine/src/cldnn_engine/ops/topk.cpp | 5 +++++ .../api/cldnn/runtime/debug_configuration.hpp | 2 +- .../thirdparty/clDNN/runtime/memory_pool.cpp | 9 +++++++++ .../clDNN/src/impls/ocl/primitive_base.hpp | 9 +++++++++ .../thirdparty/clDNN/src/primitive_inst.cpp | 15 ++++++++++++++- inference-engine/thirdparty/clDNN/src/program.cpp | 4 ++++ 11 files changed, 74 insertions(+), 2 deletions(-) diff --git a/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp b/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp index 9a55217975c..6c0e2527eac 100644 --- a/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_infer_request.cpp @@ -12,6 +12,7 @@ #include "cldnn_remote_context.h" #include "cldnn_executable_network.h" #include "cldnn_itt.h" +#include "cldnn/runtime/debug_configuration.hpp" #include #include @@ -622,6 +623,10 @@ void CLDNNInferRequest::allocate_inputs() { IE_THROW() << "Input layout for " << name << " is not found"; } + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << name << ": input blob]" << std::endl; + } if (desc.getPrecision() == Precision::I16 || desc.getPrecision() == Precision::U16) { TensorDesc desc_fp32 = desc; desc_fp32.setPrecision(Precision::FP32); @@ -673,6 +678,10 @@ void CLDNNInferRequest::allocate_outputs() { const cldnn::layout output_layout = m_graph->GetNetwork()->get_output_memory(outputID)->get_layout(); const TensorDesc& desc = no.second->getTensorDesc(); + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << no.first << ": output blob]" << std::endl; + } auto blobPtr = create_device_blob(desc, output_layout); _deviceOutputs[no.first] = blobPtr; _outputs[no.first] = blobPtr; diff --git a/inference-engine/src/cldnn_engine/ops/constant.cpp b/inference-engine/src/cldnn_engine/ops/constant.cpp index 5f28cd2e602..58bc0a18d4a 100644 --- a/inference-engine/src/cldnn_engine/ops/constant.cpp +++ b/inference-engine/src/cldnn_engine/ops/constant.cpp @@ -18,6 +18,7 @@ #include "ngraph/op/util/op_types.hpp" #include "cldnn/primitives/data.hpp" +#include "cldnn/runtime/debug_configuration.hpp" namespace CLDNNPlugin { @@ -169,6 +170,10 @@ void CreateConstantOp(Program& p, const std::shared_ptrsecond; } else { + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << initialconstPrimID << ": constant]" << std::endl; + } cldnn::memory::ptr mem = p.GetEngine().allocate_memory(constLayout, false); auto& stream = p.GetEngine().get_program_stream(); cldnn::mem_lock lock{mem, stream}; diff --git a/inference-engine/src/cldnn_engine/ops/ctc_greedy_decoder.cpp b/inference-engine/src/cldnn_engine/ops/ctc_greedy_decoder.cpp index 7dde9c8b92a..4ff72462a47 100644 --- a/inference-engine/src/cldnn_engine/ops/ctc_greedy_decoder.cpp +++ b/inference-engine/src/cldnn_engine/ops/ctc_greedy_decoder.cpp @@ -11,6 +11,7 @@ #include "cldnn/primitives/ctc_greedy_decoder.hpp" #include "cldnn/primitives/reorder.hpp" #include "cldnn/primitives/mutable_data.hpp" +#include "cldnn/runtime/debug_configuration.hpp" #include "transformations/utils/utils.hpp" @@ -73,6 +74,10 @@ void CreateCommonCTCGreedyDecoderOp(Program& p, const std::shared_ptrget_output_shape(1).size()), CldnnTensorFromIEDims(op->get_output_shape(1))); + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << layer_type_name_ID(op) << ": mutable data]" << std::endl; + } shared_memory.emplace_back(p.GetEngine().allocate_memory(mutableLayout)); cldnn::primitive_id ctc_gd_mutable_id_w = layer_type_name_ID(op) + "_md_write"; diff --git a/inference-engine/src/cldnn_engine/ops/non_max_suppression.cpp b/inference-engine/src/cldnn_engine/ops/non_max_suppression.cpp index df34657d6cb..b5c2e05e711 100644 --- a/inference-engine/src/cldnn_engine/ops/non_max_suppression.cpp +++ b/inference-engine/src/cldnn_engine/ops/non_max_suppression.cpp @@ -12,6 +12,7 @@ #include "cldnn/primitives/reorder.hpp" #include "cldnn/primitives/mutable_data.hpp" #include "cldnn/primitives/non_max_suppression.hpp" +#include "cldnn/runtime/debug_configuration.hpp" namespace CLDNNPlugin { @@ -66,6 +67,7 @@ void CreateNonMaxSuppressionIEInternalOp(Program& p, const std::shared_ptrget_output_size(); std::vector shared_memory; + GPU_DEBUG_GET_INSTANCE(debug_config); switch (num_output) { case 3: { auto mutable_precision_second = op->get_output_element_type(2); @@ -77,6 +79,9 @@ void CreateNonMaxSuppressionIEInternalOp(Program& p, const std::shared_ptrget_output_shape(2).size()), CldnnTensorFromIEDims(op->get_output_shape(2))); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << layer_type_name_ID(op) << ": mutable data]" << std::endl; + } shared_memory.emplace_back(p.GetEngine().allocate_memory(mutableLayoutSecond)); cldnn::primitive_id non_max_supression_mutable_id_w_second = layer_type_name_ID(op) + "_md_write_second"; @@ -95,6 +100,9 @@ void CreateNonMaxSuppressionIEInternalOp(Program& p, const std::shared_ptr(outputIndices), 3, 1, 1)); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << layer_type_name_ID(op) << ": mutable data]" << std::endl; + } shared_memory.emplace_back(p.GetEngine().allocate_memory(mutableLayoutFirst)); cldnn::primitive_id non_max_supression_mutable_id_w_first = layer_type_name_ID(op) + "_md_write_first"; diff --git a/inference-engine/src/cldnn_engine/ops/proposal.cpp b/inference-engine/src/cldnn_engine/ops/proposal.cpp index 34677bd82ab..9be2f1d4e99 100644 --- a/inference-engine/src/cldnn_engine/ops/proposal.cpp +++ b/inference-engine/src/cldnn_engine/ops/proposal.cpp @@ -9,6 +9,7 @@ #include "cldnn/primitives/proposal.hpp" #include "cldnn/primitives/mutable_data.hpp" +#include "cldnn/runtime/debug_configuration.hpp" namespace CLDNNPlugin { @@ -62,6 +63,10 @@ void CreateProposalOp(Program& p, const std::shared_ptrget_output_shape(1).size()), CldnnTensorFromIEDims(op->get_output_shape(1))); + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << layer_type_name_ID(op) << ": mutable data]" << std::endl; + } auto shared_memory = p.GetEngine().allocate_memory(mutableLayout); cldnn::primitive_id proposal_mutable_id_w = layer_type_name_ID(op) + "_md_write"; diff --git a/inference-engine/src/cldnn_engine/ops/topk.cpp b/inference-engine/src/cldnn_engine/ops/topk.cpp index 20637b4eb58..fe9ae95550b 100644 --- a/inference-engine/src/cldnn_engine/ops/topk.cpp +++ b/inference-engine/src/cldnn_engine/ops/topk.cpp @@ -9,6 +9,7 @@ #include "cldnn/primitives/arg_max_min.hpp" #include "cldnn/primitives/mutable_data.hpp" +#include "cldnn/runtime/debug_configuration.hpp" namespace CLDNNPlugin { @@ -71,6 +72,10 @@ void CreateTopKOp(Program& p, const std::shared_ptr& op) { DefaultFormatForDims(op->get_output_shape(1).size()), CldnnTensorFromIEDims(op->get_output_shape(1))); + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << layer_type_name_ID(op) << ": mutable data]" << std::endl; + } auto shared_memory = p.GetEngine().allocate_memory(mutableLayout); cldnn::primitive_id argmax_mutable_id_w = layer_type_name_ID(op) + "_md_write"; diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/debug_configuration.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/debug_configuration.hpp index c43abac85e3..357f290efdb 100644 --- a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/debug_configuration.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/debug_configuration.hpp @@ -12,7 +12,7 @@ #define GPU_DEBUG_IF(cond) if (0) #endif -#define GPU_DEBUG_COUT std::cout << debug_configuration::prefix +#define GPU_DEBUG_COUT std::cout << cldnn::debug_configuration::prefix // Macro below is inserted to avoid unused variable warning when GPU_DEBUG_CONFIG is OFF #define GPU_DEBUG_GET_INSTANCE(name) auto name = cldnn::debug_configuration::get_instance(); (void)(name); diff --git a/inference-engine/thirdparty/clDNN/runtime/memory_pool.cpp b/inference-engine/thirdparty/clDNN/runtime/memory_pool.cpp index 74351fda54e..30863de6aae 100644 --- a/inference-engine/thirdparty/clDNN/runtime/memory_pool.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/memory_pool.cpp @@ -9,6 +9,7 @@ #include "cldnn/runtime/memory.hpp" #include "cldnn/runtime/engine.hpp" #include "cldnn/runtime/memory_pool.hpp" +#include "cldnn/runtime/debug_configuration.hpp" #include #include @@ -136,6 +137,10 @@ memory::ptr memory_pool::get_from_non_padded_pool(const layout& layout, ++it; } } + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << id << ": output]" << std::endl; + } // didn't find anything for you? create new resource auto mem = alloc_memory(layout, type); { @@ -174,6 +179,10 @@ memory::ptr memory_pool::get_from_padded_pool(const layout& layout, memory_record({{id, network_id}}, mem, network_id, type)); return mem; } + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << id << ": output]" << std::endl; + } auto mem = alloc_memory(layout, type); std::list list = {memory_record({{id, network_id}}, mem, network_id, type)}; _padded_pool.emplace(layout, std::move(list)); diff --git a/inference-engine/thirdparty/clDNN/src/impls/ocl/primitive_base.hpp b/inference-engine/thirdparty/clDNN/src/impls/ocl/primitive_base.hpp index 4315156be13..8d44482a89b 100644 --- a/inference-engine/thirdparty/clDNN/src/impls/ocl/primitive_base.hpp +++ b/inference-engine/thirdparty/clDNN/src/impls/ocl/primitive_base.hpp @@ -9,6 +9,7 @@ #include "primitive_inst.h" #include "cldnn/graph/program.hpp" #include "cldnn/runtime/error_handler.hpp" +#include "cldnn/runtime/debug_configuration.hpp" #include "kernel_selector_helper.h" #include "cldnn/graph/network.hpp" #include "register.hpp" @@ -46,6 +47,10 @@ struct typed_primitive_impl_ocl : public typed_primitive_impl { _kernels.emplace_back(other._kernels[k]->clone()); } for (auto& mem : other._intermediates_memory) { + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << _kernel_data.params->layerID << ": internal buf]" << std::endl; + } auto& engine = _outer.get_program().get_engine(); auto new_mem = engine.allocate_memory(mem->get_layout(), mem->get_allocation_type()); _intermediates_memory.push_back(new_mem); @@ -75,6 +80,10 @@ struct typed_primitive_impl_ocl : public typed_primitive_impl { {1, 1, 1, (tensor::value_type)(size / bpp)}}; auto& eimpl = arg.get_program().get_engine(); + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << _kernel_data.params->layerID << ": internal buf]" << std::endl; + } _intermediates_memory.push_back(eimpl.allocate_memory(expected_layout)); } } diff --git a/inference-engine/thirdparty/clDNN/src/primitive_inst.cpp b/inference-engine/thirdparty/clDNN/src/primitive_inst.cpp index b6c65a5b739..dcaea49163a 100644 --- a/inference-engine/thirdparty/clDNN/src/primitive_inst.cpp +++ b/inference-engine/thirdparty/clDNN/src/primitive_inst.cpp @@ -15,6 +15,7 @@ #include "cldnn/runtime/memory.hpp" #include "cldnn/runtime/error_handler.hpp" +#include "cldnn/runtime/debug_configuration.hpp" #include "json_object.h" #include #include @@ -174,8 +175,11 @@ memory::ptr primitive_inst::allocate_output() { allocation_type alloc_type = use_lockable_memory ? engine.get_lockable_preffered_memory_allocation_type(layout.format.is_image_2d()) : allocation_type::usm_device; - + GPU_DEBUG_GET_INSTANCE(debug_config); if (!_network.is_internal() && (_node.can_be_optimized() || _node.is_type())) { + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << _node.id() << ": output]" << std::endl; + } return _network.get_memory_from_pool(layout, _node.id(), _node.get_memory_dependencies(), @@ -183,12 +187,21 @@ memory::ptr primitive_inst::allocate_output() { false); } else if (_network.is_internal() && _node.is_output() && _node.is_type() && engine.supports_allocation(allocation_type::usm_device)) { + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << _node.id() << ": output]" << std::endl; + } return engine.allocate_memory(layout, allocation_type::usm_device, false); } else if (_network.is_internal() && !_node.is_output() && _node.is_type()) { // Skip memory reset for input_layout primitives, since data will be copied from cldnn::data primitive // or just reuse primitive's memory + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << _node.id() << ": constant]" << std::endl; + } return engine.allocate_memory(layout, alloc_type, false); } else if (_network.is_internal() || (!_node.can_share_buffer()) || _node.can_be_optimized() || _node.is_output()) { + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << _node.id() << ": output]" << std::endl; + } return engine.allocate_memory(layout, alloc_type); } else { return _network.get_memory_from_pool(layout, diff --git a/inference-engine/thirdparty/clDNN/src/program.cpp b/inference-engine/thirdparty/clDNN/src/program.cpp index 1d576d3399e..6ce6b875e2e 100644 --- a/inference-engine/thirdparty/clDNN/src/program.cpp +++ b/inference-engine/thirdparty/clDNN/src/program.cpp @@ -602,6 +602,10 @@ void program::transfer_memory_to_device() { if (alloc_type == allocation_type::usm_host || alloc_type == allocation_type::usm_shared) { + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + GPU_DEBUG_COUT << "[" << data_node.id() << ": constant]" << std::endl; + } // Allocate and transfer memory auto device_mem = mem.get_engine()->allocate_memory(data_node_layout, allocation_type::usm_device, false); device_mem->copy_from(get_stream(), mem);