-
Notifications
You must be signed in to change notification settings - Fork 26.3k
error instead of crashing on attempt to subclass typed tensors #20283
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
pytorch#20052 typed tensors (e.g. torch.FloatTensor) can't be subclassed. Was causing crashes and other errors.
|
|
||
| def test_subclass_tensors(self): | ||
| # raise an error when trying to subclass FloatTensor | ||
| with self.assertRaisesRegex(TypeError, "type 'torch.FloatTensor' is not an acceptable base type"): |
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'm curious if this error message is actually stable -- I guess the CI will tell us.
| def foo(self): | ||
| return 5 | ||
| f = Foo() | ||
| self.assertEqual(f.foo(), 5) |
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'd prefer doing something with the Tensor, e.g. you could just check it's shape is () here.
facebook-github-bot
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.
@nairbv is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
#20052
typed tensors (e.g. torch.FloatTensor) can't be subclassed. Was causing
crashes and other errors.