From 121d322a6696fa4413b7fe5a4e59d7463a6c40c3 Mon Sep 17 00:00:00 2001 From: huanghui Date: Thu, 16 Feb 2023 17:40:08 +0800 Subject: [PATCH] clear record debug info --- mindspore/ccsrc/frontend/optimizer/opt.cc | 2 ++ mindspore/ccsrc/pipeline/jit/action.cc | 1 - mindspore/ccsrc/pipeline/jit/parse/parse.cc | 2 -- mindspore/ccsrc/pipeline/jit/parse/resolve.cc | 3 --- mindspore/core/utils/info.cc | 5 ++++- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/mindspore/ccsrc/frontend/optimizer/opt.cc b/mindspore/ccsrc/frontend/optimizer/opt.cc index 5b703ad3253..ddc8e1e9533 100644 --- a/mindspore/ccsrc/frontend/optimizer/opt.cc +++ b/mindspore/ccsrc/frontend/optimizer/opt.cc @@ -391,6 +391,8 @@ bool SimpleRewriter::Run() { add_todo(fg->output()); } } + TraceGuard trace_guard(std::make_shared(node->debug_info())); + ScopeGuard scope_guard(node->scope()); auto new_node = NodeRewrite(node); if (new_node != nullptr) { (void)manager_->Replace(node, new_node); diff --git a/mindspore/ccsrc/pipeline/jit/action.cc b/mindspore/ccsrc/pipeline/jit/action.cc index 9fc4eace012..641052a080b 100644 --- a/mindspore/ccsrc/pipeline/jit/action.cc +++ b/mindspore/ccsrc/pipeline/jit/action.cc @@ -839,7 +839,6 @@ bool VmOptimizeAction(const ResourcePtr &resource) { } #endif auto ret = OptimizeAction(resource, kVmPasses); - TraceManager::ClearParseOrResolveDebugInfo(); TraceManager::CloseRecordDebugInfoFlag(); return ret; } diff --git a/mindspore/ccsrc/pipeline/jit/parse/parse.cc b/mindspore/ccsrc/pipeline/jit/parse/parse.cc index 538b25488c6..48a3083da72 100644 --- a/mindspore/ccsrc/pipeline/jit/parse/parse.cc +++ b/mindspore/ccsrc/pipeline/jit/parse/parse.cc @@ -764,7 +764,6 @@ FunctionBlockPtr Parser::ParseStatement(const FunctionBlockPtr &block, const py: MS_LOG(DEBUG) << "Ast node is " << node_name; if (stmt_method_map_.count(node_name) != 0) { auto stmt_block = (this->*stmt_method_map_[node_name])(block, node); - TraceManager::ClearParseOrResolveDebugInfo(); return stmt_block; } else { errcode_ = PARSE_NODE_METHOD_UNSUPPORTED; @@ -788,7 +787,6 @@ AnfNodePtr Parser::ParseExprNode(const FunctionBlockPtr &block, const py::object MS_LOG(DEBUG) << "Ast node is " << node_name; if (expr_method_map_.count(node_name) != 0) { auto expr_node = (this->*expr_method_map_[node_name])(block, node); - TraceManager::ClearParseOrResolveDebugInfo(); return expr_node; } else { errcode_ = PARSE_NODE_METHOD_UNSUPPORTED; diff --git a/mindspore/ccsrc/pipeline/jit/parse/resolve.cc b/mindspore/ccsrc/pipeline/jit/parse/resolve.cc index c07eed0ab69..842c2861195 100644 --- a/mindspore/ccsrc/pipeline/jit/parse/resolve.cc +++ b/mindspore/ccsrc/pipeline/jit/parse/resolve.cc @@ -517,7 +517,6 @@ AnfNodePtr ResolveCellWithAttr(const FuncGraphManagerPtr &manager, const py::obj AnfNodePtrList inputs = {NewValueNode(prim::kPrimGetAttr), resolved_node, attr}; MS_EXCEPTION_IF_NULL(get_attr_node->func_graph()); AnfNodePtr res_node = get_attr_node->func_graph()->NewCNodeInOrder(std::move(inputs)); - TraceManager::ClearParseOrResolveDebugInfo(); return res_node; } @@ -533,7 +532,6 @@ AnfNodePtr ResolveCellWithAttr(const FuncGraphManagerPtr &manager, const py::obj AnfNodePtrList inputs = {NewValueNode(prim::kPrimResolve), NewValueNode(new_namespace), NewValueNode(new_symbol)}; MS_EXCEPTION_IF_NULL(get_attr_node->func_graph()); AnfNodePtr resolved_node = get_attr_node->func_graph()->NewCNodeInOrder(std::move(inputs)); - TraceManager::ClearParseOrResolveDebugInfo(); return resolved_node; } @@ -718,7 +716,6 @@ AnfNodePtr ResolveMsClassWithAttr(const FuncGraphManagerPtr &manager, const py:: } py::object attr_obj = py::getattr(cls_obj, common::SafeCStr(attr)); AnfNodePtr res_node = ResolveObjectAndAddToManager(manager, attr_obj, get_attr_node); - TraceManager::ClearParseOrResolveDebugInfo(); return res_node; } diff --git a/mindspore/core/utils/info.cc b/mindspore/core/utils/info.cc index a0209ec13ed..1377fc1f84b 100644 --- a/mindspore/core/utils/info.cc +++ b/mindspore/core/utils/info.cc @@ -190,7 +190,10 @@ void TraceManager::DebugTrace(const DebugInfoPtr &debug_info, const TraceInfoPtr (void)trace_context_stack_.emplace_back(cloned_info); } -void TraceManager::EndTrace() noexcept { trace_context_stack_.pop_back(); } +void TraceManager::EndTrace() noexcept { + trace_context_stack_.pop_back(); + ClearParseOrResolveDebugInfo(); +} DebugInfoPtr TraceManager::record_debug_info() { return record_debug_info_; }