Skip to content

[DataPipe] Add container template for _Fork and _Demux#89216

Closed
ejguan wants to merge 2 commits intopytorch:masterfrom
ejguan:template_parent
Closed

[DataPipe] Add container template for _Fork and _Demux#89216
ejguan wants to merge 2 commits intopytorch:masterfrom
ejguan:template_parent

Conversation

@ejguan
Copy link
Contributor

@ejguan ejguan commented Nov 17, 2022

  • This would remove the hard-coded check within _ChildDataPipe.
  • Add get_length_by_instance to parent class to make sure there is a chance that child DataPipe can have different lengths
  • Prevent Error when __del__ executed when the object has already been removed

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 17, 2022

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/89216

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 2 Pending

As of commit 30e5d2e:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@ejguan ejguan requested a review from NivekT November 17, 2022 15:56
@pytorch-bot pytorch-bot bot added the release notes: dataloader release notes category label Nov 17, 2022
@ejguan ejguan added the topic: improvements topic category label Nov 17, 2022
Copy link
Contributor

@NivekT NivekT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

Comment on lines +117 to +121
@abstractmethod
def get_length_by_instance(self, instance_id: int):
r"""
Raise TypeError if it's not supposed to be implemented to support `list(datapipe)`
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add another method to add the functionality to provide different length per Child.
cc: @NivekT
I need it for demux have a deterministic classifier_fn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meta-pytorch/data#903 is an example of the usage of get_length_by_instance.

@facebook-github-bot
Copy link
Contributor

@ejguan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 17, 2022
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

facebook-github-bot pushed a commit to meta-pytorch/data that referenced this pull request Nov 21, 2022
Summary:
The only reason I added this DataPipe without directly using `enumereate().demux().drop_index()` is this `RoundRobinDemux` should provide a valid length. So, this PR needs pytorch/pytorch#89216 landed

And, this DataPipe will be used for `Proto2RS`.

Side change: Move `Unzip` to `combining.py` as well.

Pull Request resolved: #903

Reviewed By: wenleix

Differential Revision: D41387813

Pulled By: ejguan

fbshipit-source-id: b3a5939763b53875dd223809041ad8d0337b1bda
kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Dec 10, 2022
- This would remove the hard-coded check within `_ChildDataPipe`.
- Add `get_length_by_instance` to parent class to make sure there is a chance that child DataPipe can have different lengths
- Prevent Error when `__del__` executed when the object has already been removed
Pull Request resolved: pytorch#89216
Approved by: https://github.com/NivekT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: dataloader release notes category topic: improvements topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants