mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-10 12:21:57 +08:00
fix tpu transfer bug
This commit is contained in:
@@ -436,20 +436,20 @@ class TrainerDPMixin(ABC):
|
||||
# when list
|
||||
if isinstance(batch, list):
|
||||
for i, x in enumerate(batch):
|
||||
batch[i] = self.transfer_batch_to_tpu(x)
|
||||
batch[i] = self.__transfer_data_to_device(x, device, gpu_id)
|
||||
return batch
|
||||
|
||||
# when tuple
|
||||
if isinstance(batch, tuple):
|
||||
batch = list(batch)
|
||||
for i, x in enumerate(batch):
|
||||
batch[i] = self.transfer_batch_to_tpu(x)
|
||||
batch[i] = self.__transfer_data_to_device(x, device, gpu_id)
|
||||
return tuple(batch)
|
||||
|
||||
# when dict
|
||||
if isinstance(batch, dict):
|
||||
for k, v in batch.items():
|
||||
batch[k] = self.transfer_batch_to_tpu(v)
|
||||
batch[k] = self.__transfer_data_to_device(x, device, gpu_id)
|
||||
|
||||
return batch
|
||||
|
||||
|
||||
Reference in New Issue
Block a user