Fix the bug in dispatch_to when calling cpu() (#13700)

Summary:
When we added to in #13146, we did not emit the cast correctly in one of the dispatch overloads, then when we call .cpu(), the dtype will always be the default float type, which is wrong.

CC jamesr66a eellison
Pull Request resolved: https://github.com/pytorch/pytorch/pull/13700

Differential Revision: D12968699

Pulled By: wanchaol

fbshipit-source-id: c1aaf2bf6a163643ce5360797da61c68271d8bf8
This commit is contained in:
Wanchao Liang
2018-11-07 22:50:23 -08:00
committed by Facebook Github Bot
parent 90ea61800f
commit 411d89ca64
2 changed files with 2 additions and 2 deletions

View File

@ -259,7 +259,7 @@ static PyObject * THPVariable_invert(PyObject* self, PyObject* args) {
static Tensor dispatch_to(const Tensor & self, Device device, bool non_blocking, bool copy) {
AutoNoGIL no_gil;
return self.to(device, non_blocking, copy);
return self.to(self.options().device(device), non_blocking, copy);
}
static Tensor dispatch_to(const Tensor & self, ScalarType dtype, bool non_blocking, bool copy) {