Skip to content

Add complex support for torch.unique #53440

@shervinf66

Description

@shervinf66

🚀 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    complex_autogradfunction requestA request for a new function or the addition of new arguments/modes to an existing function.module: complexRelated to complex number support in PyTorchmodule: numpyRelated to numpy support, and also numpy compatibility of our operatorsmodule: python array apiIssues related to the Python Array APItriagedThis 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