Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DensePaddingDataLoader for flexible (padded) dense batching of BaseData objects #8518

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

amorehead
Copy link
Contributor

@amorehead amorehead commented Dec 4, 2023

🚀 The new functionality, motivation and pitch

  • This PR adds a new DensePaddingDataLoader class that enables flexible dense batching of BaseData objects.
  • Such functionality supports fast and direct conversion of PyG Data or HeteroData objects into CV/NLP-driven (dense-batching) model training pipelines.

Alternatives

No alternatives exist for this functionality, including PyG's DenseDataLoader which assumes each (sub)graph's node count must be identical to all other (sub)graphs.

Additional context

This new data loader enables one to easily experiment with message passing algorithms that operate on dense tensor representations of batched graph objects without having to redesign one's PyG-driven Dataset class. This idea was initiated per #8516 and raised as an issue in #8517.

@amorehead amorehead requested review from mananshah99 and a team as code owners December 4, 2023 03:29
Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Attention: Patch coverage is 0% with 169 lines in your changes are missing coverage. Please review.

Project coverage is 89.08%. Comparing base (2fcd29d) to head (6cef254).
Report is 2 commits behind head on master.

Files Patch % Lines
...orch_geometric/loader/dense_padding_data_loader.py 0.00% 169 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8518      +/-   ##
==========================================
- Coverage   90.02%   89.08%   -0.94%     
==========================================
  Files         470      471       +1     
  Lines       30164    30333     +169     
==========================================
- Hits        27154    27022     -132     
- Misses       3010     3311     +301     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

return batch


class DensePaddingCollater:
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the PR. It looks like we now have multiple places that dictate how to collate or pad attributes from data objects. I wonder if we can re-use existing code from there, e.g., we have the PadTransform, that already does most of what you have written here. Do you think there is a chance to re-use some of this logic for this PR?

Copy link
Contributor Author

@amorehead amorehead Dec 6, 2023

Choose a reason for hiding this comment

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

Hi, @rusty1s. It's possible we may be able to reuse existing assets here. I'm not too familiar with the PadTransform utility. Does it already support padding both float and non-float (e.g., int, bool) tensors?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that should be supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants