lelouedec / 3DNetworksPytorch

Implementation of Popular Deep Learning Network using pytorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

c++ extension related

leungMr opened this issue · comments

Thank you for a great job!
Would like to ask, using c++ extension to write algorithm, to achieve the effect of speed up, what knowledge should be learned in this step, is it difficult for a c++ beginner?
Also, do c++ extensions just increase speed, and does that affect memory footprint?
...
Looking forward to your reply!

Hey thank you for the kind words.
I would say building pytorch extension in C++ is not super easy but not very hard either. You can start with their docs and tutorial here : https://pytorch.org/cppdocs/
The interface between python and C++ is quite easy to deal with, and implement some functions with·
Using Cuda (so GPU computations) is harder tho.
C++ extensions will increase the speed of your algorithms when they replace python code like for loops on your tensors.
Memory footprints shouldn't change as you can reuse tensors created in python in your C++ code, but you need to know how to manage memory in C++, just to avoid memory leaks and unstable code.

hello I'm back again!
in file 3DNetworksPytorch/C_utils/src/PointSift_cuda.cu:

__global__ void cubeselect(int n,float radius, const float* xyz, int* idx_out)
...
                int temp_idx = _x * 4 + _y * 2 + _z;
                if(dist < temp_dist[temp_idx]) {
                    idx_out[i * 8 + temp_idx] = j;
                    temp_dist[temp_idx] = dist;
                }
...

do you know why _x * 4 + _y * 2 + _z can identify the octant where the dot is located?

Hey @leungMr ,
I had to read the code again to be sure ahah, Haven't looked at it in a long time. and because it is not my paper, it took me a few minutes to understand.
so :
int _x = (tx > x); int _y = (ty > y); int _z = (tz > z); int temp_idx = _x * 4 + _y * 2 + _z;

_x, _y, _z give you the position of the found point around the point you are looking for the neighbours. And temp_idx moves the index in the cube octant using them so moving 4 times on X cells, 2 times on Y cells and 1 on z. because of the point in the cube's centre. Bellow in cubselect two you have an example for 16 cells cuboid.
Maybe I am not making sense, the easiest way is to make a drawing ahah. I hope I could help :)
I also realised that I didnt add pointsift cuda code to the CPP version.

Thank you for your time and patience!

I have learned your code again these days and found some mistakes (about pointsift). I will point them out after I have confirmed one by one.
Although I have fixed some errors, currently my experiment has not achieved the desired effect, which bothering me.
May I ask, have you run all the code related to PointSitf and how accurate is it

Hey @leungMr ,

For pointsift, all the cuda code is from the original repository and I just added the C/C++ code and python models.
But if you find errors, please let me know!

For performances, I remember this code achieving similar performances to the original, minus the finetuning and various optimizations of training the author might have done.

I you want more help regarding your research and experiments, I am free these days for collaborations, so don't hesitate dropping me an email!