Skip to content

Conversation

@smessmer
Copy link
Contributor

@smessmer smessmer commented Apr 25, 2019

Stack:
    :black_circle:  #19784 The deprecated API allows std::vector arguments  💛
    :white_circle:  #19783 Move IValues from stack into kernels  💛

Previously, the IValues were copied into the kernel arguments, which caused a refcount bump if Tensor was taken by value.
Now, a kernel can take Tensor by value without any refcount bump because it is moved in.

Differential Revision: D15091973

Differential Revision: D15091973
Differential Version: 80762472
@pytorchbot pytorchbot added the module: internals Related to internal abstractions in c10 and ATen label Apr 25, 2019
static void call_(std::tuple<OutputTypes...>&& output, Stack* stack, guts::index_sequence<indices...>) {
(void)(stack); // when sizeof...(indices) == 0, this argument would be unused and we have to silence the compiler warning.
// iterate over all outputs and push them
(void)std::initializer_list<int>{(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we have this initializer_list in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a trick to expand a parameter list into a series of statements. It was calling torch::jit::push(stack, output) on each output. But, actually, inside the implementation of torch::jit::push, there is already an initializer_list doing exactly the same, so instead of calling it on each output individually, we can just pass in torch::jit::push(stack, output, ...) and have that initializer_list take care of it.

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in cb5442b.

zdevito pushed a commit to zdevito/ATen that referenced this pull request May 1, 2019
Summary:
Pull Request resolved: pytorch/pytorch#19783

Previously, the IValues were copied into the kernel arguments, which caused a refcount bump if Tensor was taken by value.
Now, a kernel can take Tensor by value without any refcount bump because it is moved in.

Reviewed By: dzhulgakov

Differential Revision: D15091973

fbshipit-source-id: 4c5ff2e3ee86f5934cc84191697f7dbc9c3ee345
zhangguanheng66 pushed a commit to zhangguanheng66/pytorch that referenced this pull request May 6, 2019
Summary:
Pull Request resolved: pytorch#19783

Previously, the IValues were copied into the kernel arguments, which caused a refcount bump if Tensor was taken by value.
Now, a kernel can take Tensor by value without any refcount bump because it is moved in.

Reviewed By: dzhulgakov

Differential Revision: D15091973

fbshipit-source-id: 4c5ff2e3ee86f5934cc84191697f7dbc9c3ee345
@ezyang ezyang deleted the export-D15091973 branch May 30, 2019 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: internals Related to internal abstractions in c10 and ATen

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants