Undefined symbol, cannot figure out why this time

Good afternoon,

I have been trying to compile some CPP extension I coded 2 years ago but on the newest version of pytorch for the past 2 days.
I keep receiving the error : undefined symbole : _ZNK2at10TensorBase8data_ptrIPfEEPT_v
when importing the extension compiled.
I checked cuda toolkit and pytorch and spent some time matching them between system and conda and pytorch, there is no error during compilation and I even reduced all the code to one function which is as follow to try to debug that :

void compute_distances(int b, int n, int m,  at::Tensor  xyz1p, at::Tensor  xyz2p){

    auto  xyz1   = xyz1p.contiguous().data<float*>();
    auto  xyz2   = xyz2p.contiguous().data<float*>();

    for (int i=0;i<b;++i) {
        float x1 = xyz1[i][0];
        float y1 = xyz1[i][1];
        float z1 = xyz1[i][2];
        for (int j=0;j<b;++j) {
            float x2 = xyz1[j][0];
            float y2 = xyz1[j][1];
            float z2 = xyz1[j][2];
            auto distance = sqrtf((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
            xyz2[i][j] = distance;


Any idea what might be the cause this time ?
My guess is that it is coming from the arrays and how I am handling the C++ float **, but I am really not sure.

Yours faithfully

Justin L

PS : I am importing torch before the extension of course

I am just stupid.
If anyone passes here, doing :


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);
        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));
                *xyz2 = 1000000.0;
                *xyz2 = distance;


And it should work