From 698c926ce5f1666d18b00bdd12fe63803dc738fe Mon Sep 17 00:00:00 2001 From: Xin Pan Date: Wed, 22 Aug 2018 20:42:29 +0800 Subject: [PATCH] copy program and fix op_desc --- paddle/fluid/framework/ir/graph.h | 4 +--- paddle/fluid/framework/ir/node.h | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/framework/ir/graph.h b/paddle/fluid/framework/ir/graph.h index 25e33861c..0d27be5fc 100644 --- a/paddle/fluid/framework/ir/graph.h +++ b/paddle/fluid/framework/ir/graph.h @@ -142,8 +142,6 @@ class Graph { nodes_.erase(node); } - const ProgramDesc &program() const { return program_; } - private: // This method takes ownership of `node`. ir::Node *AddNode(ir::Node *node) { @@ -154,7 +152,7 @@ class Graph { } // NOTE: program_ shouldn't be exposed to user. - const ProgramDesc &program_; + const ProgramDesc program_; std::map attrs_; std::map> attr_dels_; std::map> nodes_; diff --git a/paddle/fluid/framework/ir/node.h b/paddle/fluid/framework/ir/node.h index 063c70fb7..63277d2d0 100644 --- a/paddle/fluid/framework/ir/node.h +++ b/paddle/fluid/framework/ir/node.h @@ -41,8 +41,7 @@ class Node { explicit Node(OpDesc* op_desc) : name_(op_desc->Type()), var_desc_(nullptr), - op_desc_(new OpDesc(*op_desc)), // TODO(panyx0718) the pointer in the - // original OpDesc might go out. + op_desc_(new OpDesc(*op_desc, op_desc->Block())), type_(Type::kOperation) {} Type NodeType() const { return type_; } -- GitLab