torch.tensor.to()

image
image
image

tensor = torch.randn(2, 2)  # Initially dtype=float32, device=cpu
tensor.to(torch.float64)

cuda0 = torch.device('cuda:0')
tensor.to(cuda0)

tensor.to(cuda0, dtype=torch.float64)

other = torch.randn((), dtype=torch.float64, device=cuda0)
tensor.to(other, non_blocking=True)

posted on 2022-12-08 19:23  朴素贝叶斯  阅读(133)  评论(0编辑  收藏  举报

导航