提交 8bab1b5a 编写于 作者: R Ralf W. Grosse-Kunstleve 提交者: TensorFlower Gardener

xla/python/py_values.cc GIL-not-held fix: `DevicePutResult` can be copied only with the GIL held.

PiperOrigin-RevId: 481042256
上级 3d977755
......@@ -196,13 +196,16 @@ StatusOr<DevicePutResult> HandleNumpyArray(py::handle h, PjRtDevice* to_device,
}
// Must release the GIL before BufferFromHostBuffer because backends may
// decide to block/sleep for device buffer allocation.
py::gil_scoped_release gil_release;
TF_ASSIGN_OR_RETURN(
auto buffer,
to_device->client()->BufferFromHostBuffer(
data, squashed_type, dims, byte_strides, host_buffer_semantics,
std::move(on_done_with_host_buffer), to_device));
return DevicePutResult(std::move(buffer), /*weak_type=*/false);
StatusOr<std::unique_ptr<PjRtBuffer>> buffer;
{
py::gil_scoped_release gil_release;
TF_ASSIGN_OR_RETURN(
buffer,
to_device->client()->BufferFromHostBuffer(
data, squashed_type, dims, byte_strides, host_buffer_semantics,
std::move(on_done_with_host_buffer), to_device));
}
return DevicePutResult(std::move(buffer.value()), /*weak_type=*/false);
}
StatusOr<DevicePutResult> PyBufferHelper(py::handle obj, py::handle py_buffer,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册