Browse Source

!295 bugfix(side effect): fix cell object can not free normally.

Merge pull request !295 from gongchen/fix_free_cell_obj
tags/v0.2.0-alpha
mindspore-ci-bot Gitee 5 years ago
parent
commit
a30ee78001
2 changed files with 11 additions and 11 deletions
  1. +10
    -10
      mindspore/ccsrc/ir/func_graph.cc
  2. +1
    -1
      mindspore/ccsrc/ir/func_graph.h

+ 10
- 10
mindspore/ccsrc/ir/func_graph.cc View File

@@ -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); } void FuncGraph::add_parameter_obj_node(const AnfNodePtr& p) { paramter_obj_nodes_.push_back(p); }


std::list<CNodePtr> FuncGraph::GetOrderedCnodes(bool force_use_topo_sort) {
if (has_flag(GRAPH_FLAG_HAS_EFFECT) && !force_use_topo_sort) {
std::list<CNodePtr> FuncGraph::GetOrderedCnodes() {
if (has_flag(GRAPH_FLAG_HAS_EFFECT)) {
MS_LOG(DEBUG) << "Return ordered cnodes."; MS_LOG(DEBUG) << "Return ordered cnodes.";
return order_; return order_;
} else { } 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<FuncGraph>());
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<FuncGraph>()];
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."; MS_LOG(DEBUG) << "Check order okay.";
} }


+ 1
- 1
mindspore/ccsrc/ir/func_graph.h View File

@@ -258,7 +258,7 @@ class FuncGraph : public FuncGraphBase {
std::map<std::string, AnfNodePtr> parameter_default_value_; std::map<std::string, AnfNodePtr> parameter_default_value_;
std::unordered_map<AnfNodePtr, AnfNodePtr> make_ref_params_; std::unordered_map<AnfNodePtr, AnfNodePtr> make_ref_params_;


std::list<CNodePtr> GetOrderedCnodes(bool force_use_topo_sort = false);
std::list<CNodePtr> GetOrderedCnodes();
void EraseUnusedNodeInOrder(const AnfNodePtr &n); void EraseUnusedNodeInOrder(const AnfNodePtr &n);
void EraseUnusedNodeInOrder(); void EraseUnusedNodeInOrder();
void CheckOrder(); void CheckOrder();


Loading…
Cancel
Save