You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was going through the code of DeepSpeedDataLoader and noticed that the DataLoader constuctor are called seperately to create a DataLoader object determined by if statements.
def_create_dataloader(self):
self.dataloader=DataLoader(
self.dataset,
batch_size=self.batch_size,
pin_memory=self.pin_memory,
sampler=self.data_sampler,
collate_fn=self.collate_fn, # self.collate_fn is default to be None anywaysnum_workers=self.num_local_io_workers,
drop_last=self.dataloader_drop_lastifself.curriculum_learning_enabledelseFalse# drop_last is default to be False
)
ifself.curriculum_learning_enabled:
self.data_iterator=iter(self.dataloader)
returnself.dataloaderelse:
self.data= (xforxinself.dataloader)
returnself.dataloader
The code would be much more readable.
So as a new learner, I'm just curious. What is the purpose of the seemingly repetitive code? Is it to make sure that the default values of params in torch.utils.data.DataLoader would not be messed up in case they are changed by PyTorch team?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was going through the code of
DeepSpeedDataLoader
and noticed that theDataLoader
constuctor are called seperately to create aDataLoader
object determined byif
statements.DeepSpeed/deepspeed/runtime/dataloader.py
Lines 126 to 159 in 3324efd
Why not just:
The code would be much more readable.
So as a new learner, I'm just curious. What is the purpose of the seemingly repetitive code? Is it to make sure that the default values of params in
torch.utils.data.DataLoader
would not be messed up in case they are changed by PyTorch team?Beta Was this translation helpful? Give feedback.
All reactions