I have 3 tensors with:
x.shape = (2500,2) # in this case the each value in this array are unique(like a grid)
y.shape = (2500,1)


The last tensor is a subset of x, let’s call it z, and has a  shape (650,2), I would like to find the indexes where x = z. For me to use the indexes in tensor “y” and slice it to find the corresponding values.
I decided to do this problem as I did it with only one dimension I used torch.where(). However, I found different problems with this way of using it.
First of all, I can’t use a torch.where(x==z), since it has different lengths.
Second of all, I believe this function isn’t pairwise. Meaning that it can’t check each of the pairs of numbers for each of them. (This might not be true).
I created a way that finds this indexes:
def findIndexes(domain,quadrants):
    noleaf = torch.tensor([])
    for j in range(0,quadrants[i].shape[0]):
      index = torch.where((domain[:,0] == quadrants[j,0]) & (domain[:,1] == quadrants[j,1]))[0]
      noleaf = torch.cat((noleaf,index))
    
  return noleaf

I was wondering if this way could be too inefficient, in terms of memory. I wanted to pick your brains to see if there is a more sophisticated way to do it. If so how could I do it?