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>();
    auto  start = xyz1;
    auto  xyz2   = xyz2p.contiguous().data_ptr<float>();
    auto start2 = xyz2;
    for (int i=0;i<n;i++) {
        float x1 = *xyz1;
        float y1 = *(1+xyz1);
        float z1 = *(2+xyz1);
        xyz1+=3;
        for (int j=0;j<n;j++) {
            float x2 = *((j*3)+start);
            float y2 = *((j*3)+1+start);
            float z2 = *((j*3)+2+start);
            float distance = sqrtf((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
            if(j==i){
                *xyz2 = 1000000.0;
            }else{
                *xyz2 = distance;
            }
            xyz2++;
        }
    }



}

And it should work