Trace CNode Enter&Leave during StackFrame jump.

This commit is contained in:
Zhang Qinghua 2021-06-28 20:29:13 +08:00
parent aa08bbf063
commit 3b85a38c9d
2 changed files with 16 additions and 5 deletions

View File

@ -116,13 +116,14 @@ void TraceGraphEval() {
auto &infer_stack = GetCurrenGraphEvalStack();
std::ostringstream oss;
if (infer_stack.empty()) {
MS_LOG(ERROR) << "Length of analysis graph stack is empty.";
return;
}
MS_LOG(INFO) << "\n*******************************graph evaluate stack**********************************";
MS_LOG(ERROR) << "\n*******************************graph evaluate stack**********************************";
oss << std::endl;
DumpInferStack(oss);
MS_LOG(INFO) << oss.str();
MS_LOG(INFO) << "\n*************************************************************************************";
MS_LOG(ERROR) << oss.str();
MS_LOG(ERROR) << "\n*************************************************************************************";
}
class AnalyzedFuncGraphExporter : public AnfExporter {
@ -501,7 +502,7 @@ void GetEvalStackInfo(std::ostringstream &oss) {
MS_LOG(INFO) << "Get graph analysis information begin";
auto stack = GetCNodeDebugStack();
if (stack.empty()) {
MS_LOG(INFO) << "Length of analysis information stack is empty.";
MS_LOG(ERROR) << "Length of analysis information stack is empty.";
return;
}

View File

@ -116,7 +116,14 @@ StackFramePtr StackFrame::Jump(const AnalysisEnginePtr &engine) {
}
// It's FuncGraph Call or MetaFuncGraph Call. `maybe_func` is definitely a AbstractFunction.
return DoJump(engine, cnode, dyn_cast<AbstractFunction>(maybe_func));
AnfNodeConfigPtr call_node_conf = engine->MakeConfig(cnode, current_context_);
// Enter the call CNode.
trace::TraceEvalCNodeEnter(call_node_conf);
auto res = DoJump(engine, cnode, dyn_cast<AbstractFunction>(maybe_func));
if (res == nullptr) {
trace::TraceEvalCNodeLeave();
}
return res;
}
// Run one step in current func graph.
@ -150,6 +157,9 @@ void StackFrame::Back(const AnalysisEnginePtr &engine, const StackFramePtr &last
<< ", current_context_: " << current_context_->ToString();
AnfNodeConfigPtr node_conf = engine->MakeConfig(current_node, current_context_);
engine->SaveEvalResultInCache(node_conf, result);
// Leave the call CNode.
trace::TraceEvalCNodeLeave();
}
} // namespace abstract
} // namespace mindspore