-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix lost compatibility with custom datatypes implementing .to
#2335
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2335 +/- ##
======================================
- Coverage 88% 88% -0%
======================================
Files 70 70
Lines 5512 5519 +7
======================================
+ Hits 4851 4857 +6
- Misses 661 662 +1 |
@@ -38,14 +39,43 @@ def apply_to_collection(data: Any, dtype: Union[type, tuple], function: Callable | |||
return data | |||
|
|||
|
|||
class TransferableDataType(ABC): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case someone has a suggestion for a better name, let me know :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc: @williamFalcon
nice! great catch |
What does this PR do?
Fixes #2314
When I refactored the data transfer and added a model hook in #1756, I accidentally removed the ability to move non-tensor datastructures that implement
.to()
. This PR re-enables that via a duck typing check. For this type of data, the user is not required to override the hook, since PL can handle this out of the box now.The test alone fails on master, confirming that the changes here fix the bug.
Before submitting
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 🙃