未验证 提交 78415f32 编写于 作者: X Xin Pan 提交者: GitHub

Merge pull request #12838 from panyx0718/infer

speed up while_op
......@@ -57,12 +57,12 @@ class WhileOp : public framework::OperatorBase {
PADDLE_ENFORCE(platform::is_cpu_place(cond.place()),
"Condition of while op must in CPU memory.");
auto ctx = executor.Prepare(*program, block->ID());
while (cond.data<bool>()[0]) {
auto &current_scope = scope.NewScope();
step_scopes->push_back(&current_scope);
executor.Run(*program, &current_scope, block->ID(),
false /*create_local_scope*/);
executor.RunPreparedContext(ctx.get(), &current_scope, false);
}
}
};
......@@ -109,6 +109,7 @@ class WhileGradOp : public framework::OperatorBase {
framework::Executor executor(dev_place);
auto *block = Attr<framework::BlockDesc *>(kStepBlock);
auto *program = block->Program();
auto ctx = executor.Prepare(*program, block->ID());
auto *step_scopes =
scope.FindVar(Input(kStepScopes))->GetMutable<StepScopeVar>();
......@@ -161,8 +162,7 @@ class WhileGradOp : public framework::OperatorBase {
}
}
}
executor.Run(*program, *cur_scope_iter, block->ID(), false);
executor.RunPreparedContext(ctx.get(), *cur_scope_iter, false);
auto &pg_names = Outputs(kXGRAD);
auto &p_names = Inputs(kX);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册