| 105 | |
| 106 | template <typename Dtype> |
| 107 | void Im2colLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom, |
| 108 | const vector<Blob<Dtype>*>& top) { |
| 109 | vector<int> top_shape = bottom[0]->shape(); |
| 110 | const int* kernel_shape_data = kernel_shape_.cpu_data(); |
| 111 | const int* stride_data = stride_.cpu_data(); |
| 112 | const int* pad_data = pad_.cpu_data(); |
| 113 | const int* dilation_data = dilation_.cpu_data(); |
| 114 | for (int i = 0; i < num_spatial_axes_; ++i) { |
| 115 | top_shape[channel_axis_] *= kernel_shape_data[i]; |
| 116 | const int input_dim = bottom[0]->shape(channel_axis_ + i + 1); |
| 117 | const int kernel_extent = dilation_data[i] * (kernel_shape_data[i] - 1) + 1; |
| 118 | const int output_dim = (input_dim + 2 * pad_data[i] - kernel_extent) |
| 119 | / stride_data[i] + 1; |
| 120 | top_shape[channel_axis_ + i + 1] = output_dim; |
| 121 | } |
| 122 | top[0]->Reshape(top_shape); |
| 123 | num_ = bottom[0]->count(0, channel_axis_); |
| 124 | bottom_dim_ = bottom[0]->count(channel_axis_); |
| 125 | top_dim_ = top[0]->count(channel_axis_); |
| 126 | |
| 127 | channels_ = bottom[0]->shape(channel_axis_); |
| 128 | } |
| 129 | |
| 130 | template <typename Dtype> |
| 131 | void Im2colLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, |
no test coverage detected