Skip to content

Commit

Permalink
Merge pull request jwyang#286 from ahmed-shariff/master
Browse files Browse the repository at this point in the history
Fixes to build on pytorch master and python 3.7
  • Loading branch information
jwyang authored Aug 29, 2018
2 parents f0bec5a + 58a07fe commit e283c7d
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 8,783 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,6 @@ caffe2.egg-info
# Atom/Watchman required file
.watchmanconfig

# cython generated files
lib/model/utils/bbox.c
lib/pycocotools/_mask.c
3 changes: 3 additions & 0 deletions lib/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# CUDA_PATH=/usr/local/cuda/

export CUDA_PATH=/usr/local/cuda/
#You may also want to ad the following
#export C_INCLUDE_PATH=/opt/cuda/include

export CXXFLAGS="-std=c++11"
export CFLAGS="-std=c99"

Expand Down
4 changes: 2 additions & 2 deletions lib/model/nms/src/nms_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ int nms_cuda(THCudaIntTensor *keep_out, THCudaTensor *boxes_host,
nms_cuda_compute(THCudaIntTensor_data(state, keep_out),
THCudaIntTensor_data(state, num_out),
THCudaTensor_data(state, boxes_host),
boxes_host->size[0],
boxes_host->size[1],
THCudaTensor_size(state, boxes_host, 0),
THCudaTensor_size(state, boxes_host, 1),
nms_overlap_thresh);

return 1;
Expand Down
173 changes: 85 additions & 88 deletions lib/model/roi_crop/src/roi_crop.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@
int BilinearSamplerBHWD_updateOutput(THFloatTensor *inputImages, THFloatTensor *grids, THFloatTensor *output)
{

int batchsize = inputImages->size[0];
int inputImages_height = inputImages->size[1];
int inputImages_width = inputImages->size[2];
int output_height = output->size[1];
int output_width = output->size[2];
int inputImages_channels = inputImages->size[3];
int batchsize = THFloatTensor_size(inputImages, 0);
int inputImages_height = THFloatTensor_size(inputImages, 1);
int inputImages_width = THFloatTensor_size(inputImages, 2);
int output_height = THFloatTensor_size(output, 1);
int output_width = THFloatTensor_size(output, 2);
int inputImages_channels = THFloatTensor_size(inputImages, 3);

int output_strideBatch = output->stride[0];
int output_strideHeight = output->stride[1];
int output_strideWidth = output->stride[2];
int output_strideBatch = THFloatTensor_stride(output, 0);
int output_strideHeight = THFloatTensor_stride(output, 1);
int output_strideWidth = THFloatTensor_stride(output, 2);

int inputImages_strideBatch = inputImages->stride[0];
int inputImages_strideHeight = inputImages->stride[1];
int inputImages_strideWidth = inputImages->stride[2];

int grids_strideBatch = grids->stride[0];
int grids_strideHeight = grids->stride[1];
int grids_strideWidth = grids->stride[2];
int inputImages_strideBatch = THFloatTensor_stride(inputImages, 0);
int inputImages_strideHeight = THFloatTensor_stride(inputImages, 1);
int inputImages_strideWidth = THFloatTensor_stride(inputImages, 2);

int grids_strideBatch = THFloatTensor_stride(grids, 0);
int grids_strideHeight = THFloatTensor_stride(grids, 1);
int grids_strideWidth = THFloatTensor_stride(grids, 2);

real *inputImages_data, *output_data, *grids_data;
inputImages_data = THFloatTensor_data(inputImages);
Expand Down Expand Up @@ -107,32 +106,32 @@ int BilinearSamplerBHWD_updateGradInput(THFloatTensor *inputImages, THFloatTenso
{
bool onlyGrid=false;

int batchsize = inputImages->size[0];
int inputImages_height = inputImages->size[1];
int inputImages_width = inputImages->size[2];
int gradOutput_height = gradOutput->size[1];
int gradOutput_width = gradOutput->size[2];
int inputImages_channels = inputImages->size[3];
int batchsize = THFloatTensor_size(inputImages, 0);
int inputImages_height = THFloatTensor_size(inputImages, 1);
int inputImages_width = THFloatTensor_size(inputImages, 2);
int gradOutput_height = THFloatTensor_size(gradOutput, 1);
int gradOutput_width = THFloatTensor_size(gradOutput, 2);
int inputImages_channels = THFloatTensor_size(inputImages, 3);

int gradOutput_strideBatch = gradOutput->stride[0];
int gradOutput_strideHeight = gradOutput->stride[1];
int gradOutput_strideWidth = gradOutput->stride[2];
int gradOutput_strideBatch = THFloatTensor_stride(gradOutput, 0);
int gradOutput_strideHeight = THFloatTensor_stride(gradOutput, 1);
int gradOutput_strideWidth = THFloatTensor_stride(gradOutput, 2);

int inputImages_strideBatch = inputImages->stride[0];
int inputImages_strideHeight = inputImages->stride[1];
int inputImages_strideWidth = inputImages->stride[2];
int inputImages_strideBatch = THFloatTensor_stride(inputImages, 0);
int inputImages_strideHeight = THFloatTensor_stride(inputImages, 1);
int inputImages_strideWidth = THFloatTensor_stride(inputImages, 2);

int gradInputImages_strideBatch = gradInputImages->stride[0];
int gradInputImages_strideHeight = gradInputImages->stride[1];
int gradInputImages_strideWidth = gradInputImages->stride[2];
int gradInputImages_strideBatch = THFloatTensor_stride(gradInputImages, 0);
int gradInputImages_strideHeight = THFloatTensor_stride(gradInputImages, 1);
int gradInputImages_strideWidth = THFloatTensor_stride(gradInputImages, 2);

int grids_strideBatch = grids->stride[0];
int grids_strideHeight = grids->stride[1];
int grids_strideWidth = grids->stride[2];
int grids_strideBatch = THFloatTensor_stride(grids, 0);
int grids_strideHeight = THFloatTensor_stride(grids, 1);
int grids_strideWidth = THFloatTensor_stride(grids, 2);

int gradGrids_strideBatch = gradGrids->stride[0];
int gradGrids_strideHeight = gradGrids->stride[1];
int gradGrids_strideWidth = gradGrids->stride[2];
int gradGrids_strideBatch = THFloatTensor_stride(gradGrids, 0);
int gradGrids_strideHeight = THFloatTensor_stride(gradGrids, 1);
int gradGrids_strideWidth = THFloatTensor_stride(gradGrids, 2);

real *inputImages_data, *gradOutput_data, *grids_data, *gradGrids_data, *gradInputImages_data;
inputImages_data = THFloatTensor_data(inputImages);
Expand Down Expand Up @@ -240,29 +239,28 @@ int BilinearSamplerBHWD_updateGradInput(THFloatTensor *inputImages, THFloatTenso
int BilinearSamplerBCHW_updateOutput(THFloatTensor *inputImages, THFloatTensor *grids, THFloatTensor *output)
{

int batchsize = inputImages->size[0];
int inputImages_height = inputImages->size[2];
int inputImages_width = inputImages->size[3];
int batchsize = THFloatTensor_size(inputImages, 0);
int inputImages_height = THFloatTensor_size(inputImages, 2);
int inputImages_width = THFloatTensor_size(inputImages, 3);

int output_height = output->size[2];
int output_width = output->size[3];
int inputImages_channels = inputImages->size[1];

int output_strideBatch = output->stride[0];
int output_strideHeight = output->stride[2];
int output_strideWidth = output->stride[3];
int output_strideChannel = output->stride[1];
int output_height = THFloatTensor_size(output, 2);
int output_width = THFloatTensor_size(output, 3);
int inputImages_channels = THFloatTensor_size(inputImages, 1);

int output_strideBatch = THFloatTensor_stride(output, 0);
int output_strideHeight = THFloatTensor_stride(output, 2);
int output_strideWidth = THFloatTensor_stride(output, 3);
int output_strideChannel = THFloatTensor_stride(output, 1);

int inputImages_strideBatch = THFloatTensor_stride(inputImages, 0);
int inputImages_strideHeight = THFloatTensor_stride(inputImages, 2);
int inputImages_strideWidth = THFloatTensor_stride(inputImages, 3);
int inputImages_strideChannel = THFloatTensor_stride(inputImages, 1);

int inputImages_strideBatch = inputImages->stride[0];
int inputImages_strideHeight = inputImages->stride[2];
int inputImages_strideWidth = inputImages->stride[3];
int inputImages_strideChannel = inputImages->stride[1];

int grids_strideBatch = grids->stride[0];
int grids_strideHeight = grids->stride[2];
int grids_strideWidth = grids->stride[3];
int grids_strideChannel = grids->stride[1];
int grids_strideBatch = THFloatTensor_stride(grids, 0);
int grids_strideHeight = THFloatTensor_stride(grids, 2);
int grids_strideWidth = THFloatTensor_stride(grids, 3);
int grids_strideChannel = THFloatTensor_stride(grids, 1);


real *inputImages_data, *output_data, *grids_data;
Expand Down Expand Up @@ -346,38 +344,37 @@ int BilinearSamplerBCHW_updateGradInput(THFloatTensor *inputImages, THFloatTenso
{
bool onlyGrid=false;

int batchsize = inputImages->size[0];
int inputImages_height = inputImages->size[2];
int inputImages_width = inputImages->size[3];
int gradOutput_height = gradOutput->size[2];
int gradOutput_width = gradOutput->size[3];
int inputImages_channels = inputImages->size[1];

int gradOutput_strideBatch = gradOutput->stride[0];
int gradOutput_strideHeight = gradOutput->stride[2];
int gradOutput_strideWidth = gradOutput->stride[3];
int gradOutput_strideChannel = gradOutput->stride[1];

int inputImages_strideBatch = inputImages->stride[0];
int inputImages_strideHeight = inputImages->stride[2];
int inputImages_strideWidth = inputImages->stride[3];
int inputImages_strideChannel = inputImages->stride[1];
int batchsize = THFloatTensor_size(inputImages, 0);
int inputImages_height = THFloatTensor_size(inputImages, 2);
int inputImages_width = THFloatTensor_size(inputImages, 3);
int gradOutput_height = THFloatTensor_size(gradOutput, 2);
int gradOutput_width = THFloatTensor_size(gradOutput, 3);
int inputImages_channels = THFloatTensor_size(inputImages, 1);

int gradOutput_strideBatch = THFloatTensor_stride(gradOutput, 0);
int gradOutput_strideHeight = THFloatTensor_stride(gradOutput, 2);
int gradOutput_strideWidth = THFloatTensor_stride(gradOutput, 3);
int gradOutput_strideChannel = THFloatTensor_stride(gradOutput, 1);

int inputImages_strideBatch = THFloatTensor_stride(inputImages, 0);
int inputImages_strideHeight = THFloatTensor_stride(inputImages, 2);
int inputImages_strideWidth = THFloatTensor_stride(inputImages, 3);
int inputImages_strideChannel = THFloatTensor_stride(inputImages, 1);


int gradInputImages_strideBatch = gradInputImages->stride[0];
int gradInputImages_strideHeight = gradInputImages->stride[2];
int gradInputImages_strideWidth = gradInputImages->stride[3];
int gradInputImages_strideChannel = gradInputImages->stride[1];

int grids_strideBatch = grids->stride[0];
int grids_strideHeight = grids->stride[2];
int grids_strideWidth = grids->stride[3];
int grids_strideChannel = grids->stride[1];

int gradGrids_strideBatch = gradGrids->stride[0];
int gradGrids_strideHeight = gradGrids->stride[2];
int gradGrids_strideWidth = gradGrids->stride[3];
int gradGrids_strideChannel = gradGrids->stride[1];
int gradInputImages_strideBatch = THFloatTensor_stride(gradInputImages, 0);
int gradInputImages_strideHeight = THFloatTensor_stride(gradInputImages, 2);
int gradInputImages_strideWidth = THFloatTensor_stride(gradInputImages, 3);
int gradInputImages_strideChannel = THFloatTensor_stride(gradInputImages, 1);

int grids_strideBatch = THFloatTensor_stride(grids, 0);
int grids_strideHeight = THFloatTensor_stride(grids, 2);
int grids_strideWidth = THFloatTensor_stride(grids, 3);
int grids_strideChannel = THFloatTensor_stride(grids, 1);

int gradGrids_strideBatch = THFloatTensor_stride(gradGrids, 0);
int gradGrids_strideHeight = THFloatTensor_stride(gradGrids, 2);
int gradGrids_strideWidth = THFloatTensor_stride(gradGrids, 3);
int gradGrids_strideChannel = THFloatTensor_stride(gradGrids, 1);

real *inputImages_data, *gradOutput_data, *grids_data, *gradGrids_data, *gradInputImages_data;
inputImages_data = THFloatTensor_data(inputImages);
Expand Down
116 changes: 58 additions & 58 deletions lib/model/roi_crop/src/roi_crop_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@ int BilinearSamplerBHWD_updateOutput_cuda(THCudaTensor *inputImages, THCudaTenso
// THCudaTensor *output = (THCudaTensor *)luaT_checkudata(L, 4, "torch.CudaTensor");

int success = 0;
success = BilinearSamplerBHWD_updateOutput_cuda_kernel(output->size[1],
output->size[3],
output->size[2],
output->size[0],
THCudaTensor_size(state, inputImages, 1),
THCudaTensor_size(state, inputImages, 2),
THCudaTensor_size(state, inputImages, 3),
THCudaTensor_size(state, inputImages, 0),
THCudaTensor_data(state, inputImages),
THCudaTensor_stride(state, inputImages, 0),
THCudaTensor_stride(state, inputImages, 1),
THCudaTensor_stride(state, inputImages, 2),
THCudaTensor_stride(state, inputImages, 3),
THCudaTensor_data(state, grids),
THCudaTensor_stride(state, grids, 0),
THCudaTensor_stride(state, grids, 3),
THCudaTensor_stride(state, grids, 1),
THCudaTensor_stride(state, grids, 2),
THCudaTensor_data(state, output),
THCudaTensor_stride(state, output, 0),
THCudaTensor_stride(state, output, 1),
THCudaTensor_stride(state, output, 2),
THCudaTensor_stride(state, output, 3),
THCState_getCurrentStream(state));
success = BilinearSamplerBHWD_updateOutput_cuda_kernel(THCudaTensor_size(state, output, 1),
THCudaTensor_size(state, output, 3),
THCudaTensor_size(state, output, 2),
THCudaTensor_size(state, output, 0),
THCudaTensor_size(state, inputImages, 1),
THCudaTensor_size(state, inputImages, 2),
THCudaTensor_size(state, inputImages, 3),
THCudaTensor_size(state, inputImages, 0),
THCudaTensor_data(state, inputImages),
THCudaTensor_stride(state, inputImages, 0),
THCudaTensor_stride(state, inputImages, 1),
THCudaTensor_stride(state, inputImages, 2),
THCudaTensor_stride(state, inputImages, 3),
THCudaTensor_data(state, grids),
THCudaTensor_stride(state, grids, 0),
THCudaTensor_stride(state, grids, 3),
THCudaTensor_stride(state, grids, 1),
THCudaTensor_stride(state, grids, 2),
THCudaTensor_data(state, output),
THCudaTensor_stride(state, output, 0),
THCudaTensor_stride(state, output, 1),
THCudaTensor_stride(state, output, 2),
THCudaTensor_stride(state, output, 3),
THCState_getCurrentStream(state));

//check for errors
if (!success) {
Expand All @@ -62,40 +62,40 @@ int BilinearSamplerBHWD_updateGradInput_cuda(THCudaTensor *inputImages, THCudaTe
// THCudaTensor *gradOutput = (THCudaTensor *)luaT_checkudata(L, 6, "torch.CudaTensor");

int success = 0;
success = BilinearSamplerBHWD_updateGradInput_cuda_kernel(gradOutput->size[1],
gradOutput->size[3],
gradOutput->size[2],
gradOutput->size[0],
THCudaTensor_size(state, inputImages, 1),
THCudaTensor_size(state, inputImages, 2),
THCudaTensor_size(state, inputImages, 3),
THCudaTensor_size(state, inputImages, 0),
THCudaTensor_data(state, inputImages),
THCudaTensor_stride(state, inputImages, 0),
THCudaTensor_stride(state, inputImages, 1),
THCudaTensor_stride(state, inputImages, 2),
THCudaTensor_stride(state, inputImages, 3),
THCudaTensor_data(state, grids),
THCudaTensor_stride(state, grids, 0),
THCudaTensor_stride(state, grids, 3),
THCudaTensor_stride(state, grids, 1),
THCudaTensor_stride(state, grids, 2),
THCudaTensor_data(state, gradInputImages),
THCudaTensor_stride(state, gradInputImages, 0),
THCudaTensor_stride(state, gradInputImages, 1),
THCudaTensor_stride(state, gradInputImages, 2),
THCudaTensor_stride(state, gradInputImages, 3),
THCudaTensor_data(state, gradGrids),
THCudaTensor_stride(state, gradGrids, 0),
THCudaTensor_stride(state, gradGrids, 3),
THCudaTensor_stride(state, gradGrids, 1),
THCudaTensor_stride(state, gradGrids, 2),
THCudaTensor_data(state, gradOutput),
THCudaTensor_stride(state, gradOutput, 0),
THCudaTensor_stride(state, gradOutput, 1),
THCudaTensor_stride(state, gradOutput, 2),
THCudaTensor_stride(state, gradOutput, 3),
THCState_getCurrentStream(state));
success = BilinearSamplerBHWD_updateGradInput_cuda_kernel(THCudaTensor_size(state, gradOutput, 1),
THCudaTensor_size(state, gradOutput, 3),
THCudaTensor_size(state, gradOutput, 2),
THCudaTensor_size(state, gradOutput, 0),
THCudaTensor_size(state, inputImages, 1),
THCudaTensor_size(state, inputImages, 2),
THCudaTensor_size(state, inputImages, 3),
THCudaTensor_size(state, inputImages, 0),
THCudaTensor_data(state, inputImages),
THCudaTensor_stride(state, inputImages, 0),
THCudaTensor_stride(state, inputImages, 1),
THCudaTensor_stride(state, inputImages, 2),
THCudaTensor_stride(state, inputImages, 3),
THCudaTensor_data(state, grids),
THCudaTensor_stride(state, grids, 0),
THCudaTensor_stride(state, grids, 3),
THCudaTensor_stride(state, grids, 1),
THCudaTensor_stride(state, grids, 2),
THCudaTensor_data(state, gradInputImages),
THCudaTensor_stride(state, gradInputImages, 0),
THCudaTensor_stride(state, gradInputImages, 1),
THCudaTensor_stride(state, gradInputImages, 2),
THCudaTensor_stride(state, gradInputImages, 3),
THCudaTensor_data(state, gradGrids),
THCudaTensor_stride(state, gradGrids, 0),
THCudaTensor_stride(state, gradGrids, 3),
THCudaTensor_stride(state, gradGrids, 1),
THCudaTensor_stride(state, gradGrids, 2),
THCudaTensor_data(state, gradOutput),
THCudaTensor_stride(state, gradOutput, 0),
THCudaTensor_stride(state, gradOutput, 1),
THCudaTensor_stride(state, gradOutput, 2),
THCudaTensor_stride(state, gradOutput, 3),
THCState_getCurrentStream(state));

//check for errors
if (!success) {
Expand Down
Loading

0 comments on commit e283c7d

Please sign in to comment.