Skip to content

Commit

Permalink
Adding ability to use dill to pass DataPipes in mutiprocessing (#77288)
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/pytorch#77288

Fixes part of #397 (only DataLoader v2 remaining)

Reviewed By: NivekT, ejguan

Differential Revision: D36347737

Pulled By: VitalyFedyunin

fbshipit-source-id: 144d149f1da98b7108f54e9dcecda0f5740d1eb9
  • Loading branch information
VitalyFedyunin authored and facebook-github-bot committed May 15, 2022
1 parent 33b5f2f commit 3c77696
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions test/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,26 @@ def finalize_iteration(self) -> None:
dp.started = False


def _x_and_x_plus_5(x):
return [x, x + 5]


def _x_mod_2(x):
return x % 2


def _x_mult_2(x):
return x * 2


class TestGraph(expecttest.TestCase):
def _get_datapipes(self) -> Tuple[IterDataPipe, IterDataPipe, IterDataPipe]:
src_dp = IterableWrapper(range(20))
m1 = src_dp.map(lambda x: [x, x + 5])
m1 = src_dp.map(_x_and_x_plus_5)
ub = m1.unbatch()
c1, c2 = ub.demux(2, lambda x: x % 2)
c1, c2 = ub.demux(2, _x_mod_2)
dm = c1.main_datapipe
m2 = c1.map(lambda x: x * 2)
m2 = c1.map(_x_mult_2)
dp = m2.zip(c2)

return traverse(dp, only_datapipe=True), (src_dp, m1, ub, dm, c1, c2, m2, dp)
Expand Down

0 comments on commit 3c77696

Please sign in to comment.