zero.hardware.to_device¶
-
zero.hardware.
to_device
(data, device, non_blocking=False)[source]¶ Move tensor(s) to device.
Move data consisting of tensors to the given device using
torch.Tensor.to
.- Parameters
data (
Recursive[torch.Tensor]
) –device (
Device
) –non_blocking (bool) – is forwarded to
torch.Tensor.to
- Returns
The same data, but moved to the given device.
- Return type
Examples
to_device(torch.tensor(0), 'cpu') to_device({'a': torch.tensor(0), 'b': [(torch.tensor(0),)]}, 'cpu')