Difference between detach().clone() and clone().detach()

If you first detach the tensor and then clone it, the computation path is not copied, the other way around it is copied and then abandoned. Other than that, the methods should be identical.

Thus I’d recommend to first detach and then copy because it does not make sense to copy anything that is never used.

14 Likes