MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / async_copy_to

Function async_copy_to

lib/nn/parallel/data_parallel.py:13–24  ·  view source on GitHub ↗
(obj, dev, main_stream=None)

Source from the content-addressed store, hash-verified

11
12
13def async_copy_to(obj, dev, main_stream=None):
14 if torch.is_tensor(obj):
15 v = obj.cuda(dev, non_blocking=True)
16 if main_stream is not None:
17 v.data.record_stream(main_stream)
18 return v
19 elif isinstance(obj, collections.Mapping):
20 return {k: async_copy_to(o, dev, main_stream) for k, o in obj.items()}
21 elif isinstance(obj, collections.Sequence):
22 return [async_copy_to(o, dev, main_stream) for o in obj]
23 else:
24 return obj
25
26
27def dict_gather(outputs, target_device, dim=0):

Callers 2

_async_copyFunction · 0.85
_async_copy_streamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected