From b5e70f72316b9a48a6d34e28a4febcc62e6c7cf4 Mon Sep 17 00:00:00 2001 From: John Tzanakakis Date: Thu, 6 May 2021 13:45:59 -0400 Subject: [PATCH] use device type in dump file name when trans_flag=false --- mindspore/ccsrc/debug/data_dump/e2e_dump.cc | 19 ++++++++++++------- mindspore/ccsrc/debug/data_dump/e2e_dump.h | 3 ++- mindspore/ccsrc/debug/debug_services.cc | 4 ++-- mindspore/ccsrc/debug/debug_services.h | 2 +- mindspore/ccsrc/debug/debugger/debugger.cc | 4 ++-- mindspore/ccsrc/debug/debugger/debugger.h | 2 +- mindspore/ccsrc/debug/tensor_load.h | 4 ++-- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/mindspore/ccsrc/debug/data_dump/e2e_dump.cc b/mindspore/ccsrc/debug/data_dump/e2e_dump.cc index 3f24b56ae68..5b12d8ad1a3 100644 --- a/mindspore/ccsrc/debug/data_dump/e2e_dump.cc +++ b/mindspore/ccsrc/debug/data_dump/e2e_dump.cc @@ -40,12 +40,13 @@ bool E2eDump::IsDeviceTargetGPU() { void E2eDump::DumpGPUMemToFile(const std::string &file_path, const std::string &original_kernel_name, NotNull addr, const ShapeVector &int_shapes, - const TypeId &type, bool trans_flag, size_t slot, const Debugger *debugger) { + const TypeId &host_type, const TypeId &device_type, bool trans_flag, size_t slot, + const Debugger *debugger) { #ifdef ENABLE_DEBUGGER auto format = kOpFormat_DEFAULT; MS_EXCEPTION_IF_NULL(debugger); - auto ret = debugger->DumpTensorToFile(original_kernel_name, trans_flag, file_path, format, int_shapes, type, - addr->type_id(), addr->format(), slot); + auto ret = debugger->DumpTensorToFile(original_kernel_name, trans_flag, file_path, format, int_shapes, host_type, + device_type, addr->format(), slot); if (!ret) { MS_LOG(ERROR) << "DumpTensorToFile Failed: flag:" << std::to_string(trans_flag) << ", path:" << file_path << ", host_format:" << format; @@ -86,10 +87,11 @@ void E2eDump::DumpOutputImpl(const CNodePtr &node, bool trans_flag, const std::s ShapeVector int_shapes; GetDumpIntShape(node, j, NOT_NULL(&int_shapes), trans_flag); auto type = AnfAlgo::GetOutputInferDataType(node, j); + auto device_type = AnfAlgo::GetOutputDeviceDataType(node, j); std::string file_path = dump_path + '/' + *kernel_name + '_' + "output_" + std::to_string(j); if (IsDeviceTargetGPU()) { - DumpGPUMemToFile(file_path, node->fullname_with_scope(), NOT_NULL(addr), int_shapes, type, trans_flag, j, - debugger); + DumpGPUMemToFile(file_path, node->fullname_with_scope(), NOT_NULL(addr), int_shapes, type, device_type, + trans_flag, j, debugger); } else { DumpMemToFile(file_path, NOT_NULL(addr), int_shapes, type, trans_flag); } @@ -145,9 +147,11 @@ void E2eDump::DumpInputImpl(const CNodePtr &node, bool trans_flag, const std::st ShapeVector int_shapes; GetDumpIntShape(input, index, NOT_NULL(&int_shapes), trans_flag); auto type = AnfAlgo::GetOutputInferDataType(input, index); + auto device_type = AnfAlgo::GetOutputDeviceDataType(input, index); std::string file_path = dump_path + '/' + *kernel_name + '_' + "input_" + std::to_string(j); if (IsDeviceTargetGPU()) { - DumpGPUMemToFile(file_path, tensor_name, NOT_NULL(addr), int_shapes, type, trans_flag, slot, debugger); + DumpGPUMemToFile(file_path, tensor_name, NOT_NULL(addr), int_shapes, type, device_type, trans_flag, slot, + debugger); } else { DumpMemToFile(file_path, NOT_NULL(addr), int_shapes, type, trans_flag); } @@ -185,10 +189,11 @@ void E2eDump::DumpSingleAnfNode(const AnfNodePtr &anf_node, const size_t output_ ShapeVector int_shapes; GetDumpIntShape(anf_node, output_index, NOT_NULL(&int_shapes), trans_flag); auto type = AnfAlgo::GetOutputInferDataType(anf_node, output_index); + auto device_type = AnfAlgo::GetOutputDeviceDataType(anf_node, output_index); std::string file_path = dump_path + '/' + dump_name + '_' + "output_0"; if (IsDeviceTargetGPU()) { - DumpGPUMemToFile(file_path, node_name, NOT_NULL(addr), int_shapes, type, trans_flag, 0, debugger); + DumpGPUMemToFile(file_path, node_name, NOT_NULL(addr), int_shapes, type, device_type, trans_flag, 0, debugger); } else { DumpMemToFile(file_path, NOT_NULL(addr), int_shapes, type, trans_flag); } diff --git a/mindspore/ccsrc/debug/data_dump/e2e_dump.h b/mindspore/ccsrc/debug/data_dump/e2e_dump.h index 372232eaeac..fa7a7567775 100644 --- a/mindspore/ccsrc/debug/data_dump/e2e_dump.h +++ b/mindspore/ccsrc/debug/data_dump/e2e_dump.h @@ -49,7 +49,8 @@ class E2eDump { static void DumpGPUMemToFile(const std::string &file_path, const std::string &original_kernel_name, NotNull addr, const ShapeVector &int_shapes, - const TypeId &type, bool trans_flag, size_t slot, const Debugger *debugger); + const TypeId &host_type, const TypeId &device_type, bool trans_flag, size_t slot, + const Debugger *debugger); static bool IsDeviceTargetGPU(); static void DumpSingleAnfNode(const AnfNodePtr &anf_node, const size_t output_index, const std::string &dump_path, bool trans_flag, std::map *const_map, const Debugger *debugger); diff --git a/mindspore/ccsrc/debug/debug_services.cc b/mindspore/ccsrc/debug/debug_services.cc index 359fa9b94a9..dbee3eba890 100644 --- a/mindspore/ccsrc/debug/debug_services.cc +++ b/mindspore/ccsrc/debug/debug_services.cc @@ -887,10 +887,10 @@ void DebugServices::EmptyCurrentTensor() { tensor_loader_->EmptyCurrentTensor(); #ifdef ONLINE_DBG_MODE bool DebugServices::DumpTensorToFile(const std::string &tensor_name, bool trans_flag, const std::string &filepath, const std::string &host_fmt, const std::vector &host_shape, - TypeId host_type, TypeId addr_type_id, const std::string &addr_format, + TypeId host_type, TypeId device_type, const std::string &addr_format, size_t slot) const { return tensor_loader_->DumpTensorToFile(tensor_name, trans_flag, filepath, host_fmt, host_shape, host_type, - addr_type_id, addr_format, slot); + device_type, addr_format, slot); } #endif diff --git a/mindspore/ccsrc/debug/debug_services.h b/mindspore/ccsrc/debug/debug_services.h index d8d729372c4..688428e8a89 100644 --- a/mindspore/ccsrc/debug/debug_services.h +++ b/mindspore/ccsrc/debug/debug_services.h @@ -270,7 +270,7 @@ class DebugServices { #ifdef ONLINE_DBG_MODE bool DumpTensorToFile(const std::string &tensor_name, bool trans_flag, const std::string &filepath, const std::string &host_fmt, const std::vector &host_shape, TypeId host_type, - TypeId addr_type_id, const std::string &addr_format, size_t slot) const; + TypeId device_type, const std::string &addr_format, size_t slot) const; #endif bool LoadNewTensor(const std::shared_ptr &tensor, bool keep_prev); diff --git a/mindspore/ccsrc/debug/debugger/debugger.cc b/mindspore/ccsrc/debug/debugger/debugger.cc index 14a6f4af230..d77a9165b7a 100644 --- a/mindspore/ccsrc/debug/debugger/debugger.cc +++ b/mindspore/ccsrc/debug/debugger/debugger.cc @@ -881,9 +881,9 @@ void Debugger::SendWatchpoints(const std::list &points) { bool Debugger::DumpTensorToFile(const std::string &tensor_name, bool trans_flag, const std::string &filepath, const std::string &host_fmt, const std::vector &host_shape, TypeId host_type, - TypeId addr_type_id, const std::string &addr_format, size_t slot) const { + TypeId device_type, const std::string &addr_format, size_t slot) const { return debug_services_.get()->DumpTensorToFile(tensor_name, trans_flag, filepath, host_fmt, host_shape, host_type, - addr_type_id, addr_format, slot); + device_type, addr_format, slot); } bool Debugger::DebugServicesIsWatchPoint(const std::string &kernel_name, const CNodePtr &kernel) const { diff --git a/mindspore/ccsrc/debug/debugger/debugger.h b/mindspore/ccsrc/debug/debugger/debugger.h index 52105cb3c31..7bd03b61f21 100644 --- a/mindspore/ccsrc/debug/debugger/debugger.h +++ b/mindspore/ccsrc/debug/debugger/debugger.h @@ -91,7 +91,7 @@ class Debugger : public std::enable_shared_from_this { bool DumpTensorToFile(const std::string &tensor_name, bool trans_flag, const std::string &filepath, const std::string &host_fmt, const std::vector &host_shape, TypeId host_type, - TypeId addr_type_id, const std::string &addr_format, size_t slot) const; + TypeId device_type, const std::string &addr_format, size_t slot) const; bool DebugServicesIsWatchPoint(const std::string &kernel_name, const CNodePtr &kernel = nullptr) const; diff --git a/mindspore/ccsrc/debug/tensor_load.h b/mindspore/ccsrc/debug/tensor_load.h index f464ec56911..e7e831b0910 100644 --- a/mindspore/ccsrc/debug/tensor_load.h +++ b/mindspore/ccsrc/debug/tensor_load.h @@ -159,7 +159,7 @@ class TensorLoader { #ifdef ONLINE_DBG_MODE bool DumpTensorToFile(const std::string &tensor_name, bool trans_flag, const std::string &filepath, const std::string &host_fmt, const std::vector &host_shape, TypeId host_type, - TypeId addr_type_id, const std::string &addr_format, size_t slot) { + TypeId device_type, const std::string &addr_format, size_t slot) { if (filepath.empty()) { MS_LOG(ERROR) << "Dump file path is null!"; return false; @@ -177,7 +177,7 @@ class TensorLoader { if (trans_flag) { path = filepath + '_' + shape + '_' + TypeIdToType(host_type)->ToString() + '_' + host_fmt + file_extension; } else { - path = filepath + '_' + shape + '_' + TypeIdToType(addr_type_id)->ToString() + '_' + addr_format + file_extension; + path = filepath + '_' + shape + '_' + TypeIdToType(device_type)->ToString() + '_' + addr_format + file_extension; } MS_LOG(INFO) << "Dump path is " << path;