towhee.trainer.utils.trainer_utils.send_to_device

towhee.trainer.utils.trainer_utils.send_to_device(tensor: Any, device: device)[source]

Recursively sends the elements in a nested list/tuple/dictionary of tensors to a given device. Borrowed from huggingface/accelerate. :param tensor: The data to send to a given device. :type tensor: nested list/tuple/dictionary of torch.Tensor :param device: The device to send the data to :type device: torch.device

Returns:

The same data structure as tensor with all tensors sent to the proper device.