Move pyobj_ to TensorImpl (#18225)
authorWill Feng <willfeng@fb.com>
Sat, 23 Mar 2019 19:47:15 +0000 (12:47 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sat, 23 Mar 2019 19:50:38 +0000 (12:50 -0700)
commit32d0e7e339d22636ccb43d5d8a85b70791dd2dba
tree3c0dc70884f60ed780801c85a49efaf01ebeb9b1
parent5860fa5dcf993ddb53080edcbfbc42cfed676a25
Move pyobj_ to TensorImpl (#18225)

Summary:
Currently, `THPVariable_Wrap(…)` and `THPVariable_NewWithVar(…)` depend on the existence of `pyobj_` in the autograd metadata of a Variable to convert the Variable to a Python tensor. However, after the Variable/Tensor merge, there will be Variables that don't contain autograd metadata, and to allow the conversion from non-autograd-meta Variable to a Python tensor we need to store the `pyobj_` outside of autograd metadata and in a place where it will always be available.

This PR makes it possible by moving `pyobj_` into TensorImpl, so that `THPVariable_Wrap(…)` and `THPVariable_NewWithVar(…)` can always access a Variable's `pyobj_` and convert the Variable to a Python tensor.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18225

Differential Revision: D14562616

Pulled By: yf225

fbshipit-source-id: 18d4aaace70eee6120abaf9276036d1f8f51b18d
c10/core/TensorImpl.h
c10/util/python_stub.h [new file with mode: 0644]
torch/csrc/autograd/variable.cpp
torch/csrc/autograd/variable.h