Thanks for your advice.
But after changing code as yours, it blocked at x2 = x1.to(dtype=torch.float64). The line next it never executed.
I think there may be some setting in pytorch causes it.
And if change device in run to 'cuda:0', the problem disappears. But this really not what I want.