-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[bugfix] Add set_default_tensor_type to torch.DoubleTensor with precision=64 #7108
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
Conversation
ethanwharris
left a comment
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.
LGTM 😃
Codecov Report
@@ Coverage Diff @@
## master #7108 +/- ##
=======================================
- Coverage 92% 90% -2%
=======================================
Files 197 197
Lines 12634 12982 +348
=======================================
+ Hits 11649 11697 +48
- Misses 985 1285 +300 |
| """A contextmanager for the trainstep""" | ||
| torch.set_default_tensor_type(torch.DoubleTensor) | ||
| yield | ||
| torch.set_default_tensor_type(torch.FloatTensor) |
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.
shall you rather save what was it before and then set it back?
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.
I think it should be fine. Didn't find any utils to get the default either.
Co-authored-by: Carlos Mocholí <[email protected]>
Co-authored-by: Carlos Mocholí <[email protected]>
Co-authored-by: Carlos Mocholí <[email protected]>
| train_step_context = tensor_type_context | ||
| val_step_context = tensor_type_context | ||
| test_step_context = tensor_type_context | ||
| predict_step_context = tensor_type_context |
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.
@tchaton this is breaking the plugin typechecks with mypy:
pytorch_lightning/plugins/precision/double.py:105: error: Incompatible types in assignment (expression has type "Callable[[], _GeneratorContextManager[Any]]", base class "Plugin" defined the type as "Callable[[], Generator[Any, Any, Any]]") [assignment]
pytorch_lightning/plugins/precision/double.py:106: error: Incompatible types in assignment (expression has type "Callable[[], _GeneratorContextManager[Any]]", base class "Plugin" defined the type as "Callable[[], Generator[Any, Any, Any]]") [assignment]
pytorch_lightning/plugins/precision/double.py:107: error: Incompatible types in assignment (expression has type "Callable[[], _GeneratorContextManager[Any]]", base class "Plugin" defined the type as "Callable[[], Generator[Any, Any, Any]]") [assignment]
pytorch_lightning/plugins/precision/double.py:108: error: Incompatible types in assignment (expression has type "Callable[[], _GeneratorContextManager[Any]]", base class "Plugin" defined the type as "Callable[[], Generator[Any, Any, Any]]") [assignment]
rather than overriding these step contexts, could we share the same implementation?
What does this PR do?
c.f title.
Fixes #6927
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:
Did you have fun?
Make sure you had fun coding 🙃