add GenParentScopeTreeDebugInfo

mixed_precision_init
Qiao Longfei 6 years ago
parent a66115bed5
commit 62549e0714

@ -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

Loading…
Cancel
Save