Added input/output kernel dump support based on the config file

pull/7267/head
Adel Shafiei 4 years ago
parent 15b1725198
commit e4ebdc599e

@ -307,11 +307,6 @@ void DumpJsonParser::JudgeDumpEnabled() {
MS_EXCEPTION_IF_NULL(context); MS_EXCEPTION_IF_NULL(context);
if (context->get_param<std::string>(MS_CTX_DEVICE_TARGET) == kGPUDevice) { if (context->get_param<std::string>(MS_CTX_DEVICE_TARGET) == kGPUDevice) {
async_dump_enabled_ = false; async_dump_enabled_ = false;
// GPU not support dump kernel inputs
if (input_output_ != kDumpOutputOnly) {
MS_LOG(WARNING) << "Data dump only support dump kernel output when device target is GPU";
input_output_ = kDumpOutputOnly;
}
} }
if (context->get_param<std::string>(MS_CTX_DEVICE_TARGET) == kAscendDevice) { if (context->get_param<std::string>(MS_CTX_DEVICE_TARGET) == kAscendDevice) {

@ -102,11 +102,11 @@ void LoadKernelData(Debugger *debugger, const CNodePtr &kernel,
bool dump_enabled) { bool dump_enabled) {
// check if we should read the kernel data // check if we should read the kernel data
bool read_data = false; bool read_data = false;
auto &dump_json_parser = DumpJsonParser::GetInstance();
std::string kernel_name = kernel->fullname_with_scope(); std::string kernel_name = kernel->fullname_with_scope();
if (debugger) { if (debugger) {
debugger->SetCurNode(kernel_name); debugger->SetCurNode(kernel_name);
if (dump_enabled) { if (dump_enabled) {
auto &dump_json_parser = DumpJsonParser::GetInstance();
auto dump_mode = dump_json_parser.dump_mode(); auto dump_mode = dump_json_parser.dump_mode();
// dump the node if dump_mode is 0, which means all kernels, or if this kernel is in the kernels list // dump the node if dump_mode is 0, which means all kernels, or if this kernel is in the kernels list
if ((dump_mode == 0) || ((dump_mode == 1) && dump_json_parser.NeedDump(kernel_name))) { if ((dump_mode == 0) || ((dump_mode == 1) && dump_json_parser.NeedDump(kernel_name))) {
@ -120,6 +120,7 @@ void LoadKernelData(Debugger *debugger, const CNodePtr &kernel,
return; return;
} }
if (dump_json_parser.InputNeedDump()) {
// get inputs // get inputs
auto input_size = AnfAlgo::GetInputTensorNum(kernel); auto input_size = AnfAlgo::GetInputTensorNum(kernel);
for (size_t j = 0; j < input_size; ++j) { for (size_t j = 0; j < input_size; ++j) {
@ -140,7 +141,9 @@ void LoadKernelData(Debugger *debugger, const CNodePtr &kernel,
<< ", tensor_name:" << input_tensor_name << ", host_format:" << format << ".!"; << ", tensor_name:" << input_tensor_name << ", host_format:" << format << ".!";
} }
} }
}
if (dump_json_parser.OutputNeedDump()) {
// get outputs // get outputs
auto output_size = AnfAlgo::GetOutputTensorNum(kernel); auto output_size = AnfAlgo::GetOutputTensorNum(kernel);
auto node_name = AnfAlgo::GetCNodeName(kernel); auto node_name = AnfAlgo::GetCNodeName(kernel);
@ -165,6 +168,7 @@ void LoadKernelData(Debugger *debugger, const CNodePtr &kernel,
<< ", tensor_name:" << tensor_name << ", host_format:" << format << ".!"; << ", tensor_name:" << tensor_name << ", host_format:" << format << ".!";
} }
} }
}
debugger->PostExecuteNode(); debugger->PostExecuteNode();
} }

Loading…
Cancel
Save