Here are two cases use “=” and “clone”:

(1)

x1 = torch.randn(4)

x1.requires_grad()

y1 = x1

z1 = y1.mean().backward()

(2)

x2 = torch.randn(4)

x2.requires_grad()

y2 = x2.clone()

z2 =

Since x1 and x2 can get their grads (which are equal), and my questions are:

- what’s the difference in the two cases?
- which one is preferred when creating a computation graph?