fix python parallel gil
This commit is contained in:
parent
64e44c6e73
commit
1dbe4a6db2
|
@ -116,12 +116,15 @@ void ModelPyBind(const py::module &m) {
|
||||||
.def("get_outputs", &ModelParallelRunner::GetOutputs)
|
.def("get_outputs", &ModelParallelRunner::GetOutputs)
|
||||||
.def("predict", [](ModelParallelRunner &runner, const std::vector<MSTensor> &inputs, std::vector<MSTensor> *outputs,
|
.def("predict", [](ModelParallelRunner &runner, const std::vector<MSTensor> &inputs, std::vector<MSTensor> *outputs,
|
||||||
const MSKernelCallBack &before = nullptr, const MSKernelCallBack &after = nullptr) {
|
const MSKernelCallBack &before = nullptr, const MSKernelCallBack &after = nullptr) {
|
||||||
auto status = runner.Predict(inputs, outputs, before, after);
|
{
|
||||||
if (status != kSuccess) {
|
py::gil_scoped_release release;
|
||||||
std::vector<MSTensor> empty;
|
auto status = runner.Predict(inputs, outputs, before, after);
|
||||||
return empty;
|
if (status != kSuccess) {
|
||||||
|
std::vector<MSTensor> empty;
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
return *outputs;
|
||||||
}
|
}
|
||||||
return *outputs;
|
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue