From d537e123105717c9af85df6446cffca5897ba65a Mon Sep 17 00:00:00 2001 From: Gregory Chanan Date: Wed, 10 Apr 2019 11:46:35 -0700 Subject: [PATCH] Improve mismatched storage error message. (#19068) Summary: Previously the error message would look like: ``` Attempted to set the storage of a tensor on device cuda:0 to a storage on different device cuda. This is no longer allowed; the devices must match. ``` Now it looks like: ``` Attempted to set the storage of a tensor on device "cuda:0" to a storage on different device "cuda". This is no longer allowed; the devices must match. ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/19068 Reviewed By: dzhulgakov Differential Revision: D14854257 Pulled By: gchanan fbshipit-source-id: deb1ef73c2fcbf9338e7d67f2856282db2befac8 --- aten/src/TH/THTensor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aten/src/TH/THTensor.cpp b/aten/src/TH/THTensor.cpp index 2be5ce7..06b02d8 100644 --- a/aten/src/TH/THTensor.cpp +++ b/aten/src/TH/THTensor.cpp @@ -168,8 +168,8 @@ void THTensor_stealAndSetStoragePtr(THTensor* tensor, THStorage* storage) { // see Note [We regret making Variable hold a Tensor] // Let's put an actual error message for this one. AT_CHECK(tensor->storage().device() == storage->device(), - "Attempted to set the storage of a tensor on device ", tensor->storage().device(), - " to a storage on different device ", storage->device(), - ". This is no longer allowed; the devices must match."); + "Attempted to set the storage of a tensor on device \"", tensor->storage().device(), + "\" to a storage on different device \"", storage->device(), + "\". This is no longer allowed; the devices must match."); tensor->set_storage(at::Storage(c10::intrusive_ptr::reclaim(storage))); } -- 2.7.4