Which device is model / tensor stored on?

It would be convenient in many cases if we have a method device() that returns the exact device that the model/tensors are located, then

some_tensor.to(some_model.device())

would be an elegant solution for many functions (which accept a model as input and perform some inference on the model).

5 Likes