Solved by lelouedec in post #2 
              
              
                I am just stupid. 
If anyone passes here, doing : 
xyz2p.contiguous().data<float>();

returns a 1D array of the data, so you need to do your indexing as following : 
void compute_distances(int n, int m,  at::Tensor  xyz1p, at::Tensor  xyz2p){

    auto  xyz1   = xyz1p.contiguous().data_ptr<float>();…