-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Zero slice bug #20914
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
Zero slice bug #20914
Conversation
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.
@umanwizard has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
@umanwizard has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
@umanwizard has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Bug reported internally at FB: ```python >>> t=torch.from_numpy(np.empty((0,4))) >>> t[:,1::2]*=1 Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: Trying to resize storage that is not resizable at ../aten/src/TH/THStorageFunctions.cpp:76 ``` This happens because the storage offset of `t[:, 1::2]` is 1, and it has 0 elements. We can fix this by avoiding resizing the storage for no-element arrays. (We could *also* have avoided it by not modifying the storage index in this case, but I felt this way was more semantically correct -- in general, we should not be assuming it's okay to do anything to the storage when it has zero elements). Pull Request resolved: pytorch/pytorch#20914 Differential Revision: D15497860 Pulled By: umanwizard fbshipit-source-id: 6af61d73a05edfc5c07ce8be9e530f15bf72e6a9
|
@umanwizard merged this pull request in c46c6a4. |
Bug reported internally at FB:
This happens because the storage offset of
t[:, 1::2]is 1, and it has 0 elements. We can fix this by avoiding resizing the storage for no-element arrays.(We could also have avoided it by not modifying the storage index in this case, but I felt this way was more semantically correct -- in general, we should not be assuming it's okay to do anything to the storage when it has zero elements).