-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Labels
enhancementNot as big of a feature, but technically not a bug. Should be easy to fixNot as big of a feature, but technically not a bug. Should be easy to fixmodule: reductionstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🚀 Feature
Applying tensor.min(dim), tensor.max(dim), tensor.argmin(dim), tensor.argmax(dim) causes an error when any dimension of the tensor is of size 0.
>>> torch.zeros((2,0)).max(0)
RuntimeError: cannot perform reduction function max on tensor with no elements because the operation does not have an identity
In my opinion this error should only be thrown, if the dim is associated to a dimension which is of size 0.
Motivation
The current behavior is inconsistent with numpy and requires unnecessary case handling for empty tensors.
>>> np.zeros((2,0)).max(0)
array([], dtype=float64)
Pitch
Return empty tensors instead of raising an exception.
>>> torch.zeros((2,0)).max(0)
torch.return_types.max(
values=tensor([]),
indices=tensor([], dtype=torch.int64))
oguzserbetci
Metadata
Metadata
Assignees
Labels
enhancementNot as big of a feature, but technically not a bug. Should be easy to fixNot as big of a feature, but technically not a bug. Should be easy to fixmodule: reductionstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module