I have two very large tensors a and b, each has about one million values.
Now I want to see if the elements in b exist in a, and if yes, return their indices in a. I know the easiest way to implement is
exist_elements_id, index_in_a = b.view(-1, 1).eq(a).nonzero(as_tuple=True)
However, this will result in cuda out of memory (1TB memory) issue because the eq() result is too large.
Is there any other memory-efficient and fast way to implement this? Thanks!