If model already on cpu does model.to('cpu') return a copy or a reference?

Sorry for the basic question:
If model already on cpu does model.to(‘cpu’) return a copy of the model or a reference to the existing model?
Same question if model already on gpu and model.to(‘gpu’)?

It copies the parameters and buffer only if the requested device/dtype is different. It never copies the module object.

1 Like