[XLA:Python] Fix potential issue in CopyToDevice where source device buffer might get deallocated before transfer completes.
PiperOrigin-RevId: 257216762
This commit is contained in:
parent
4bb0f6e87f
commit
af8772fa69
@ -652,6 +652,10 @@ StatusOr<std::unique_ptr<PyLocalBuffer>> PyLocalBuffer::CopyToDevice(
|
||||
output_buffer));
|
||||
}
|
||||
|
||||
// We hold on to the `src_device_buffer` until the transfer is finished.
|
||||
src_device.ThenRelease(src_device_to_device_stream,
|
||||
std::move(src_device_buffer));
|
||||
|
||||
// Write new tuple buffers. The destination buffers have different addresses,
|
||||
// so we must construct tuple buffers from scratch instead of copying them.
|
||||
if (dst_buffer.on_device_shape().IsTuple()) {
|
||||
|
Loading…
Reference in New Issue
Block a user