-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[jit] fix tuple index and slicing #21450
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, we were not correctly normalizing slices/indexes.
zdevito
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.
I think tuple indices should be normalize before they ever make it into the Graph. TupleSlice should assert that this is true when created. As the patch is currently is written it forces the entire compiler to know about the more complicated behavior, but tuple indices are always constant and can be normalized on creation.
|
yeah I came to the same realization lol. Will put up the new version soon |
| auto tuple = n->inputs().at(0); | ||
| const size_t tuple_len = tuple->type()->containedTypes().size(); | ||
| const size_t normalized_idx = normalizeIndex(*maybe_int, tuple_len); | ||
| n->output()->replaceAllUsesWith(construct->inputs().at(normalized_idx)); |
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 this is the only change needed, but it's not safe to use the normalized_idx since it maybe out of bounds. I don't think tupleslice has a problem.
|
Can you land this or do you mind if I submit a PR to fix it ? Would like to get this fixed asap |
|
I'll fix it up and land |
|
Closing in favor of a PR @eellison will put up |
Stack from ghstack:
Previously, we were not correctly normalizing slices/indexes.
Closes https://github.com/pytorch/lockdown/issues/102