[jit] add pop support to list#17015
Conversation
bad3188 to
9d5f16c
Compare
There was a problem hiding this comment.
This doesn't really need the node and you can just use the std::function<int(Stack&)> directly (i.e. this turns into
int listPop(Stack& stack) {
// stuff
return 0;
}There was a problem hiding this comment.
Python allows poping with negative indices (e.g.
a = [1, 2, 3]
a.pop(-2) # return 2) so using -1 as a flag won't allow that. We could instead have 2 schemas for aten::pop, one where its just aten::pop(the_list) and the other with aten::pop(the_list, index) (and error messages to match)
There was a problem hiding this comment.
I think this works - pop() with no argument has the same semantics as pop(-1)
There was a problem hiding this comment.
To all the checkScript calls it turns things into TorchScript for you, so it needs the function itself instead of the return value (so this should be self.checkScriptRaisesRegex(test_pop_empty, (), RuntimeError))
driazati
left a comment
There was a problem hiding this comment.
Thanks for the PR! Mostly looks good, a few small suggestions
eellison
left a comment
There was a problem hiding this comment.
Thanks for doing this! Looks good!
There was a problem hiding this comment.
pop can take in negative indices other than -1, so the idx needs to be normalized before the call to erase (and you won't need a special case for idx == -1).
eellison
left a comment
There was a problem hiding this comment.
Looks great ✨
One very small comment and I'll land it
There was a problem hiding this comment.
Don't think you need to call std::move on a bool
facebook-github-bot
left a comment
There was a problem hiding this comment.
@eellison 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.
@eellison is landing 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.
@eellison 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.
@eellison 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.
@eellison has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
| TList a; | ||
| pop(stack, a); | ||
|
|
||
| a->elements().clear(); |
There was a problem hiding this comment.
Fix for https://github.com/pytorch/pytorch/pull/17015/files here
facebook-github-bot
left a comment
There was a problem hiding this comment.
@eellison 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.
@eellison is landing 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.
@eellison is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: [WIP] add "pop" to list, see pytorch#16662 Pull Request resolved: pytorch#17015 Differential Revision: D14071680 Pulled By: eellison fbshipit-source-id: b49a318059c1cc131acda50713132e11b562568f
[WIP] add "pop" to list, see #16662