Skip to content

Commit

Permalink
correct condition
Browse files Browse the repository at this point in the history
  • Loading branch information
b3602sss committed Jun 3, 2021
1 parent 1b52f22 commit 2d2999e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions paddle/fluid/inference/api/analysis_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,16 @@ static bool IsPrepareDataOptTargetOp(framework::OpDesc *op) {
}

static void DisablePrepareDataOpt(
std::shared_ptr<framework::ProgramDesc> inference_program, int block) {
std::shared_ptr<framework::ProgramDesc> inference_program, int block,
bool pre_disable_opt) {
bool disable_opt = false;
for (auto *op : inference_program->Block(block).AllOps()) {
if (disable_opt) {
if (disable_opt || pre_disable_opt) {
op->SetAttr("inference_force_prepare_data", true);
}
if (op->HasAttr("sub_block")) {
int blockID = op->GetBlockAttrId("sub_block");
DisablePrepareDataOpt(inference_program, blockID);
DisablePrepareDataOpt(inference_program, blockID, disable_opt);
}
if (IsPrepareDataOptTargetOp(op)) {
disable_opt = true;
Expand All @@ -306,7 +307,7 @@ static void DisablePrepareDataOpt(
}

bool AnalysisPredictor::PrepareExecutor() {
DisablePrepareDataOpt(inference_program_, 0);
DisablePrepareDataOpt(inference_program_, 0, false);

executor_->Prepare(sub_scope_, *inference_program_, 0,
config_.use_feed_fetch_ops_);
Expand Down

0 comments on commit 2d2999e

Please sign in to comment.