From b1fe84faec8d710e6edc046cbf6dee414f457f4c Mon Sep 17 00:00:00 2001 From: louie5 Date: Thu, 22 Jul 2021 09:37:12 +0800 Subject: [PATCH] release resource reference by RDR at the beginning of C++ interface --- mindspore/ccsrc/debug/rdr/base_recorder.h | 2 +- mindspore/ccsrc/debug/rdr/recorder_manager.cc | 4 ++-- mindspore/ccsrc/debug/rdr/running_data_recorder.cc | 2 +- mindspore/ccsrc/debug/rdr/running_data_recorder.h | 2 +- mindspore/ccsrc/pipeline/jit/pipeline.cc | 9 ++++++--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/mindspore/ccsrc/debug/rdr/base_recorder.h b/mindspore/ccsrc/debug/rdr/base_recorder.h index 39fae96799b..70ed7f2eb84 100644 --- a/mindspore/ccsrc/debug/rdr/base_recorder.h +++ b/mindspore/ccsrc/debug/rdr/base_recorder.h @@ -52,7 +52,7 @@ class BaseRecorder { } } } - ~BaseRecorder() {} + virtual ~BaseRecorder() {} std::string GetModule() const { return module_; } std::string GetName() const { return name_; } diff --git a/mindspore/ccsrc/debug/rdr/recorder_manager.cc b/mindspore/ccsrc/debug/rdr/recorder_manager.cc index 5da420de462..8e26750b009 100644 --- a/mindspore/ccsrc/debug/rdr/recorder_manager.cc +++ b/mindspore/ccsrc/debug/rdr/recorder_manager.cc @@ -105,7 +105,7 @@ void RecorderManager::TriggerAll() { if (!trigger) { MS_LOG(WARNING) << "There is no recorder to export."; } else { - MS_LOG(INFO) << "RDR export all recorders' info."; + MS_LOG(INFO) << "RDR export all recorders."; } } @@ -116,6 +116,6 @@ void RecorderManager::ClearAll() { std::lock_guard lock(mtx_); recorder_container_.clear(); rdr_has_record_mem_ = false; - MS_LOG(INFO) << "RDR clear all recorders' info."; + MS_LOG(INFO) << "RDR clear all recorders."; } } // namespace mindspore diff --git a/mindspore/ccsrc/debug/rdr/running_data_recorder.cc b/mindspore/ccsrc/debug/rdr/running_data_recorder.cc index da594dab3ba..4233dde47ec 100644 --- a/mindspore/ccsrc/debug/rdr/running_data_recorder.cc +++ b/mindspore/ccsrc/debug/rdr/running_data_recorder.cc @@ -118,7 +118,7 @@ bool UpdateGPUMemAddressInfo(const SubModuleId module, const std::string &name, void TriggerAll() { mindspore::RecorderManager::Instance().TriggerAll(); } -void ClearAll() { mindspore::RecorderManager::Instance().ClearAll(); } +void ResetRecorder() { mindspore::RecorderManager::Instance().ClearAll(); } void ClearGPUMemAddressInfo() { if (!mindspore::RecorderManager::Instance().RdrEnable()) { diff --git a/mindspore/ccsrc/debug/rdr/running_data_recorder.h b/mindspore/ccsrc/debug/rdr/running_data_recorder.h index 649bc2dbe37..c6ecf65e9ac 100644 --- a/mindspore/ccsrc/debug/rdr/running_data_recorder.h +++ b/mindspore/ccsrc/debug/rdr/running_data_recorder.h @@ -60,7 +60,7 @@ bool RecordTaskDebugInfo(SubModuleId module, const std::string &name, const std::vector &task_debug_info_list); #endif // ENABLE_D void TriggerAll(); -void ClearAll(); +void ResetRecorder(); void ClearGPUMemAddressInfo(); } // namespace RDR } // namespace mindspore diff --git a/mindspore/ccsrc/pipeline/jit/pipeline.cc b/mindspore/ccsrc/pipeline/jit/pipeline.cc index 964c6970904..8e78f5fa702 100644 --- a/mindspore/ccsrc/pipeline/jit/pipeline.cc +++ b/mindspore/ccsrc/pipeline/jit/pipeline.cc @@ -445,9 +445,6 @@ void ExecutorPy::DelNetRes(const std::string &id) { #endif } nested_called = false; -#ifdef ENABLE_DUMP_IR - mindspore::RDR::ClearAll(); -#endif } void ExecutorPy::ClearRes() { @@ -1132,6 +1129,9 @@ bool InitExecDatasetVm(const std::string &queue_name, int64_t size, int64_t batc app_init->set_abstract(abstract_none); // Before the graph compiling, need reset the iter num. ConfigManager::GetInstance().ResetIterNum(); +#ifdef ENABLE_DUMP_IR + mindspore::RDR::ResetRecorder(); +#endif compile::SetMindRTEnable(); auto backend = compile::CreateBackend(); @@ -1298,6 +1298,9 @@ void ClearResAtexit() { ps::Worker::GetInstance().Finalize(); } } +#endif +#ifdef ENABLE_DUMP_IR + mindspore::RDR::ResetRecorder(); #endif session::ExecutorManager::Instance().Clear(); device::KernelRuntimeManager::Instance().ClearRuntimeResource();