-
Notifications
You must be signed in to change notification settings - Fork 27.7k
Add complex support for torch.unique #53440
Copy link
Copy link
Open
Labels
complex_autogradfunction requestA request for a new function or the addition of new arguments/modes to an existing function.A request for a new function or the addition of new arguments/modes to an existing function.module: complexRelated to complex number support in PyTorchRelated to complex number support in PyTorchmodule: numpyRelated to numpy support, and also numpy compatibility of our operatorsRelated to numpy support, and also numpy compatibility of our operatorsmodule: python array apiIssues related to the Python Array APIIssues related to the Python Array APItriagedThis 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
Metadata
Metadata
Assignees
Labels
complex_autogradfunction requestA request for a new function or the addition of new arguments/modes to an existing function.A request for a new function or the addition of new arguments/modes to an existing function.module: complexRelated to complex number support in PyTorchRelated to complex number support in PyTorchmodule: numpyRelated to numpy support, and also numpy compatibility of our operatorsRelated to numpy support, and also numpy compatibility of our operatorsmodule: python array apiIssues related to the Python Array APIIssues related to the Python Array APItriagedThis 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
🚀 Feature
ComplexFloat support for torch.unique
Motivation
I need to use this during training my network
Pitch
I am using this to find unique values per row in 2d tensor much faster.
Alternatives
The alternative is to do a for loop over each row and use torch unique on each row which slows the training significantly
Additional context
complex_tensor = tensor([[ 2.+0.j, 3.+0.j, 9.+0.j, 3.+0.j, 10.+0.j, 10.+0.j, 4.+0.j, 3.+0.j, 10.+0.j, 8.+0.j],
[ 9.+10.j, 1.+10.j, 8.+10.j, 2.+10.j, 6.+10.j, 6.+10.j, 6.+10.j, 1.+10.j, 8.+10.j, 5.+10.j]
])
u, ind, cnt = torch.unique(complex_tensor return_inverse=True, return_counts=True)
RuntimeError: "unique" not implemented for 'ComplexFloat'
cc @ezyang @anjali411 @dylanbespalko @mruberry @lezcano @nikitaved @rgommers @pmeier @asmeurer @leofang @AnirudhDagar @asi1024 @emcastillo @kmaehashi @aocsa @heitorschueroff