diff --git a/mindspore/ccsrc/backend/optimizer/somas/somas.cc b/mindspore/ccsrc/backend/optimizer/somas/somas.cc index 775ca904bf..53c3612365 100644 --- a/mindspore/ccsrc/backend/optimizer/somas/somas.cc +++ b/mindspore/ccsrc/backend/optimizer/somas/somas.cc @@ -34,7 +34,9 @@ #include "backend/optimizer/common/helper.h" #include "utils/ms_context.h" #include "debug/common.h" +#ifdef ENABLE_DUMP_IR #include "debug/rdr/running_data_recorder.h" +#endif #include "common/thread_pool.h" #include "profiler/device/common/memory_profiling.h" diff --git a/mindspore/ccsrc/debug/CMakeLists.txt b/mindspore/ccsrc/debug/CMakeLists.txt index 81ccb31530..aed1675895 100644 --- a/mindspore/ccsrc/debug/CMakeLists.txt +++ b/mindspore/ccsrc/debug/CMakeLists.txt @@ -6,13 +6,18 @@ set(_DEBUG_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/trace.cc" "${CMAKE_CURRENT_SOURCE_DIR}/common.cc" "${CMAKE_CURRENT_SOURCE_DIR}/env_config_parser.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/rdr/graph_exec_order_recorder.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/rdr/graph_recorder.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/rdr/string_recorder.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/rdr/recorder_manager.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/rdr/running_data_recorder.cc" ) +if(ENABLE_DUMP_IR) + list(APPEND _DEBUG_SRC_LIST + "${CMAKE_CURRENT_SOURCE_DIR}/rdr/graph_exec_order_recorder.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/rdr/graph_recorder.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/rdr/string_recorder.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/rdr/recorder_manager.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/rdr/running_data_recorder.cc" + ) +endif() + if(ENABLE_DEBUGGER) list(APPEND _DEBUG_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/debugger/debugger.cc" diff --git a/mindspore/ccsrc/debug/rdr/graph_recorder.cc b/mindspore/ccsrc/debug/rdr/graph_recorder.cc index 874e51fe72..e02b64957e 100644 --- a/mindspore/ccsrc/debug/rdr/graph_recorder.cc +++ b/mindspore/ccsrc/debug/rdr/graph_recorder.cc @@ -78,8 +78,17 @@ void DumpIRProto(const FuncGraphPtr &, const std::string &) { void GraphRecorder::Export() { bool save_flag = false; if (filename_.empty()) { - filename_ = directory_ + module_ + "_" + tag_ + "_" + timestamp_; + filename_ = module_ + "_" + tag_ + "_" + timestamp_; } + if (filename_.length() > 255) { // 255: filename maximum length + filename_ = filename_.substr(0, 255); + } + filename_ = directory_ + filename_; + if (filename_.size() + 3 > PATH_MAX) { // 3: file format length + MS_LOG(ERROR) << "File path " << filename_ << " is too long."; + return; + } + if (graph_type_.find(".dat") != std::string::npos) { save_flag = true; AnfExporter exporter(std::to_string(id_)); diff --git a/mindspore/ccsrc/runtime/device/memory_manager.cc b/mindspore/ccsrc/runtime/device/memory_manager.cc index 1b57e99495..697c9afd33 100644 --- a/mindspore/ccsrc/runtime/device/memory_manager.cc +++ b/mindspore/ccsrc/runtime/device/memory_manager.cc @@ -17,7 +17,9 @@ #include "runtime/device/memory_manager.h" #include #include "backend/session/anf_runtime_algorithm.h" +#ifdef ENABLE_DUMP_IR #include "debug/rdr/running_data_recorder.h" +#endif #include "utils/ms_context.h" using mindspore::memreuse::BestFitMemReuse;