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

[WIP][mxnet 2.0] Pure C++ threaded dataloader that shared the interface with gluon dataloader #17464

Closed
wants to merge 92 commits into from

Conversation

zhreshold
Copy link
Member

Description

This is the implementation for proposal #17269

The coverage for dataset types are still limited but minimal examples are already available.

import time
import mxnet as mx
from mxnet.gluon.data.dataloader import no_mx_iter, DataLoader
from mxnet.gluon.data.vision.transforms import ToTensor

dataset = mx.gluon.data.vision.CIFAR10()
cpp_dl = DataLoader(dataset.transform_first(ToTensor()), batch_size=32, num_workers=8)
start = time.time()
for _ in range(5):
  print(len(cpp_dl))
  for _ in cpp_dl:
    pass
print('Elapsed time for backend dataloader:', time.time() - start)

with no_mx_iter:
  dl = DataLoader(dataset.transform_first(ToTensor()), batch_size=32, num_workers=8)
start = time.time()
for _ in range(5):
  print(len(dl))
  for _ in dl:
    pass
print('Elapsed time for python multiprocess dataloader:', time.time() - start)

C++ backend loader is roughly 2x faster even for a simple workload.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@zhreshold
Copy link
Member Author

reopened another PR and closing this one: see #17841

@zhreshold zhreshold closed this Mar 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants