From 62549e071402530e862285ab1613eb8e8e5e5150 Mon Sep 17 00:00:00 2001 From: Qiao Longfei Date: Sun, 27 Jan 2019 17:10:45 +0800 Subject: [PATCH] add GenParentScopeTreeDebugInfo --- paddle/fluid/framework/parallel_executor.cc | 1 + paddle/fluid/framework/scope.cc | 29 +++++++++++++++++++++ paddle/fluid/framework/scope.h | 1 + 3 files changed, 31 insertions(+) diff --git a/paddle/fluid/framework/parallel_executor.cc b/paddle/fluid/framework/parallel_executor.cc index 3997294f172..f0bc3acccc2 100644 --- a/paddle/fluid/framework/parallel_executor.cc +++ b/paddle/fluid/framework/parallel_executor.cc @@ -365,6 +365,7 @@ ParallelExecutor::ParallelExecutor( void ParallelExecutor::BCastParamsToDevices( const std::unordered_set &vars) const { + VLOG(3) << "BCastParamsToDevices"; // the initializing bcast, all vars would be bcast from device(0). for (auto &var : vars) { framework::Variable *main_var = member_->local_scopes_[0]->FindVar(var); diff --git a/paddle/fluid/framework/scope.cc b/paddle/fluid/framework/scope.cc index 95361856091..884ad3b34b3 100644 --- a/paddle/fluid/framework/scope.cc +++ b/paddle/fluid/framework/scope.cc @@ -259,5 +259,34 @@ std::string GenScopeTreeDebugInfo(Scope* root) { return os.str(); } +std::string GenParentScopeTreeDebugInfo(Scope* leaf) { + std::stringstream os; + + if (!leaf) return ""; + + // level traversal + std::vector scopes; + const Scope* current_scope = leaf; + + while (current_scope != nullptr) { + scopes.push_back(current_scope); + current_scope = current_scope->parent(); + // end of a level + os << "\n------------------------------------------\n"; + } + + os << "\nDetails:\n\n"; + + for (auto* q : scopes) { + os << "====\n"; + os << q << ":\n"; + for (auto& var : q->LocalVarNames()) { + os << " - " << var << "\n"; + } + } + + return os.str(); +} + } // namespace framework } // namespace paddle diff --git a/paddle/fluid/framework/scope.h b/paddle/fluid/framework/scope.h index f0915d2eee0..eb5c12def6a 100644 --- a/paddle/fluid/framework/scope.h +++ b/paddle/fluid/framework/scope.h @@ -144,6 +144,7 @@ class Scope { // Generate some debug string about the inherience structure of scope, quite // naive. std::string GenScopeTreeDebugInfo(Scope*); +std::string GenParentScopeTreeDebugInfo(Scope*); } // namespace framework } // namespace paddle -- GitLab