fix python parallel gil
This commit is contained in:
yefeng 2022-07-05 20:46:54 +08:00
parent 64e44c6e73
commit 1dbe4a6db2
1 changed files with 8 additions and 5 deletions

View File

@ -116,12 +116,15 @@ void ModelPyBind(const py::module &m) {
.def("get_outputs", &ModelParallelRunner::GetOutputs)
.def("predict", [](ModelParallelRunner &runner, const std::vector<MSTensor> &inputs, std::vector<MSTensor> *outputs,
const MSKernelCallBack &before = nullptr, const MSKernelCallBack &after = nullptr) {
auto status = runner.Predict(inputs, outputs, before, after);
if (status != kSuccess) {
std::vector<MSTensor> empty;
return empty;
{
py::gil_scoped_release release;
auto status = runner.Predict(inputs, outputs, before, after);
if (status != kSuccess) {
std::vector<MSTensor> empty;
return empty;
}
return *outputs;
}
return *outputs;
});
#endif
}