-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Closed
Labels
actionablemodule: docsRelated to our documentation, both in docs/ and docblocksRelated to our documentation, both in docs/ and docblocksmodule: python frontendFor issues relating to PyTorch's Python frontendFor issues relating to PyTorch's Python frontendtriagedThis 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
🐛 Describe the bug
sort() works with 4 argument keywords as shown below:
import torch
my_tensor = torch.tensor([7, 1, -5, 7, 9, -3, 0, -3])
torch.sort(input=my_tensor, dim=0, descending=False, stable=False) # Works
# torch.return_types.sort(
# values=tensor([-5, -3, -3, 0, 1, 7, 7, 9]),
# indices=tensor([2, 5, 7, 6, 1, 0, 3, 4]))But sort() doesn't work without 4 argument keywords as shown below:
import torch
my_tensor = torch.tensor([7, 1, -5, 7, 9, -3, 0, -3])
torch.sort(my_tensor, 0, False, False) # ErrorTypeError: sort() received an invalid combination of arguments - got (Tensor, int, bool, bool), but expected one of:
* (Tensor input, *, bool stable, int dim, bool descending, tuple of Tensors out)
* (Tensor input, int dim, bool descending, *, tuple of Tensors out)
* (Tensor input, *, bool stable, name dim, bool descending, tuple of Tensors out)
* (Tensor input, name dim, bool descending, *, tuple of Tensors out)
In addition, sort() works without 2 or 3 argument keywords as shown below:
import torch
my_tensor = torch.tensor([7, 1, -5, 7, 9, -3, 0, -3])
torch.sort(my_tensor, 0) # Works
torch.sort(my_tensor, 0, False) # Works
# torch.return_types.sort(
# values=tensor([-5, -3, -3, 0, 1, 7, 7, 9]),
# indices=tensor([2, 5, 7, 6, 1, 0, 3, 4]))Versions
import torch
my_tensor = torch.tensor([7, 1, -5, 7, 9, -3, 0, -3])
torch.__version__ # 2.3.0+cu121Metadata
Metadata
Assignees
Labels
actionablemodule: docsRelated to our documentation, both in docs/ and docblocksRelated to our documentation, both in docs/ and docblocksmodule: python frontendFor issues relating to PyTorch's Python frontendFor issues relating to PyTorch's Python frontendtriagedThis 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