Gather and sum the tensor from all gpus.
(tensor: torch.Tensor)
| 148 | |
| 149 | |
| 150 | def 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 |