Skip to content

Deprecate torch.(min|max|median|mode) to only return values and not indices #61490

@heitorschueroff

Description

@heitorschueroff

torch.min, torch.max, torch.median and torch.mode return indices along with the values when reducing over one dimension. This is incompatible with the Python Array API Standard as described in the following issue #58745 and furthermore makes it difficult to support reducing over multiple dimensions.

Alternatives

  • a dedicated operator for computing the extra output such as argmax that only returns that extra output
  • a variant of the function, e.g. argmax_with_indices, that returns all output tensors
  • an optional parameter return_indices=True to explicitly ask for the extra output, although it is discouraged to have operators with multiple possible return types
  • an optional out parameter on which to place the extra output, this avoids the return type changing and creating a combinatorial number of variants of the operator. We already support the out= keyword so it might be possible to extend the code to accept extra optional out tensors.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: deprecationmodule: numpyRelated to numpy support, and also numpy compatibility of our operatorsmodule: python array apiIssues related to the Python Array APImodule: reductionsneeds designWe want to add this feature but we need to figure out how firsttriagedThis 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