What is the difference between model.to(device) and model=model.to(device)?
Suppose the model is originally stored on CPU, and then I want to move it to GPU0, then I can do:

device = torch.device('cuda:0')
model = model.to(device)
# or
model.to(device)


What is the difference between those two lines?

No semantic difference. nn.Module.to function moves the model to the device.
But be cautious.
For tensors (documentation):
# tensor a is in CPU
device = torch.device('cuda:0')
b = a.to(device)
# a is still in CPU!
# b is in GPU!
# a and b are different 

For models (documentation):
# model a is in CPU
device = torch.device('cuda:0')
b = a.to(device)
# a and b are in GPU
# a and b point to the same model 

