提交 01eddf12 编写于 作者: Z Zhen Wang

Not add graph copy construction method. test=develop

上级 1b9c8d5f
...@@ -14,7 +14,6 @@ limitations under the License. */ ...@@ -14,7 +14,6 @@ limitations under the License. */
#include <algorithm> #include <algorithm>
#include <unordered_map> #include <unordered_map>
#include <unordered_set>
#include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/ir/graph.h"
#include "paddle/fluid/framework/op_proto_maker.h" #include "paddle/fluid/framework/op_proto_maker.h"
...@@ -30,8 +29,6 @@ Graph::Graph(const ProgramDesc &program) : program_(program) { ...@@ -30,8 +29,6 @@ Graph::Graph(const ProgramDesc &program) : program_(program) {
ResolveHazard(var_nodes); ResolveHazard(var_nodes);
} }
Graph::Graph(const Graph &o) : Graph(o.program_) {}
std::map<std::string, std::vector<ir::Node *>> Graph::InitFromProgram( std::map<std::string, std::vector<ir::Node *>> Graph::InitFromProgram(
const ProgramDesc &program) { const ProgramDesc &program) {
VLOG(3) << "block in program:" << program_.Size(); VLOG(3) << "block in program:" << program_.Size();
......
...@@ -72,7 +72,6 @@ namespace ir { ...@@ -72,7 +72,6 @@ namespace ir {
class Graph { class Graph {
public: public:
explicit Graph(const ProgramDesc &program); explicit Graph(const ProgramDesc &program);
Graph(const Graph &o);
virtual ~Graph() { virtual ~Graph() {
for (auto &attr : attrs_) { for (auto &attr : attrs_) {
......
...@@ -54,14 +54,13 @@ void BindGraph(py::module *m) { ...@@ -54,14 +54,13 @@ void BindGraph(py::module *m) {
"The graph is a Directed Acyclic Single Static Assignment Graph, see " "The graph is a Directed Acyclic Single Static Assignment Graph, see "
"`paddle::ir::Graph` for details.") "`paddle::ir::Graph` for details.")
.def(py::init<const ProgramDesc &>()) .def(py::init<const ProgramDesc &>())
.def("__init__",
[](Graph &self, const Graph &other) { new (&self) Graph(other); })
.def("has", &Graph::Has) .def("has", &Graph::Has)
.def("get_int", &Graph::Get<int>) .def("get_int", &Graph::Get<int>)
.def("get_float", &Graph::Get<float>) .def("get_float", &Graph::Get<float>)
.def("get_double", &Graph::Get<double>) .def("get_double", &Graph::Get<double>)
.def("get_string", &Graph::Get<std::string>) .def("get_string", &Graph::Get<std::string>)
.def("get_marked_nodes", &Graph::Get<std::unordered_set<const Node *>>) .def("get_marked_nodes", &Graph::Get<std::unordered_set<const Node *>>,
return_value_policy::reference)
.def("set", [](Graph &self, const std::string &attr_name, .def("set", [](Graph &self, const std::string &attr_name,
int attr) { return self.Set(attr_name, new int(attr)); }) int attr) { return self.Set(attr_name, new int(attr)); })
.def("set", .def("set",
...@@ -105,7 +104,8 @@ void BindGraph(py::module *m) { ...@@ -105,7 +104,8 @@ void BindGraph(py::module *m) {
.def("retrieve_node", &Graph::RetrieveNode, .def("retrieve_node", &Graph::RetrieveNode,
return_value_policy::reference) return_value_policy::reference)
.def("resolve_hazard", &Graph::ResolveHazard) .def("resolve_hazard", &Graph::ResolveHazard)
.def("origin_program_desc", &Graph::OriginProgram); .def("origin_program_desc", &Graph::OriginProgram,
return_value_policy::reference);
} }
void BindNode(py::module *m) { void BindNode(py::module *m) {
......
...@@ -2006,10 +2006,13 @@ class IrGraph(object): ...@@ -2006,10 +2006,13 @@ class IrGraph(object):
""" """
Create a new and duplicated IrGraph. Create a new and duplicated IrGraph.
Warns:
The method only clones the graph structure, not its attributes.
Returns: Returns:
IrGraph: A new and duplicated graph. IrGraph: A new and duplicated graph.
""" """
g = core.Graph(self.graph) g = core.Graph(self.graph.origin_program_desc())
return IrGraph(g, self._for_test) return IrGraph(g, self._for_test)
def is_test(self): def is_test(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册