Replace clone.detach with detach.clone (#140264)

Fixes #64532

As state in issue, replace `clone.detach` by `detach.clone`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/140264
Approved by: https://github.com/soulitzer
This commit is contained in:
zeshengzong
2024-11-13 07:01:00 +00:00
committed by PyTorch MergeBot
parent f06ee3e546
commit cb71bcc542
66 changed files with 263 additions and 263 deletions

View File

@ -652,7 +652,7 @@ class TestModule(TestCase):
d = obj.dim()
if ((mem_format == torch.channels_last and d != 4)
or (mem_format == torch.channels_last_3d and d != 5)):
return obj.clone().detach().requires_grad_(obj.requires_grad)
return obj.detach().clone().requires_grad_(obj.requires_grad)
return obj.clone().to(memory_format=mem_format).detach().requires_grad_(obj.requires_grad)
return self._traverse_obj(obj, inner_to_mem_format)