Skip to content

Commit 759dae0

Browse files
authored
Merge pull request #13461 from panyx0718/ir3
clean unused inference_optimize c++ implementation
2 parents fd8d83e + 5ce7788 commit 759dae0

File tree

4 files changed

+0
-33
lines changed

4 files changed

+0
-33
lines changed

paddle/fluid/framework/prune.cc

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -183,28 +183,5 @@ void Prune(const proto::ProgramDesc& input, proto::ProgramDesc* output) {
183183
output->clear_blocks();
184184
prune_impl(input, output, 0, -1, &dependent_vars);
185185
}
186-
187-
void inference_optimize_impl(proto::ProgramDesc* input, int block_id) {
188-
auto* op_field = input->mutable_blocks(block_id)->mutable_ops();
189-
for (auto& op_desc : *op_field) {
190-
for (auto& attr : *op_desc.mutable_attrs()) {
191-
if (attr.name() == "is_test") {
192-
attr.set_b(true);
193-
break;
194-
}
195-
}
196-
}
197-
}
198-
199-
void InferenceOptimize(const proto::ProgramDesc& input,
200-
proto::ProgramDesc* output) {
201-
*output = input;
202-
int num_blocks = output->blocks_size();
203-
PADDLE_ENFORCE_GT(num_blocks, 0, "ProgramDesc must have at least one block");
204-
for (int i = 0; i < num_blocks; ++i) {
205-
inference_optimize_impl(output, i);
206-
}
207-
}
208-
209186
} // namespace framework
210187
} // namespace paddle

paddle/fluid/framework/prune.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,5 @@ namespace framework {
2222

2323
void Prune(const proto::ProgramDesc& input, proto::ProgramDesc* output);
2424

25-
void InferenceOptimize(const proto::ProgramDesc& input,
26-
proto::ProgramDesc* output);
27-
2825
} // namespace framework
2926
} // namespace paddle

paddle/fluid/pybind/pybind.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,6 @@ All parameter, weight, gradient are variables in Paddle.
396396
Prune(*prog_with_targets.Proto(), &pruned_desc);
397397
return new ProgramDesc(pruned_desc);
398398
});
399-
m.def("inference_optimize", [](ProgramDesc &origin) {
400-
proto::ProgramDesc pruned_desc;
401-
InferenceOptimize(*(origin.Proto()), &pruned_desc);
402-
return new ProgramDesc(pruned_desc);
403-
});
404399
m.def("empty_var_name",
405400
[]() { return std::string(framework::kEmptyVarName); });
406401
m.def("grad_var_suffix",

python/paddle/fluid/framework.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,8 +1738,6 @@ def _inference_optimize(self, export_for_deployment=True):
17381738
Returns:
17391739
Program: The new program.
17401740
"""
1741-
# this is an alternative implement before
1742-
# core.inference_optimize being fixed.
17431741
res = Program()
17441742
res.desc = core.ProgramDesc(self.desc)
17451743

0 commit comments

Comments
 (0)