From 4b845138e653ed318570bc22560bee9906210dd9 Mon Sep 17 00:00:00 2001 From: Vasileios Vryniotis Date: Sat, 24 Oct 2020 22:35:46 +0100 Subject: [PATCH 1/2] Convert to const reference and eliminate unnecessary bool casting. --- torchvision/csrc/cpu/DeformConv_cpu.cpp | 6 +++--- torchvision/csrc/cuda/DeformConv_cuda.cu | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/torchvision/csrc/cpu/DeformConv_cpu.cpp b/torchvision/csrc/cpu/DeformConv_cpu.cpp index a50eec3b76f..d3dd3d79873 100644 --- a/torchvision/csrc/cpu/DeformConv_cpu.cpp +++ b/torchvision/csrc/cpu/DeformConv_cpu.cpp @@ -597,7 +597,7 @@ static void deformable_col2im_coord_kernel( out_w; const int offset_c = c - offset_grp * 2 * weight_h * weight_w; - const int is_y_direction = offset_c % 2 == 0; + const bool is_y_direction = offset_c % 2 == 0; const int c_bound = c_per_offset_grp * weight_h * weight_w; for (int col_c = (offset_c / 2); col_c < c_bound; col_c += col_step) { @@ -812,9 +812,9 @@ static std::tuple deform_conv2d_backward_input_cpu( static at::Tensor deform_conv2d_backward_parameters_cpu( at::Tensor input, - at::Tensor weight, + const at::Tensor& weight, at::Tensor offset, - at::Tensor grad_out, + const at::Tensor& grad_out, std::pair stride, std::pair pad, std::pair dilation, diff --git a/torchvision/csrc/cuda/DeformConv_cuda.cu b/torchvision/csrc/cuda/DeformConv_cuda.cu index 7a45c6b5c45..f70a7c2a59f 100644 --- a/torchvision/csrc/cuda/DeformConv_cuda.cu +++ b/torchvision/csrc/cuda/DeformConv_cuda.cu @@ -618,7 +618,7 @@ __global__ void deformable_col2im_coord_gpu_kernel( out_h * out_w; const int offset_c = c - offset_grp * 2 * weight_h * weight_w; - const int is_y_direction = offset_c % 2 == 0; + const bool is_y_direction = offset_c % 2 == 0; const int c_bound = c_per_offset_grp * weight_h * weight_w; for (int col_c = (offset_c / 2); col_c < c_bound; col_c += col_step) { @@ -840,9 +840,9 @@ static std::tuple deform_conv_backward_input_cuda( static at::Tensor deform_conv_backward_parameters_cuda( at::Tensor input, - at::Tensor weight, + const at::Tensor& weight, at::Tensor offset, - at::Tensor grad_out, + const at::Tensor& grad_out, std::pair stride, std::pair pad, std::pair dilation, From 31131a8ed9107aa5a6ab32fa6f39e102a23c82cf Mon Sep 17 00:00:00 2001 From: Vasileios Vryniotis Date: Sun, 25 Oct 2020 12:52:30 +0000 Subject: [PATCH 2/2] Removing unnecessary namespace use. --- torchvision/csrc/cpu/DeformConv_cpu.cpp | 2 -- torchvision/csrc/cuda/DeformConv_cuda.cu | 2 -- 2 files changed, 4 deletions(-) diff --git a/torchvision/csrc/cpu/DeformConv_cpu.cpp b/torchvision/csrc/cpu/DeformConv_cpu.cpp index d3dd3d79873..c1580f7228a 100644 --- a/torchvision/csrc/cpu/DeformConv_cpu.cpp +++ b/torchvision/csrc/cpu/DeformConv_cpu.cpp @@ -74,8 +74,6 @@ #include #include -using namespace at; - const int kMaxParallelImgs = 32; template diff --git a/torchvision/csrc/cuda/DeformConv_cuda.cu b/torchvision/csrc/cuda/DeformConv_cuda.cu index f70a7c2a59f..89516ae8454 100644 --- a/torchvision/csrc/cuda/DeformConv_cuda.cu +++ b/torchvision/csrc/cuda/DeformConv_cuda.cu @@ -78,8 +78,6 @@ #include #include -using namespace at; - const unsigned int CUDA_NUM_THREADS = 1024; const int kMaxParallelImgs = 32;