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


@torch.no_grad()
def solution(tensor: torch.Tensor) -> torch.Tensor:
    world_size = dist.get_world_size()
    out = tensor.new_empty((world_size,) + tensor.shape)
    dist.all_gather_into_tensor(out, tensor)
    return out