Skip to content

unique should be split into four partial functions #70920

@pmeier

Description

@pmeier

The array API specification stipulates that we should have four partial functions for uniqueness computation rather than just one:

  • unique_values: torch.unique
  • unique_counts: roughly partial(torch.unique, return_counts=True)1
  • unique_inverse: roughly partial(torch.unique, return_inverse=True)1
  • unique_all: roughly partial(torch.unique, return_inverse=True, return_counts=True)1, with the caveat that actually 4 tensors should be returned, with the second element being the indices that denote the first occurences of the values in the input.

cc @mruberry @rgommers @pmeier @asmeurer @leofang @AnirudhDagar @asi1024 @emcastillo @kmaehashi

Footnotes

  1. We currently return plain tuples, but for compliance with the array API, we need to return named tuples. 2 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: 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