-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Relax dtype restrictions on torch.Tensor #73850
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
Previously, torch.Tensor was treated as if it were torch.FloatTensor (where Float is whatever the default dtype was). This is not good behavior for tensor subclasses, which inherit from torch.Tensor and will want to super() call into it and will only notice later that only float works as a dtype. So in this PR I relax the behavior for this case to make the torch.Tensor constructor more useful for subclasses. Signed-off-by: Edward Z. Yang <ezyang@fb.com> [ghstack-poisoned]
CI Flow Status⚛️ CI FlowRuleset - Version:
|
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 1ec06f7 (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
albanD
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.
test?
Previously, torch.Tensor was treated as if it were torch.FloatTensor (where Float is whatever the default dtype was). This is not good behavior for tensor subclasses, which inherit from torch.Tensor and will want to super() call into it and will only notice later that only float works as a dtype. So in this PR I relax the behavior for this case to make the torch.Tensor constructor more useful for subclasses. Signed-off-by: Edward Z. Yang <ezyangfb.com> [ghstack-poisoned]
Previously, torch.Tensor was treated as if it were torch.FloatTensor (where Float is whatever the default dtype was). This is not good behavior for tensor subclasses, which inherit from torch.Tensor and will want to super() call into it and will only notice later that only float works as a dtype. So in this PR I relax the behavior for this case to make the torch.Tensor constructor more useful for subclasses. Signed-off-by: Edward Z. Yang <ezyangfb.com> ghstack-source-id: 656b68b Pull Request resolved: #73850
Previously, torch.Tensor was treated as if it were torch.FloatTensor (where Float is whatever the default dtype was). This is not good behavior for tensor subclasses, which inherit from torch.Tensor and will want to super() call into it and will only notice later that only float works as a dtype. So in this PR I relax the behavior for this case to make the torch.Tensor constructor more useful for subclasses. Signed-off-by: Edward Z. Yang <ezyangfb.com> [ghstack-poisoned]
|
test added |
|
@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
albanD
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.
SGTM
|
@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: Pull Request resolved: #73850 Previously, torch.Tensor was treated as if it were torch.FloatTensor (where Float is whatever the default dtype was). This is not good behavior for tensor subclasses, which inherit from torch.Tensor and will want to super() call into it and will only notice later that only float works as a dtype. So in this PR I relax the behavior for this case to make the torch.Tensor constructor more useful for subclasses. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: Imported from OSS Reviewed By: albanD Differential Revision: D34707396 Pulled By: ezyang fbshipit-source-id: a995d601007b6fcd0317d89f66ca7e08c4d6053e
Stack from ghstack (oldest at bottom):
Previously, torch.Tensor was treated as if it were torch.FloatTensor
(where Float is whatever the default dtype was). This is not good
behavior for tensor subclasses, which inherit from torch.Tensor and
will want to super() call into it and will only notice later that
only float works as a dtype. So in this PR I relax the behavior
for this case to make the torch.Tensor constructor more useful for
subclasses.
Signed-off-by: Edward Z. Yang ezyang@fb.com
Differential Revision: D34707396