From b5fa5a56033dda7bb5852fe873486134f3395fe9 Mon Sep 17 00:00:00 2001 From: Roy Li Date: Mon, 11 Mar 2019 15:50:45 -0700 Subject: [PATCH] Remove device guard from TypeDefault::copy() Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17833 Reviewed By: ezyang Differential Revision: D14400901 Pulled By: li-roy fbshipit-source-id: ababc95dadfc94a996a80c5332f45f76a300963d --- aten/src/ATen/templates/TypeDefault.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aten/src/ATen/templates/TypeDefault.cpp b/aten/src/ATen/templates/TypeDefault.cpp index 992b5dc..e89b6f1 100644 --- a/aten/src/ATen/templates/TypeDefault.cpp +++ b/aten/src/ATen/templates/TypeDefault.cpp @@ -28,13 +28,12 @@ Tensor & TypeDefault::copy_(Tensor & self, const Tensor & src, bool non_blocking } Tensor TypeDefault::copy(const Tensor & src, bool non_blocking, optional to_device) const { - OptionalDeviceGuard device_guard(to_device); AT_CHECK(src.defined(), "attempt to copy an undefined tensor"); Tensor r; if (is_sparse()) { - r = at::empty({0}, this->options()); + r = at::empty({0}, this->options(to_device)); } else { - r = at::empty(src.sizes(), this->options()); + r = at::empty(src.sizes(), this->options(to_device)); } r.copy_(src, non_blocking); return r; -- 2.7.4