We have to.dtype_layout, to.device, to.dtype, to.other. I use gdb to trace and find that it calls to.dtype_layout instead of to.device.
import torch

a = torch.Tensor([1,2,3]).to("cuda")

image797×381 10.6 KB