Move most methods off Variable into torch::autograd::impl functions. (#29665)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29665

Our intention is to merge the static distinction between Tensor and
Variable.  Ordinarily, this would entail merging the methods of Tensor
and Variable.  But there are a lot of "private"-ish methods on Variable
that we don't actually want to dump onto the Tensor class.  So, as prep
work, we move all of those methods off of Variable and into
the torch::autograd::impl namespace (impl as in, please don't use this
end users).  This ends up being a fairly large patch because all of
the call sites have to play ball too.

While I was on the topic, I also moved any of the touched functions into
the C++ file, so that modifying them would not trigger a recompilation of
all of torch.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Test Plan: Imported from OSS

Differential Revision: D18496169

Pulled By: ezyang

fbshipit-source-id: afb203252620ec274be596b3e7b1d84d321bad3a
This commit is contained in:
Edward Yang
2019-11-18 08:10:19 -08:00
committed by Facebook Github Bot
parent 38340f59fd
commit 1ab2f043ba
18 changed files with 326 additions and 324 deletions

View File

@ -329,7 +329,7 @@ static std::unordered_set<at::TensorImpl*> _mark_dirty(THPFunction *self)
dirty_inputs.insert(((THPVariable*)obj)->cdata.unsafeGetTensorImpl());
auto variable = (THPVariable*)obj;
variable->cdata.bump_version();
torch::autograd::impl::bump_version(variable->cdata);
}
// We're not going to ever need this so let's remove references now
Py_CLEAR(self->dirty_tensors);