PyG's Data.to(device) function behaves differently from PyTorch #5433
Boltzmachine
started this conversation in
General
Replies: 1 comment 1 reply
-
In PyG, import copy
>>> data = Data(x=torch.tensor(1))
>>> data2 = copy.copy(data)
>>> data.to('cuda').x.device
device(type='cuda', index=0)
>>> data2.x.device
device(type='cpu') |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In PyTorch, we now when
data
is a tensor, theto(device)
function will return a copy, for example:Howevew, if
data
is a PyG Data object, theto(device)
function will inplace change the device of original data object, for exampleIs there any reason for such design. And what is the correct way if I want to make a cuda copy from PyG data in CPU.
Beta Was this translation helpful? Give feedback.
All reactions