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

Add worker_fn argument to multiworker function #12177

Merged
merged 2 commits into from
Aug 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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