torch.Tensor.cuda
- Tensor.cuda(device=None, non_blocking=False, memory_format=torch.preserve_format) → Tensor
-
返回该对象在CUDA内存中的副本。
如果该对象已存在于CUDA内存且位于正确设备上,则不会进行复制操作,直接返回原对象。
- 参数
-
-
device (
torch.device
) – 指定目标GPU设备。默认使用当前的CUDA设备。 -
non_blocking (bool) – 如果源位于 pinned 内存中且参数为
True
,复制操作将相对于主机异步执行。否则,该参数无效。默认值:False
。 -
memory_format (
torch.memory_format
, 可选) – 指定返回的张量的内存格式。默认值为:torch.preserve_format
。
-