From 61e959a9f33f3b1629ac7bb94ab78383428d1c48 Mon Sep 17 00:00:00 2001 From: gong chen Date: Tue, 14 Apr 2020 15:07:42 +0800 Subject: [PATCH] bugfix(side effect): fix cell object cann't free normally. --- mindspore/ccsrc/ir/func_graph.cc | 20 ++++++++++---------- mindspore/ccsrc/ir/func_graph.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mindspore/ccsrc/ir/func_graph.cc b/mindspore/ccsrc/ir/func_graph.cc index 7404db4af0..93fd9c0936 100644 --- a/mindspore/ccsrc/ir/func_graph.cc +++ b/mindspore/ccsrc/ir/func_graph.cc @@ -640,8 +640,8 @@ FuncGraphPtr FuncGraph::GenerateGraph(const AbstractBasePtrList& args_spec_list) void FuncGraph::add_parameter_obj_node(const AnfNodePtr& p) { paramter_obj_nodes_.push_back(p); } -std::list FuncGraph::GetOrderedCnodes(bool force_use_topo_sort) { - if (has_flag(GRAPH_FLAG_HAS_EFFECT) && !force_use_topo_sort) { +std::list FuncGraph::GetOrderedCnodes() { + if (has_flag(GRAPH_FLAG_HAS_EFFECT)) { MS_LOG(DEBUG) << "Return ordered cnodes."; return order_; } else { @@ -703,14 +703,14 @@ void FuncGraph::CheckOrder() { } } } - auto topo_sort = GetOrderedCnodes(true); - if (topo_sort.size() != order_.size()) { - DumpCNodeList(); - DumpIR(ToString(), shared_from_base()); - MS_LOG(INFO) << "Dump graph: " << ToString() << "."; - DumpFuncGraph(ToString()); - MS_LOG(EXCEPTION) << "CNode order size " << order_.size() << " is not equal to topo sort list size " - << topo_sort.size() << "."; + auto mng = manager_.lock(); + if (mng != nullptr) { + const auto& nodes = mng->nodes()[shared_from_base()]; + if (nodes.size() != (order_.size() + parameters_.size())) { + DumpCNodeList(); + MS_LOG(EXCEPTION) << "CNode order size " << order_.size() << " is not equal to managed node size " + << nodes.size() - parameters_.size() << "."; + } } MS_LOG(DEBUG) << "Check order okay."; } diff --git a/mindspore/ccsrc/ir/func_graph.h b/mindspore/ccsrc/ir/func_graph.h index 1d58c90755..9c3752cd81 100644 --- a/mindspore/ccsrc/ir/func_graph.h +++ b/mindspore/ccsrc/ir/func_graph.h @@ -258,7 +258,7 @@ class FuncGraph : public FuncGraphBase { std::map parameter_default_value_; std::unordered_map make_ref_params_; - std::list GetOrderedCnodes(bool force_use_topo_sort = false); + std::list GetOrderedCnodes(); void EraseUnusedNodeInOrder(const AnfNodePtr &n); void EraseUnusedNodeInOrder(); void CheckOrder();