Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#1552 from joey12300/fix_delete_pass
Browse files Browse the repository at this point in the history
[Backend] Fix delete pass of paddle inference
  • Loading branch information
joey12300 authored Mar 8, 2023
2 parents 6be2c03 + 384eca1 commit f4736e7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions fastdeploy/runtime/backends/paddle/paddle_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ void PaddleBackend::BuildOption(const PaddleBackendOption& option) {
if (!option.enable_log_info) {
config_.DisableGlogInfo();
}
if (!option.delete_pass_names.empty()) {
auto pass_builder = config_.pass_builder();
for (int i = 0; i < option.delete_pass_names.size(); i++) {
FDINFO << "Delete pass : " << option.delete_pass_names[i] << std::endl;
pass_builder->DeletePass(option.delete_pass_names[i]);
}
}
if (option.cpu_thread_num <= 0) {
config_.SetCpuMathLibraryNumThreads(8);
} else {
Expand Down Expand Up @@ -239,6 +232,15 @@ bool PaddleBackend::InitFromPaddle(const std::string& model_buffer,
<< " to set TensorRT dynamic shape." << std::endl;
config_.EnableTunedTensorRtDynamicShape(shape_range_info, false);
}
// Note(zhoushunjie): The pass deletion should be executed just before
// creating predictor.
if (!option.delete_pass_names.empty()) {
auto pass_builder = config_.pass_builder();
for (int i = 0; i < option.delete_pass_names.size(); i++) {
FDINFO << "Delete pass : " << option.delete_pass_names[i] << std::endl;
pass_builder->DeletePass(option.delete_pass_names[i]);
}
}
predictor_ = paddle_infer::CreatePredictor(config_);
initialized_ = true;
return true;
Expand Down

0 comments on commit f4736e7

Please sign in to comment.