-
Notifications
You must be signed in to change notification settings - Fork 26.3k
handle slice with negative indices and indices exceeding tensor dimen… #21811
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
spandantiwari
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.
LGTM.
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.
@houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
houseroad
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.
LGTM, thanks.
| _set_opset_version(9) | ||
| x = torch.ones(1, 3) | ||
| graph, _, __ = utils._model_to_graph(SliceModule(), (x, ), | ||
| graph, _, __ = utils._model_to_graph(NarrowModule(), (x, ), |
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.
nit: __ => _
also can you change all the __ to _?
| int64_t length = end - start; | ||
| if (length < 0 || start > updated_val.sizes()[axis] - length) | ||
| return c10::nullopt; | ||
| updated_val = at::narrow(updated_val, axis, start, length); |
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.
you may also want to try at::slice
|
will merge this pr first, feel free to open another pr to address nits. |
|
@houseroad merged this pull request in f9b3989. |
handle slice with negative indices and indices exceeding tensor dimensions.