In numpy.unique where is an option return_index=True – which returns positions of unique elements (first occurrence if several).
Unfortunately, there is no such option in torch.unique !
Question: What are the fast and torch-style ways to get indexes of the unique elements ?
=====================
More generally my issue is the following: I have two vectors v1, v2, and I want to get positions of those elements in v2, which are not in v1 and also for repeated elements I need only one position. Numpy’s unique with return_index = True immediately gives the solution. How to do it in torch ? If we know that vector v1 is sorted, can it be used to speed up the process ?