From 29ef7cc9375f07e758ba7350d5424eba0f950b86 Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Wed, 15 Sep 2021 22:02:27 -0500 Subject: [PATCH] add run interface for standalone executor, test=develop (#35761) --- paddle/fluid/pybind/pybind.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index f797ed5142c..f56968d5c28 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -1992,6 +1992,26 @@ All parameter, weight, gradient are variables in Paddle. feed_tensors.push_back(t); } + paddle::framework::FetchList ret; + { + pybind11::gil_scoped_release release; + ret = self.Run(feed_names, feed_tensors, fetch_names); + } + return py::cast(std::move(ret)); + }) + .def("run", + [](StandaloneExecutor &self, + const std::unordered_map + &input_dict, + std::vector fetch_names) { + std::vector feed_tensors; + std::vector feed_names; + + for (auto &item : input_dict) { + feed_names.push_back(item.first); + feed_tensors.push_back(item.second); + } + paddle::framework::FetchList ret; { pybind11::gil_scoped_release release; -- GitLab