const int pad_h, const int pad_w,
const int stride_h, const int stride_w,
Dtype* data_col) {
- 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 channels_col = channels * kernel_h * kernel_w;
+ const int height_col = (height + 2 * pad_h - kernel_h) / stride_h + 1;
+ const int width_col = (width + 2 * pad_w - kernel_w) / stride_w + 1;
+ const int channels_col = channels * kernel_h * kernel_w;
for (int c_col = 0; c_col < channels_col; ++c_col) {
int w_offset = c_col % kernel_w;
int h_offset = (c_col / kernel_w) % kernel_h;
const int stride_h, const int stride_w,
Dtype* data_im) {
caffe_set(height * width * channels, Dtype(0), data_im);
- 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 channels_col = channels * kernel_h * kernel_w;
+ const int height_col = (height + 2 * pad_h - kernel_h) / stride_h + 1;
+ const int width_col = (width + 2 * pad_w - kernel_w) / stride_w + 1;
+ const int channels_col = channels * kernel_h * kernel_w;
for (int c_col = 0; c_col < channels_col; ++c_col) {
int w_offset = c_col % kernel_w;
int h_offset = (c_col / kernel_w) % kernel_h;
const int height_col, const int width_col,
Dtype* data_col) {
CUDA_KERNEL_LOOP(index, n) {
- int h_index = index / width_col;
- int h_col = h_index % height_col;
- int w_col = index % width_col;
- int c_im = h_index / height_col;
- int c_col = c_im * kernel_h * kernel_w;
- int h_offset = h_col * stride_h - pad_h;
- int w_offset = w_col * stride_w - pad_w;
+ const int h_index = index / width_col;
+ const int h_col = h_index % height_col;
+ const int w_col = index % width_col;
+ const int c_im = h_index / height_col;
+ const int c_col = c_im * kernel_h * kernel_w;
+ const int h_offset = h_col * stride_h - pad_h;
+ const int w_offset = w_col * stride_w - pad_w;
Dtype* data_col_ptr = data_col;
data_col_ptr += (c_col * height_col + h_col) * width_col + w_col;
const Dtype* data_im_ptr = data_im;
Dtype* data_im) {
CUDA_KERNEL_LOOP(index, n) {
Dtype val = 0;
- int w_im = index % width + pad_w;
- int h_im = (index / width) % height + pad_h;
- int c_im = index / (width * height);
+ const int w_im = index % width + pad_w;
+ const int h_im = (index / width) % height + pad_h;
+ const int c_im = index / (width * height);
// compute the start and end of the output
- int w_col_start = (w_im < kernel_w) ? 0 : (w_im - kernel_w) / stride_w + 1;
- int w_col_end = min(w_im / stride_w + 1, width_col);
- int h_col_start = (h_im < kernel_h) ? 0 : (h_im - kernel_h) / stride_h + 1;
- int h_col_end = min(h_im / stride_h + 1, height_col);
+ const int w_col_start =
+ (w_im < kernel_w) ? 0 : (w_im - kernel_w) / stride_w + 1;
+ const int w_col_end =
+ min(w_im / stride_w + 1, width_col);
+ const int h_col_start =
+ (h_im < kernel_h) ? 0 : (h_im - kernel_h) / stride_h + 1;
+ const int h_col_end =
+ min(h_im / stride_h + 1, height_col);
/*
for (int h_col = h_col_start; h_col < h_col_end; ++h_col) {
for (int w_col = w_col_start; w_col < w_col_end; ++w_col) {