Skip to content

Commit

Permalink
size
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Oct 25, 2023
1 parent 9fb34cd commit 37246dd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/torchmetrics/utilities/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ def _bincount(x: Tensor, minlength: Optional[int] = None) -> Tensor:
minlength = len(torch.unique(x))

if torch.are_deterministic_algorithms_enabled() or _XLA_AVAILABLE or _TORCH_GREATER_EQUAL_1_12 and x.is_mps:
size = len(x)
mesh = torch.arange(minlength, device=x.device).repeat(size, 1)
mesh = torch.arange(minlength, device=x.device).repeat(len(x), 1)
return torch.eq(x.reshape(-1, 1), mesh).sum(dim=0)

return torch.bincount(x, minlength=minlength)
Expand Down

0 comments on commit 37246dd

Please sign in to comment.