Skip to content

Commit

Permalink
Account for BC
Browse files Browse the repository at this point in the history
  • Loading branch information
sadra-barikbin committed Jun 20, 2023
1 parent ffed9f3 commit bf7d752
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ignite/distributed/comp_models/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,16 @@ def _do_all_gather(self, tensor: torch.Tensor, group: Optional[Any] = None) -> t
group_size = group.size()
elif isinstance(group, list):
group_size = len(group)
group = self._do_new_group(group)

Check warning on line 441 in ignite/distributed/comp_models/native.py

View check run for this annotation

Codecov / codecov/patch

ignite/distributed/comp_models/native.py#L441

Added line #L441 was not covered by tests
else:
raise ValueError("Argument group should be list of int or ProcessGroup")
if tensor.ndimension() == 0:
tensor = tensor.unsqueeze(0)
output = [torch.zeros_like(tensor) for _ in range(group_size)]
dist.all_gather(output, tensor, group=group)
if group is not None:
dist.all_gather(output, tensor, group=group)
else:
dist.all_gather(output, tensor)
return torch.cat(output, dim=0)

def _do_new_group(self, ranks: List[int], **kwargs: Any) -> Any:
Expand Down

0 comments on commit bf7d752

Please sign in to comment.