-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Description
Issue description
torch.bincount gives an error when given an empty tensor, rather than just returning zero counts like numpy.bincount. Trips up edge cases when counting filtered data.
Code example
>>> import torch, numpy
>>> numpy.bincount([1]), numpy.bincount([]), numpy.bincount([], minlength=10)
(array([0, 1]), array([], dtype=int64), array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))
>>> torch.bincount(torch.LongTensor([]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: bincount only supports 1-d non-negative integral inputs.
>>> torch.bincount(torch.LongTensor([]), minlength=10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: bincount only supports 1-d non-negative integral inputs.
Metadata
Metadata
Assignees
Labels
No labels