Add thread-local guard: at::AutoNonVariableTypeMode (#15939)
authorWill Feng <willfeng@fb.com>
Thu, 24 Jan 2019 22:29:06 +0000 (14:29 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 24 Jan 2019 22:33:03 +0000 (14:33 -0800)
commit2a70f24cce3a5c834082bd8b6efe64a17dc7df12
treefe09672645b09975374d7d2b00b43de908c736fa
parentf0dd85d1410b2407bf5198e8cc2f628691c7c2e6
Add thread-local guard: at::AutoNonVariableTypeMode (#15939)

Summary:
This PR adds thread-local guard (`at::AutoNonVariableTypeMode`) to make sure that in VariableType.cpp the operations on baseType still dispatch to non-Variable type, even if the parameters will become Variables after the Tensor/Variable merge. We achieve this by making `legacyTensorType()` and `getType()` check the `at::AutoNonVariableTypeMode` guard to decide whether to return non-Variable type for a variable.

This is part of the VariableImpl/TensorImpl merge work: https://github.com/pytorch/pytorch/issues/13638.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15939

Reviewed By: ezyang

Differential Revision: D13640980

Pulled By: yf225

fbshipit-source-id: d12c2543822958558d7d70d36c50999a5eb8783f
13 files changed:
aten/src/ATen/Context.cpp
aten/src/ATen/SparseTensorImpl.cpp
aten/src/ATen/SparseTensorUtils.h
aten/src/ATen/Utils.h
aten/src/ATen/core/LegacyTypeDispatch.cpp
aten/src/ATen/core/LegacyTypeDispatch.h
aten/src/ATen/native/TensorFactories.cpp
aten/src/ATen/native/cuda/TensorFactories.cu
aten/src/ATen/native/sparse/SparseTensor.cpp
c10/core/TensorImpl.h
caffe2/core/tensor.h
tools/autograd/gen_variable_type.py
torch/csrc/autograd/VariableTypeManual.cpp