提交 62549e07 编写于 作者: Q Qiao Longfei

add GenParentScopeTreeDebugInfo

上级 a66115be
......@@ -365,6 +365,7 @@ ParallelExecutor::ParallelExecutor(
void ParallelExecutor::BCastParamsToDevices(
const std::unordered_set<std::string> &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);
......
......@@ -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<const Scope*> 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
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册