torch.Tensor.copy_#
- Tensor.copy_(src, non_blocking=False) Tensor#
Copies the elements from
srcintoselftensor and returnsself.The
srctensor must be broadcastable with theselftensor. It may be of a different data type or reside on a different device.See Device-to-host copies on NVLink-C2C systems for guidance on repeated CUDA-to-CPU transfers and reusing CPU buffers.
- Parameters:
Note
When
non_blockingisTrueand the copy is issued on a non-default CUDA stream, the caller is responsible for proper cross-stream synchronization. See CUDA streams for the required pattern.