From: Gregory Chanan Date: Wed, 10 Apr 2019 18:46:35 +0000 (-0700) Subject: Improve mismatched storage error message. (#19068) X-Git-Tag: accepted/tizen/6.5/unified/20211028.231830~287 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d537e123105717c9af85df6446cffca5897ba65a;p=platform%2Fupstream%2Fpytorch.git 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 --- 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))); }