Use non-Variable type for callsites that check type equality (#16325)
authorWill Feng <willfeng@fb.com>
Sun, 10 Feb 2019 17:38:50 +0000 (09:38 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sun, 10 Feb 2019 17:47:50 +0000 (09:47 -0800)
commit202eaa4ef40824d08ae88b3062b9c82d78794432
tree217e045f0631797910b18cf5b766aa87a1a67cb4
parenta9f1d2e3711476ba4189ea804488e5264a4229a8
Use non-Variable type for callsites that check type equality (#16325)

Summary:
When Variable and Tensor are merged, the dynamic type of the tensors passed to certain functions will become variables, and expecting `type()` on those variables to still return non-Variable types will cause type mismatch error.

One way to fix this problem is to use the thread-local guard `at::AutoNonVariableTypeMode` to force `type()` to return non-Variable type, but ideally we want to limit the use of `at::AutoNonVariableTypeMode` to be only in VariableType.cpp. Another way to fix the problem is to use `at::globalContext().getNonVariableType()` instead to get the non-Variable type of the tensor, which is what this PR is trying to achieve.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16325

Differential Revision: D14012022

Pulled By: yf225

fbshipit-source-id: 77ef1d2a02f78bff0063bdd72596e34046f1e00d
aten/src/ATen/native/TensorIterator.cpp
torch/csrc/Generator.cpp
torch/csrc/autograd/python_variable.cpp
torch/csrc/cuda/Module.cpp
torch/csrc/nn/type_checks.h