Consider there are two int64 torch::Tensor x and y at the same length in the c++ implementation, both with unique values. Could you kindly help me to create a mapping M() between the two, such that M(a[i]) = b[i]? Thanks!
Not aware of a solution via PyTorch but you can possibly make use of thrust library.
A crude logic would be to first both arrays by sort_by_key operation where keys are the x, y and values are the indices. Afterwards you have a mapping from sorted indices in x to sorted indices in y which can be inverted.