File size: 223 Bytes
c2f8cf1
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
import torch
import torch.distributed as dist


@torch.no_grad()
def solution(tensor: torch.Tensor, dst: int = 0) -> torch.Tensor:
    out = tensor.clone()
    dist.reduce(out, dst=dst, op=dist.ReduceOp.SUM)
    return out