Skip to content

Commit

Permalink
fixed im2col.
Browse files Browse the repository at this point in the history
  • Loading branch information
tianzhi0549 committed Dec 25, 2016
1 parent 70e6375 commit c3402ce
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions caffe/src/caffe/util/im2col.cu
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ __global__ void im2col_gpu_kernel(const int n, const Dtype* data_im,
}
}

template <typename Dtype>
void im2col_gpu(const Dtype* data_im, const int channels,
const int height, const int width, const int kernel_h, const int kernel_w,
const int pad_h, const int pad_w,
const int stride_h, const int stride_w,
Dtype* data_col) {
// We are going to launch channels * height_col * width_col kernels, each
// kernel responsible for copying a single-channel grid.
int height_col = (height + 2 * pad_h - kernel_h) / stride_h + 1;
int width_col = (width + 2 * pad_w - kernel_w) / stride_w + 1;
int num_kernels = channels * height_col * width_col;
// NOLINT_NEXT_LINE(whitespace/operators)
im2col_gpu_kernel<Dtype><<<CAFFE_GET_BLOCKS(num_kernels),
CAFFE_CUDA_NUM_THREADS>>>(
num_kernels, data_im, height, width, kernel_h, kernel_w, pad_h,
pad_w, stride_h, stride_w, height_col,
width_col, data_col);
CUDA_POST_KERNEL_CHECK;
}

// Explicit instantiation
template void im2col_gpu<float>(const float* data_im, const int channels,
const int height, const int width, const int kernel_h, const int kernel_w,
Expand Down

0 comments on commit c3402ce

Please sign in to comment.