Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented Jun 6, 2019

Stack from ghstack:

Previously, we were not correctly normalizing slices/indexes.
Closes https://github.com/pytorch/lockdown/issues/102

Previously, we were not correctly normalizing slices/indexes.
Copy link
Contributor

@zdevito zdevito left a 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.

@suo
Copy link
Member Author

suo commented Jun 6, 2019

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));
Copy link
Contributor

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.

@eellison
Copy link
Contributor

eellison commented Jun 7, 2019

Can you land this or do you mind if I submit a PR to fix it ? Would like to get this fixed asap

@suo
Copy link
Member Author

suo commented Jun 7, 2019

I'll fix it up and land

@suo
Copy link
Member Author

suo commented Jun 7, 2019

Closing in favor of a PR @eellison will put up

@suo suo closed this Jun 7, 2019
@facebook-github-bot facebook-github-bot deleted the gh/suo/55/head branch October 28, 2019 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants