Skip to content

One complex number or boolean value of a 1D or more D tensor with argmin() and dim= works #126776

Open
@hyperkai

Description

@hyperkai

🐛 Describe the bug

One complex number or boolean value of a 1D or more D tensor with argmin() gets the error as shown below:

One complex number with a 1D or 2D tensor:

import torch

my_tensor = torch.tensor([7.+5.j])

torch.argmin(input=my_tensor) # RuntimeError: "argmin_cpu" not implemented for 'ComplexFloat'

my_tensor = torch.tensor([[7.+5.j]])

torch.argmin(input=my_tensor) # RuntimeError: "argmin_cpu" not implemented for 'ComplexFloat'

One boolean value with a 1D or 2D tensor:

import torch

my_tensor = torch.tensor([True])

torch.argmin(input=my_tensor) # RuntimeError: "argmin_cpu" not implemented for 'Bool'

my_tensor = torch.tensor([[True]])

torch.argmin(input=my_tensor) # RuntimeError: "argmin_cpu" not implemented for 'Bool'

But one complex number or boolean value of a 1D or more D tensor with argmin() and dim= works as shown below:

One complex number with a 1D or 2D tensor:

import torch

my_tensor = torch.tensor([7.+5.j])

torch.argmin(input=my_tensor, dim=0)
torch.argmin(input=my_tensor, dim=-1)
# tensor(0)

my_tensor = torch.tensor([[7.+5.j]])

torch.argmin(input=my_tensor, dim=0)
torch.argmin(input=my_tensor, dim=1)
torch.argmin(input=my_tensor, dim=-1)
torch.argmin(input=my_tensor, dim=-2)
# tensor([0])

One boolean value with a 1D or 2D tensor:

import torch

my_tensor = torch.tensor([True])

torch.argmin(input=my_tensor, dim=0)
torch.argmin(input=my_tensor, dim=-1)
# tensor(0)

my_tensor = torch.tensor([[True]])

torch.argmin(input=my_tensor, dim=0)
torch.argmin(input=my_tensor, dim=1)
torch.argmin(input=my_tensor, dim=-1)
torch.argmin(input=my_tensor, dim=-2)
# tensor([0])

Versions

import torch

torch.__version__ # 2.2.1+cu121

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionablemodule: edge casesAdversarial inputs unlikely to occur in practicetriagedThis 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