albanD:

Hi,
The only difference it makes is that it copies some tensors. So output value and gradient will be the same.
One difference that makes though is that if you try to modify the tensor inplace, this is not allowed if it’s original value is needed. If you clone, then the inplace operation is done on the cloned tensor and it’s not a problem.


Hi
When I don’t use clone(), I found if my tail_block start with

relu(inplace=True)

I will have the error like this
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation.

if the tail_block start with bn or conv,  it’s ok.
But if I use clone() for every x, I won’t get any errors.