Skip to content

torch.max and torch.min inconsistent on cpu/gpu for tensors with zero elements. #17750

@surgan12

Description

@surgan12

On cpu:
g = torch.rand(0,4)
torch.max(g)

Behaviour:
RuntimeError: invalid argument 1: tensor must have one dimension at /pytorch/aten/src/TH/generic/THTensorEvenMoreMath.cpp:59

On Gpu:
g = torch.rand(0,4).cuda()
torch.max(g)

Behaviour:
tensor(-inf, device='cuda:0')

Expected Behaviour on GPU:
Some error or an empty tensor as i feel the max/min of a set should belong in the set so -inf is wrong.

PyTorch Version :'1.0.1.post2'

Metadata

Metadata

Assignees

No one assigned

    Labels

    high prioritymodule: bootcampWe plan to do a full writeup on the issue, and then get someone to do it for onboardingmodule: error checkingBugs related to incorrect/lacking error checkingsmallWe think this is a small issue to fix. Consider knocking off high priority small issuestriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions