Open
Description
🐛 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