MCPcopy Create free account
hub / github.com/AtlasAnalyticsLab/AdaFisher / to_device

Function to_device

Language_Model/utils/torch_utils.py:17–25  ·  view source on GitHub ↗
(tensors, device)

Source from the content-addressed store, hash-verified

15
16
17def to_device(tensors, device):
18 if isinstance(tensors, torch.Tensor):
19 return tensors.to(device=device)
20 elif isinstance(tensors, dict):
21 return dict(
22 (key, to_device(tensor, device)) for (key, tensor) in tensors.items()
23 )
24 else:
25 raise NotImplementedError("Unknown type {0}".format(type(tensors)))

Callers 2

trainFunction · 0.90
evaluateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected