Skip to content

Commit

Permalink
batch to cuda (#3611)
Browse files Browse the repository at this point in the history
  • Loading branch information
rusty1s committed Feb 25, 2022
1 parent 95284c6 commit c549b3b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion torch_geometric/data/collate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def collate(
# elements as attributes that got incremented need to be decremented
# while separating to obtain original values.
device = None
print('---------------')
slice_dict, inc_dict = defaultdict(dict), defaultdict(dict)
for out_store in out.stores:
key = out_store._key
Expand All @@ -84,7 +85,8 @@ def collate(
value, slices, incs = _collate(attr, values, data_list, stores,
increment)

device = value.device if isinstance(value, Tensor) else device
if isinstance(value, Tensor) and value.is_cuda:
device = value.device

out_store[attr] = value
if key is not None:
Expand Down

0 comments on commit c549b3b

Please sign in to comment.