MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / reduce_mean

Function reduce_mean

detrsmpl/utils/dist_utils.py:61–67  ·  view source on GitHub ↗

Obtain the mean of tensor on different GPUs.

(tensor)

Source from the content-addressed store, hash-verified

59
60
61def reduce_mean(tensor):
62 """"Obtain the mean of tensor on different GPUs."""
63 if not (dist.is_available() and dist.is_initialized()):
64 return tensor
65 tensor = tensor.clone()
66 dist.all_reduce(tensor.div_(dist.get_world_size()), op=dist.ReduceOp.SUM)
67 return tensor

Callers 1

loss_singleMethod · 0.90

Calls 1

cloneMethod · 0.80

Tested by

no test coverage detected