未验证 提交 326bf829 编写于 作者: G guru4elephant 提交者: GitHub

add Run Prepared Ctx (#17616)

add Run Prepared Ctx, fix pybind problem
上级 e8990e64
...@@ -1052,6 +1052,14 @@ All parameter, weight, gradient are variables in Paddle. ...@@ -1052,6 +1052,14 @@ All parameter, weight, gradient are variables in Paddle.
create_local_scope, create_vars, create_local_scope, create_vars,
feed_holder_name, fetch_holder_name); feed_holder_name, fetch_holder_name);
}) })
.def("run_cached_prepared_ctx",
[](Executor &self, ExecutorPrepareContext *ctx, Scope *scope,
bool create_local_scope = true, bool create_vars = true,
bool keep_kids = false) {
pybind11::gil_scoped_release release;
self.RunPreparedContext(ctx, scope, create_local_scope,
create_vars, keep_kids);
})
.def("prepare_ctx_cache", &Executor::PrepareCtxCache, .def("prepare_ctx_cache", &Executor::PrepareCtxCache,
py::call_guard<py::gil_scoped_release>()) py::call_guard<py::gil_scoped_release>())
.def("run", [](Executor &self, const ProgramDesc &prog, Scope *scope, .def("run", [](Executor &self, const ProgramDesc &prog, Scope *scope,
......
...@@ -719,7 +719,7 @@ class Executor(object): ...@@ -719,7 +719,7 @@ class Executor(object):
if not use_program_cache: if not use_program_cache:
exe.run(program.desc, scope, 0, True, True, fetch_var_name) exe.run(program.desc, scope, 0, True, True, fetch_var_name)
else: else:
exe.run_prepared_ctx(ctx, scope, True, True, False) exe.run_cached_prepared_ctx(ctx, scope, True, True, False)
outs = self._fetch_data(fetch_list, fetch_var_name, scope) outs = self._fetch_data(fetch_list, fetch_var_name, scope)
if return_numpy: if return_numpy:
outs = as_numpy(outs) outs = as_numpy(outs)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册