Skip to content

Commit 684d152

Browse files
jungwhanktchaton
authored andcommitted
Fix torchtext data to gpu (#4785)
Co-authored-by: chaton <[email protected]> (cherry picked from commit 471ca37)
1 parent 4658299 commit 684d152

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pytorch_lightning/utilities/apply_func.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def batch_to(data):
113113

114114
# Shallow copy because each Batch has a reference to Dataset which contains all examples
115115
device_data = copy(data)
116-
for field in data.fields:
116+
for field, field_value in data.dataset.fields.items():
117+
if field_value is None:
118+
continue
117119
device_field = move_data_to_device(getattr(data, field), device)
118120
setattr(device_data, field, device_field)
119121
return device_data

0 commit comments

Comments
 (0)