@@ -14,19 +14,19 @@ limitations under the License. */
14
14
15
15
#include " paddle/fluid/framework/prune.h"
16
16
17
+ #include < glog/logging.h>
18
+
17
19
#include < algorithm>
18
20
#include < set>
19
21
#include < string>
20
22
#include < unordered_map>
21
23
#include < vector>
22
24
23
- #include < glog/logging.h>
24
-
25
25
namespace paddle {
26
26
namespace framework {
27
27
28
- const std::string kFeedOpType = " feed" ;
29
- const std::string kFetchOpType = " fetch" ;
28
+ const char kFeedOpType [] = " feed" ;
29
+ const char kFetchOpType [] = " fetch" ;
30
30
31
31
bool HasDependentVar (const proto::OpDesc& op_desc,
32
32
const std::set<std::string>& dependent_vars) {
@@ -68,7 +68,7 @@ bool HasSubBlock(const proto::OpDesc& op_desc) {
68
68
// the child block to help pruning
69
69
void prune_impl (const proto::ProgramDesc& input, proto::ProgramDesc* output,
70
70
int block_id, int parent_block_id,
71
- std::set<std::string>& dependent_vars) {
71
+ std::set<std::string>* dependent_vars) {
72
72
auto & block = input.blocks (block_id);
73
73
auto & ops = block.ops ();
74
74
@@ -90,11 +90,11 @@ void prune_impl(const proto::ProgramDesc& input, proto::ProgramDesc* output,
90
90
std::vector<bool > should_run;
91
91
for (auto op_iter = ops.rbegin (); op_iter != ops.rend (); ++op_iter) {
92
92
auto & op_desc = *op_iter;
93
- if (IsTarget (op_desc) || HasDependentVar (op_desc, dependent_vars)) {
93
+ if (IsTarget (op_desc) || HasDependentVar (op_desc, * dependent_vars)) {
94
94
// insert its input to the dependency graph
95
95
for (auto & var : op_desc.inputs ()) {
96
96
for (auto & argu : var.arguments ()) {
97
- dependent_vars. insert (argu);
97
+ dependent_vars-> insert (argu);
98
98
}
99
99
}
100
100
should_run.push_back (true );
@@ -138,7 +138,7 @@ void prune_impl(const proto::ProgramDesc& input, proto::ProgramDesc* output,
138
138
// GetSubBlockIndex(*op) is the idx of the sub_block in the input desc
139
139
// output_block_id is the idx of the current block in the output desc
140
140
prune_impl (input, output, GetSubBlockIndex (*op), output_block_id,
141
- sub_block_dependent_vars);
141
+ & sub_block_dependent_vars);
142
142
}
143
143
}
144
144
}
@@ -181,7 +181,7 @@ void prune_impl(const proto::ProgramDesc& input, proto::ProgramDesc* output,
181
181
void Prune (const proto::ProgramDesc& input, proto::ProgramDesc* output) {
182
182
std::set<std::string> dependent_vars;
183
183
output->clear_blocks ();
184
- prune_impl (input, output, 0 , -1 , dependent_vars);
184
+ prune_impl (input, output, 0 , -1 , & dependent_vars);
185
185
}
186
186
187
187
void inference_optimize_impl (proto::ProgramDesc* input, int block_id) {
0 commit comments