Thank you very much for your response. I have another question similar to this question (relaxing the assumption of bein output of unique function). Imagine I have two tensors as follows:
x=torch.LongTensor([5,3,6,8])
y=torch.LongTensor([2,3,4,6,8,5,7,9])
I want a function that returns the indices of elements in y that are available in x. So the output of this function should be:
tensor([5, 1, 3, 4])
I tried to use the solution in this link 17, but it seems that it is not working for the case when the tensor lengths are different.
The broadcasting solution that you have given above, works perfectly, I am just looking for a more memory efficient approach (at the same performance).