MCPcopy Index your code
hub / github.com/apple/ml-pointersect / reduce_tensor

Function reduce_tensor

cdslib/core/utils/multigpu_utils.py:150–154  ·  view source on GitHub ↗

Gather and sum the tensor from all gpus.

(tensor: torch.Tensor)

Source from the content-addressed store, hash-verified

148
149
150def reduce_tensor(tensor: torch.Tensor):
151 """Gather and sum the tensor from all gpus."""
152 rt = tensor.clone()
153 dist.all_reduce(rt, op=dist.ReduceOp.SUM)
154 return rt

Callers 1

_gather_lossesMethod · 0.90

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected