Skip to content

Commit

Permalink
Fix 0-sized size and stride case.
Browse files Browse the repository at this point in the history
  • Loading branch information
ysiraichi committed Feb 28, 2024
1 parent f2189d3 commit 9be6084
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions torch_xla/csrc/aten_xla_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9be6084

Please sign in to comment.