Hi,
Since you apply the relu inplace in the second case, x now points to the output of the relu. And so you actually do dx/dx = 1.
If you do the following to have access to the gradient of the original x (before the inplace), it will work.
x = torch.tensor([-1.0]).requires_grad_()
x2 = x.clone()
print(torch.autograd.grad(F.relu_(x2), (x, ))[0])

In spirit, you can replace F.relu_(x) by y = F.relu(x); x = y. Where x is the actual python variable and thus will affect everything that uses x.