move_to_device#

pytorch_forecasting.utils._utils.move_to_device(x: dict[str, Tensor | list[Tensor] | tuple[Tensor]] | Tensor | list[Tensor] | tuple[Tensor], device: str | DeviceObjType) dict[str, Tensor | list[Tensor] | tuple[Tensor]] | Tensor | list[Tensor] | tuple[Tensor][source]#

Move object to device.

Parameters:
  • x (dict, list, tuple, or torch.Tensor) – Object (e.g. dictionary) of tensors to move to device.

  • device (str or torch.DeviceObjType) – Device, e.g. “cpu”.

Returns:

Input x on targeted device.

Return type:

dict, list, tuple, or torch.Tensor