!19077 Trace CNode Enter&Leave during StackFrame jump.

Merge pull request !19077 from 张清华/opt
This commit is contained in:
i-robot 2021-07-01 03:07:56 +00:00 committed by Gitee
commit 35e35d5af4
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;
}
static int fileNumber = 0;

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