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

Method BackwardMaxPooling

src/model/layer/pooling.cc:208–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208void Pooling::BackwardMaxPooling(const float* top, const float* mask,
209 const int num, const int channels,
210 const int height, const int width,
211 const int pooled_h, const int pooled_w,
212 const int kernel_h, const int kernel_w,
213 const int pad_h, const int pad_w,
214 const int stride_h, const int stride_w,
215 float* bottom) {
216 const int top_offset = pooled_h * pooled_w;
217 const int bottom_offset = height * width;
218 memset(bottom, 0, sizeof(float) * num * channels * bottom_offset);
219 for (int n = 0; n < num; ++n) {
220 for (int c = 0; c < channels; ++c) {
221 for (int ph = 0; ph < pooled_h; ++ph) {
222 for (int pw = 0; pw < pooled_w; ++pw) {
223 const int top_idx = ph * pooled_w + pw;
224 const int bottom_idx = static_cast<int>(mask[top_idx]);
225 bottom[bottom_idx] += top[top_idx];
226 }
227 }
228 top += top_offset;
229 mask += top_offset;
230 bottom += bottom_offset;
231 }
232 }
233}
234
235void Pooling::ForwardAvgPooling(const float* bottom, const int num,
236 const int channels,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected