C++ extension of RoIPool & RoIAlign (both CPU and GPU) in PyTorch,this code is converted from caffe2 operation. (need pytorch 0.4.0)
**Warning:**You may change AT_CHECK
to AT_ASSERT
(0.4 version using AT_ASSERT
, and latest version using AT_CHECK
)
**Note: **
roi_xxx_cpu.cpp
&roi_xxx_binding.cpp
:contains the cpu version of forward and backward operation.(Note:roi_xxx_binding.cpp
is for pybind, you can put this code intoroi_xxx_cpu.cpp
as well)roi_xxx_kernel.cu
&roi_xxx_cuda.cpp
:contains the cuda version of forward and backward operation.main.py
&temp.h
&CMakeLists.txt
:help you to debug in c++ code, rather than to runpython setup.py install
to debug. (Note: only support cpu version ~ I don't know how to debug.cu
code 😣)setup.py
:you can runpython setup.py install
to install this operation as a package (You can find this package in you python site-package)roi_xxx.py
:wrap.cpp
code to pytorch'sFunction & Module
,there is also a small demo testing.
Install
cd roixxx # roipool or roialign
python setup.py install
The "strategy" of roi-pooling in this implementaion likes the follow picture:(:joy: so bad picture)
Note: (please stand on point view rather than block view)
- scale=0.5
- dotted line is the range of "seleted area" (int form in
[left, right)
and[top, bottom)
)
Note: left sample=1
, right sample=2
There are several good resource to explain these two operations:
- caffe2 operator:most of the code is coming from here.
- extension-cpp: tutorial
- detectorch