Improve Storage copy_ size mismatch error message (#126280)

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/126280
Approved by: https://github.com/mikaylagawarecki
This commit is contained in:
Edward Z. Yang 2024-05-15 10:34:30 -04:00 committed by PyTorch MergeBot
parent d15920a7d0
commit f0d34941dd

View file

@ -94,7 +94,13 @@ static PyObject* THPStorage_copy_(
TORCH_CHECK(
!invalid, "Attempted to call copy_() on an invalid python storage.")
TORCH_CHECK(self_.nbytes() == src.nbytes(), "size does not match");
TORCH_CHECK(
self_.nbytes() == src.nbytes(),
"size does not match, self was ",
self_.nbytes(),
" bytes but src was ",
src.nbytes(),
" bytes");
at::storage_copy(self_, src, non_blocking);