From 9be60848cbf3d655a5e821d75dee8392f92a2d64 Mon Sep 17 00:00:00 2001 From: Yukio Siraichi Date: Wed, 28 Feb 2024 11:18:42 -0300 Subject: [PATCH] Fix 0-sized size and stride case. --- torch_xla/csrc/aten_xla_type.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/torch_xla/csrc/aten_xla_type.cpp b/torch_xla/csrc/aten_xla_type.cpp index b91239bc7a85..996a1b72eb32 100644 --- a/torch_xla/csrc/aten_xla_type.cpp +++ b/torch_xla/csrc/aten_xla_type.cpp @@ -711,8 +711,7 @@ at::Tensor XLANativeFunctions::as_strided_copy( if (dim == 0 && tensor.numel() > 0) { // If there's no specified dimension, return the first element of the // storage. This behavior is consistent with eager. - return take(tensor, - at::tensor({0}, at::TensorOptions().device(tensor.device()))); + return select_copy(view_copy_symint(tensor, {tensor.numel()}), 0, 0); } if (storage_size == 0) {