diff --git a/paddle/pybind/CMakeLists.txt b/paddle/pybind/CMakeLists.txt index b8fc9347243ac490efcb09132f4b049c6e9f8e08..46c24e2cd53c068a25e1a5c8c6df600c3111e20a 100644 --- a/paddle/pybind/CMakeLists.txt +++ b/paddle/pybind/CMakeLists.txt @@ -1,6 +1,6 @@ if(WITH_PYTHON) cc_library(paddle_pybind SHARED SRCS pybind.cc exception.cc protobuf.cc - DEPS pybind python backward proto_desc tensor_array paddle_memory + DEPS pybind python backward proto_desc tensor_array paddle_memory executor ${GLOB_OP_LIB}) endif(WITH_PYTHON) diff --git a/paddle/pybind/pybind.cc b/paddle/pybind/pybind.cc index b143cb9f59d3b734bcbec30c8a69dc85b5a10c97..afc80b25b185509739edcd0d06817aa1d507a8ec 100644 --- a/paddle/pybind/pybind.cc +++ b/paddle/pybind/pybind.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/pybind/protobuf.h" #include "paddle/framework/backward.h" +#include "paddle/framework/executor.h" #include "paddle/framework/lod_tensor.h" #include "paddle/framework/tensor_array.h" #include "paddle/operators/cond_op.h" @@ -391,6 +392,14 @@ All parameter, weight, gradient are variables in Paddle. self.set_falsenet(net.Clone()); }); + py::class_(m, "Executor") + .def(py::init &>()) + .def("run", + [](Executor &self, const ProgramDesc &program_desc, int block_id) { + framework::Scope &global_scope = GetGlobalScope(); + self.Run(program_desc, &global_scope, block_id); + }); + m.def("unique_integer", UniqueIntegerGenerator); m.def("is_compile_gpu", IsCompileGPU);