Don't truncate leading 1s if they are unbacked#95141
Closed
ezyang wants to merge 3 commits intogh/ezyang/1829/basefrom
Closed
Don't truncate leading 1s if they are unbacked#95141ezyang wants to merge 3 commits intogh/ezyang/1829/basefrom
ezyang wants to merge 3 commits intogh/ezyang/1829/basefrom
Conversation
If it's just right, broadcasting will do the right thing automatically. This helps with unbacked SymInts as I can avoid testing one equality on the inside. Signed-off-by: Edward Z. Yang <ezyangmeta.com> [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/95141
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit fe43676: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
If it's just right, broadcasting will do the right thing automatically. This helps with unbacked SymInts as I can avoid testing one equality on the inside. The previous attempt at #94521 I got the logic a bit wrong. I need to compute the difference between the data to be set, and the post-slice space for the values. But I incorrectly compared against the *pre-slice* space in the original PR. Another version of this PR which is wrong is to compare against variableIndices.size(); but remember that in advanced indexing with tensors/lists, each of the individual indices specify what coordinates to read out of each dimension; so to get the post-slice space you have to look at the dim of the advanced index itself! There is now a test for this. Signed-off-by: Edward Z. Yang <ezyangmeta.com> [ghstack-poisoned]
This prevents us from guarding on leading unbacked SymInts. The previous attempt at #94521 I got the logic a bit wrong. My idea there was to avoid slicing when the values to be set have low enough dimensionality that they definitely aren't too long. To do this, I need to compute the difference between the data to be set, and the post-slice space for the values. But I incorrectly compared against the *pre-slice* space in the original PR. Another version of this PR which is wrong is to compare against variableIndices.size(); but remember that in advanced indexing with tensors/lists, each of the individual indices specify what coordinates to read out of each dimension! A third incorrect attempt tested `variableIndices[0].dim()`, which is only correct if you don't broadcast one of the later variable indices, and if there are enough variableIndices to cover all dims. This is all quite complicated, so I went for a simpler solution of checking if the leading dim had a hint before testing if it is not equal to one. BTW, there is no test for this one stripping behavior. There is now a test for this, based off the real code that caused the problem. Signed-off-by: Edward Z. Yang <ezyangmeta.com> [ghstack-poisoned]
ngimel
approved these changes
Feb 20, 2023
This was referenced Feb 20, 2023
Closed
Contributor
Author
|
@pytorchbot merge |
Collaborator
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
pruthvistony
added a commit
to ROCm/pytorch
that referenced
this pull request
May 2, 2023
This reverts commit 77dae43.
jhavukainen
pushed a commit
to kulinseth/pytorch
that referenced
this pull request
Mar 15, 2024
This prevents us from guarding on leading unbacked SymInts. The previous attempt at pytorch#94521 I got the logic a bit wrong. My idea there was to avoid slicing when the values to be set have low enough dimensionality that they definitely aren't too long. To do this, I need to compute the difference between the data to be set, and the post-slice space for the values. But I incorrectly compared against the *pre-slice* space in the original PR. Another version of this PR which is wrong is to compare against variableIndices.size(); but remember that in advanced indexing with tensors/lists, each of the individual indices specify what coordinates to read out of each dimension! A third incorrect attempt tested `variableIndices[0].dim()`, which is only correct if you don't broadcast one of the later variable indices, and if there are enough variableIndices to cover all dims. This is all quite complicated, so I went for a simpler solution of checking if the leading dim had a hint before testing if it is not equal to one. BTW, there is no test for this one stripping behavior. There is now a test for this, based off the real code that caused the problem. Signed-off-by: Edward Z. Yang <ezyangmeta.com> Pull Request resolved: pytorch#95141 Approved by: https://github.com/ngimel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
This prevents us from guarding on leading unbacked SymInts.
The previous attempt at #94521 I got the logic a bit wrong. My idea there was to avoid slicing when the values to be set have low enough dimensionality that they definitely aren't too long. To do this, I need to compute the difference between the data to be set, and the post-slice space for the values. But I incorrectly compared against the pre-slice space in the original PR. Another version of this PR which is wrong is to compare against variableIndices.size(); but remember that in advanced indexing with tensors/lists, each of the individual indices specify what coordinates to read out of each dimension! A third incorrect attempt tested
variableIndices[0].dim(), which is only correct if you don't broadcast one of the later variable indices, and if there are enough variableIndices to cover all dims. This is all quite complicated, so I went for a simpler solution of checking if the leading dim had a hint before testing if it is not equal to one.BTW, there is no test for this one stripping behavior. There is now a test for this, based off the real code that caused the problem.
Signed-off-by: Edward Z. Yang <ezyangmeta.com>