From 4b193db14c4862569c345e4cf7970418dbf01073 Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Tue, 19 Feb 2019 17:17:36 +0800 Subject: [PATCH] polish code test=develop --- paddle/fluid/framework/details/multi_devices_graph_pass.cc | 6 ++++++ paddle/fluid/framework/details/multi_devices_helper.h | 6 ------ .../fluid/framework/details/parallel_ssa_graph_executor.cc | 3 --- .../fluid/framework/details/parallel_ssa_graph_executor.h | 2 -- paddle/fluid/framework/ir/graph.h | 3 +++ 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/paddle/fluid/framework/details/multi_devices_graph_pass.cc b/paddle/fluid/framework/details/multi_devices_graph_pass.cc index 3c0a8d702..7d1e63f36 100644 --- a/paddle/fluid/framework/details/multi_devices_graph_pass.cc +++ b/paddle/fluid/framework/details/multi_devices_graph_pass.cc @@ -36,6 +36,11 @@ namespace framework { namespace details { namespace { +// TODO(panyx0718): Clean this up as well. +// all operators. NOTE that even we use a vector here, the operators is +// unordered. +typedef std::vector GraphOps; +const char kGraphOps[] = "ops"; bool OpHaveRole(const ir::Node &node, const framework::OpRole &role) { return boost::get( @@ -221,6 +226,7 @@ std::unique_ptr MultiDevSSAGraphBuilderBase::ApplyImpl( * Only variables should be the leaves of graph. */ AddOutputToLeafOps(&result); + result.Erase(kGraphOps); return graph; } diff --git a/paddle/fluid/framework/details/multi_devices_helper.h b/paddle/fluid/framework/details/multi_devices_helper.h index 5331b750e..9afbb9100 100644 --- a/paddle/fluid/framework/details/multi_devices_helper.h +++ b/paddle/fluid/framework/details/multi_devices_helper.h @@ -44,12 +44,6 @@ const char kGraphVars[] = "vars"; typedef std::unordered_set GraphDepVars; const char kGraphDepVars[] = "dep_vars"; -// TODO(panyx0718): Clean this up as well. -// all operators. NOTE that even we use a vector here, the operators is -// unordered. -typedef std::vector GraphOps; -const char kGraphOps[] = "ops"; - } // namespace details } // namespace framework } // namespace paddle diff --git a/paddle/fluid/framework/details/parallel_ssa_graph_executor.cc b/paddle/fluid/framework/details/parallel_ssa_graph_executor.cc index 3740b795f..4c8f69c68 100644 --- a/paddle/fluid/framework/details/parallel_ssa_graph_executor.cc +++ b/paddle/fluid/framework/details/parallel_ssa_graph_executor.cc @@ -30,7 +30,6 @@ ParallelSSAGraphExecutor::SeparateMultiDevicesGraph( auto &g = graphs.back(); g->Set(kGraphVars, new GraphVars(1UL)); g->Set(kGraphDepVars, new GraphDepVars); - g->Set(kGraphOps, new GraphOps); } auto op_handles = ir::FilterByNodeWrapper(*graph); @@ -38,9 +37,7 @@ ParallelSSAGraphExecutor::SeparateMultiDevicesGraph( auto &dev_ctx = op->DeviceContext(); auto &p = dev_ctx.begin()->first; int dev_id = boost::get(p).device; - auto &dev_ops = graphs[dev_id]->Get(kGraphOps); auto &dev_dummys = graphs[dev_id]->Get(kGraphDepVars); - dev_ops.emplace_back(op); graphs[dev_id]->AddNode(graph->RemoveNode(op->Node()).release()); for (auto &var : op->Inputs()) { diff --git a/paddle/fluid/framework/details/parallel_ssa_graph_executor.h b/paddle/fluid/framework/details/parallel_ssa_graph_executor.h index f59305bf9..1c35d45fd 100644 --- a/paddle/fluid/framework/details/parallel_ssa_graph_executor.h +++ b/paddle/fluid/framework/details/parallel_ssa_graph_executor.h @@ -14,8 +14,6 @@ #pragma once -#include -#include #include #include diff --git a/paddle/fluid/framework/ir/graph.h b/paddle/fluid/framework/ir/graph.h index d5b3782f6..296f3b839 100644 --- a/paddle/fluid/framework/ir/graph.h +++ b/paddle/fluid/framework/ir/graph.h @@ -28,6 +28,9 @@ namespace paddle { namespace framework { namespace details { + +// This attr is not recommended, because the graph should not dependence +// the program once it is built. constexpr char kAllOpDescs[] = "all_op_descs"; } // namespace details -- GitLab