Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Add worker_fn argument to multiworker function (#12177)
Browse files Browse the repository at this point in the history
* add worker_fn argument to multiworker function

* fix pylin
  • Loading branch information
szhengac authored and zhreshold committed Aug 15, 2018
1 parent b95835a commit cd6b1cb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/mxnet/gluon/data/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ def fetcher_loop(data_queue, data_buffer, pin_memory=False):

class _MultiWorkerIter(object):
"""Interal multi-worker iterator for DataLoader."""
def __init__(self, num_workers, dataset, batchify_fn, batch_sampler, pin_memory=False):
def __init__(self, num_workers, dataset, batchify_fn, batch_sampler, pin_memory=False,
worker_fn=worker_loop):
assert num_workers > 0, "_MultiWorkerIter is not for {} workers".format(num_workers)
self._num_workers = num_workers
self._dataset = dataset
Expand All @@ -200,7 +201,7 @@ def __init__(self, num_workers, dataset, batchify_fn, batch_sampler, pin_memory=
workers = []
for _ in range(self._num_workers):
worker = multiprocessing.Process(
target=worker_loop,
target=worker_fn,
args=(self._dataset, self._key_queue, self._data_queue, self._batchify_fn))
worker.daemon = True
worker.start()
Expand Down

0 comments on commit cd6b1cb

Please sign in to comment.