Skip to content

[Feature Request] sorted_input for torch.unique #19045

@zasdfgbnm

Description

@zasdfgbnm

Is it good to add a sorted_input to torch.unique?

Current cuda implementation always sort the input tensor first. But sometimes the input tensor is guaranteed to be already sorted. Sorting is O(n*logn), which is likely to be the most time consuming part of the whole computation, and it would be nice if we allow user to skip this part.

torch.unique with sorted_input=True would resemble thrust::unique and only remove the consecutive duplicate elements.

It might be better to name it consecutive instead of sorted_input.

Metadata

Metadata

Assignees

Labels

enhancementNot as big of a feature, but technically not a bug. Should be easy to fixhigh prioritytriagedThis 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