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

Don't convert namedtuple to tuple #1589

Merged

Conversation

nathanbreitsch
Copy link
Contributor

@nathanbreitsch nathanbreitsch commented Apr 24, 2020

Before submitting

This is just a proposed solution for sending namedtuples to the GPU without converting them to regular tuples. I am open to suggestions.

Sending data to devices seems to fit the pattern of recursively doing a thing to the elements of contaners. Good examples of this are default_collate and default_convert in pytorch.
https://github.com/pytorch/pytorch/blob/master/torch/utils/data/_utils/collate.py#L15

We could take this PR further by following the pattern in pytorch so that lightning works with all the same types. On the other hand, I'm not sure if this pattern satisfies the 'Simple code' requirement.

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

What does this PR do?

Fixes #1588

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Apr 24, 2020

Hello @nathanbreitsch! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-04-29 01:40:41 UTC

@mergify mergify bot requested a review from a team April 24, 2020 03:50
Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

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

Can you also add a test case for this?

@mergify mergify bot requested a review from a team April 24, 2020 07:28
@Borda Borda added the feature Is an improvement or enhancement label Apr 24, 2020
@Borda Borda added this to the 0.7.5 milestone Apr 24, 2020
@Borda Borda added the waiting on author Waiting on user action, correction, or update label Apr 25, 2020
@nathanbreitsch nathanbreitsch force-pushed the bugs/namedtuple-to-gpu branch 2 times, most recently from 2efd6b4 to 7ad55ab Compare April 29, 2020 01:17
@nathanbreitsch nathanbreitsch force-pushed the bugs/namedtuple-to-gpu branch from 7ad55ab to 706517a Compare April 29, 2020 01:40
@codecov
Copy link

codecov bot commented Apr 29, 2020

Codecov Report

Merging #1589 into master will increase coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #1589   +/-   ##
======================================
  Coverage      88%     88%           
======================================
  Files          71      71           
  Lines        4175    4178    +3     
======================================
+ Hits         3691    3694    +3     
  Misses        484     484           

@williamFalcon williamFalcon merged commit 3eac6cf into Lightning-AI:master Apr 30, 2020
@williamFalcon
Copy link
Contributor

@nathanbreitsch awesome!

@Borda Borda removed the waiting on author Waiting on user action, correction, or update label Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Named converted to regular tuples when sent to the gpu.
5 participants