MCPcopy Create free account
hub / github.com/apache/singa / Col2im

Function Col2im

src/model/layer/convolution.cc:224–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224void Col2im(const float *data_col, const int channels,
225 const int height, const int width,
226 const int kernel_h, const int kernel_w,
227 const int pad_h, const int pad_w,
228 const int stride_h, const int stride_w,
229 float *data_im) {
230 memset(data_im, 0, (unsigned long) height * width * channels * sizeof(float));
231 int height_col = (height + 2 * pad_h - kernel_h) / stride_h + 1;
232 int width_col = ( width + 2 * pad_w - kernel_w) / stride_w + 1;
233 int channels_col = channels * kernel_h * kernel_w;
234 for (int c = 0; c < channels_col; ++c) {
235 int w_offset = c % kernel_w;
236 int h_offset = (c / kernel_w) % kernel_h;
237 int c_im = c / kernel_h / kernel_w;
238 for (int h = 0; h < height_col; ++h) {
239 for (int w = 0; w < width_col; ++w) {
240 int h_pad = h * stride_h - pad_h + h_offset;
241 int w_pad = w * stride_w - pad_w + w_offset;
242 if (h_pad >= 0 && h_pad < height && w_pad >= 0 && w_pad < width)
243 data_im[(c_im * height + h_pad) * width + w_pad] +=
244 data_col[(c * height_col + h) * width_col + w];
245 }
246 }
247 }
248}
249} // namespace singa

Callers 1

BackwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected