mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
[Core] Drop GIL in THPVariable_item around aten op (#104103)
This can cause a deadlock by starving other python threads required for the kernel to make progress. Pull Request resolved: https://github.com/pytorch/pytorch/pull/104103 Approved by: https://github.com/albanD
This commit is contained in:
parent
b5d1b42f99
commit
93e63fc0f6
1 changed files with 5 additions and 1 deletions
|
|
@ -875,7 +875,11 @@ static PyObject * THPVariable_item(PyObject* self, PyObject* args)
|
|||
}
|
||||
jit::tracer::warn("Converting a tensor to a Python number", jit::tracer::WARN_PYTHON_DATAFLOW);
|
||||
auto& self_ = THPVariable_Unpack(self);
|
||||
return py::cast(self_.item()).release().ptr();
|
||||
auto dispatch_item_ = [](const Tensor& self) -> at::Scalar {
|
||||
pybind11::gil_scoped_release no_gil;
|
||||
return self.item();
|
||||
};
|
||||
return py::cast(dispatch_item_(self_)).release().ptr();
|
||||
END_HANDLE_TH_ERRORS
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue