Skip to content

Commit cb44b81

Browse files
committed
Moved num_workers ValueError
1 parent 9ec9be1 commit cb44b81

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

torch/utils/data/dataloader.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,6 @@ def __init__(self, loader):
219219
# prime the prefetch loop
220220
for _ in range(2 * self.num_workers):
221221
self._put_indices()
222-
elif self.num_workers < 0:
223-
raise ValueError('num_workers cannot be negative; '
224-
'use num_workers=0 to disable multiprocessing.')
225222

226223
def __len__(self):
227224
return len(self.batch_sampler)
@@ -364,6 +361,10 @@ def __init__(self, dataset, batch_size=1, shuffle=False, sampler=None, batch_sam
364361
if sampler is not None and shuffle:
365362
raise ValueError('sampler is mutually exclusive with shuffle')
366363

364+
if self.num_workers < 0:
365+
raise ValueError('num_workers cannot be negative; '
366+
'use num_workers=0 to disable multiprocessing.')
367+
367368
if batch_sampler is None:
368369
if sampler is None:
369370
if shuffle:

0 commit comments

Comments
 (0)