Browse Source

!12534 Ignore renormalization if no changes made after last renormalization, and release all data after finished RDR checking.

From: @zh_qh
Reviewed-by: @ginfung,@hwhewei
Signed-off-by: @ginfung
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 5 years ago
parent
commit
efbda3bec5
6 changed files with 20 additions and 2 deletions
  1. +3
    -0
      mindspore/ccsrc/backend/session/ascend_session.cc
  2. +2
    -0
      mindspore/ccsrc/debug/rdr/recorder_manager.cc
  3. +1
    -0
      mindspore/ccsrc/debug/rdr/recorder_manager.h
  4. +2
    -0
      mindspore/ccsrc/debug/rdr/running_data_recorder.cc
  5. +1
    -0
      mindspore/ccsrc/debug/rdr/running_data_recorder.h
  6. +11
    -2
      mindspore/ccsrc/frontend/optimizer/optimizer.h

+ 3
- 0
mindspore/ccsrc/backend/session/ascend_session.cc View File

@@ -984,6 +984,9 @@ void AscendSession::Execute(const std::shared_ptr<KernelGraph> &kernel_graph, bo
#endif
MS_LOG(EXCEPTION) << "run task error!";
}
#ifdef ENABLE_DUMP_IR
mindspore::RDR::ClearAll();
#endif
MS_LOG(INFO) << "Finish!";
}



+ 2
- 0
mindspore/ccsrc/debug/rdr/recorder_manager.cc View File

@@ -52,4 +52,6 @@ void RecorderManager::TriggerAll() {
MS_LOG(WARNING) << "There is no recorder to export.";
}
}

void RecorderManager::ClearAll() { recorder_container_.clear(); }
} // namespace mindspore

+ 1
- 0
mindspore/ccsrc/debug/rdr/recorder_manager.h View File

@@ -36,6 +36,7 @@ class RecorderManager {

bool RecordObject(const BaseRecorderPtr &recorder);
void TriggerAll();
void ClearAll();

private:
RecorderManager() {}


+ 2
- 0
mindspore/ccsrc/debug/rdr/running_data_recorder.cc View File

@@ -97,6 +97,8 @@ bool RecordStreamExecOrder(const SubModuleId module, const std::string &tag, con

void TriggerAll() { mindspore::RecorderManager::Instance().TriggerAll(); }

void ClearAll() { mindspore::RecorderManager::Instance().ClearAll(); }

#else
bool RecordAnfGraph(const SubModuleId module, const std::string &tag, const FuncGraphPtr &graph, bool full_name,
const std::string &file_type, int graph_id) {


+ 1
- 0
mindspore/ccsrc/debug/rdr/running_data_recorder.h View File

@@ -36,6 +36,7 @@ bool RecordString(SubModuleId module, const std::string &tag, const std::string
bool RecordStreamExecOrder(const SubModuleId module, const std::string &tag, const int &graph_id,
const std::vector<CNodePtr> &exec_order);
void TriggerAll();
void ClearAll();
} // namespace RDR
} // namespace mindspore
#endif // MINDSPORE_CCSRC_DEBUG_RDR_RUNNING_DATA_RECORDER_H_

+ 11
- 2
mindspore/ccsrc/frontend/optimizer/optimizer.h View File

@@ -146,15 +146,22 @@ class Optimizer : public std::enable_shared_from_this<Optimizer> {
// Optimizer step counter;
int64_t counter = 1;
bool changes = true;
// If no changes since last renormalization, then no need to do the renormalization again.
// Set the initial value to true, so the renormalization can be executed once if it's the
// only pass.
bool changes_since_last_renorm = true;

while (changes) {
changes = false;
auto run_runc = [&counter, &func_graph, &changes, use_profile, this]() {
auto run_runc = [&counter, &func_graph, &changes, &changes_since_last_renorm, use_profile, this]() {
for (size_t i = 0; i < passes_.size(); ++i) {
const OptPass &opt = passes_[i];
CurPass_ = {counter, pass_names_[i]};
auto opt_func = [&func_graph, &changes, &opt, this]() {
auto opt_func = [&func_graph, &changes, &opt, &changes_since_last_renorm, this]() {
if (opt.is_renormalize()) {
if (!changes_since_last_renorm) {
return;
}
auto resource_ptr = std::dynamic_pointer_cast<pipeline::Resource>(resource_);
if (resource_ptr != nullptr) {
// StepParallel may replace the AbstractValue of the parameters of func_graph,
@@ -177,8 +184,10 @@ class Optimizer : public std::enable_shared_from_this<Optimizer> {
func_graph = pipeline::Renormalize(resource_ptr, func_graph, maybe_new_args_spec);
}
}
changes_since_last_renorm = false;
} else if (opt(func_graph, shared_from_this())) {
changes = true;
changes_since_last_renorm = true;
}
};
use_profile ? (WITH(MsProfile::GetProfile()->Step(pass_names_[i])) opt_func) : opt_func();


Loading…
Cancel
Save