Skip to content

Commit

Permalink
Revert "[fix] ltorch.to to return a copy, when copy=True (#1775)"
Browse files Browse the repository at this point in the history
This reverts commit 92a6adb.
  • Loading branch information
riccardofelluga committed Feb 21, 2025
1 parent 78d84e5 commit 1015986
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
14 changes: 0 additions & 14 deletions thunder/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1865,20 +1865,6 @@ def torch_to(a, memory_format):
assert_close(torch_result, thunder_result, check_stride=True)


def test_torch_tensor_to_return_type():
a = torch.randn(2, 4, 5, 3)

def torch_to(a):
return a.to(copy=True)

jfoo = thunder.jit(torch_to)
thunder_result = jfoo(a)
torch_result = torch_to(a)

assert thunder_result is not a
assert_close(torch_result, thunder_result)


# TODO See issue "Add contiguous and clang.stride_order OpInfos that check stride
# consistency with PyTorch"
@instantiate(
Expand Down
7 changes: 0 additions & 7 deletions thunder/torch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,6 @@ def to(
copy: bool = False,
memory_format: None | torch.memory_format = None,
) -> TensorLike:

input_device = a.device
input_dtype = a.dtype
if copy and not _will_to_return_self(input_device, input_dtype, device, dtype, memory_format, copy):
b = prims.empty(a.shape, device=input_device, dtype=input_dtype)
return _copy_(b, a)

device, dtype = _parse_to_device_and_dtype(
tensor_dtype_or_device, optional_positional_dtype, device=device, dtype=dtype
)
Expand Down

0 comments on commit 1015986

Please sign in to comment.