File tree Expand file tree Collapse file tree 1 file changed +11
-17
lines changed Expand file tree Collapse file tree 1 file changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -2157,26 +2157,20 @@ void CpuMatrix::maxPoolForward(Matrix& inputMat,
2157
2157
int wend = wstart + sizeX;
2158
2158
wstart = wstart < 0 ? 0 : wstart;
2159
2159
wend = wend < (int )imgSizeW ? wend : (int )imgSizeW;
2160
- if (maskData == NULL ) {
2161
- real tmp = -(real)FLT_MAX;
2162
- for (int h = hstart; h < hend; ++h) {
2163
- for (int w = wstart; w < wend; ++w) {
2164
- tmp = tmp < inputData[h * imgSizeW + w]
2165
- ? inputData[h * imgSizeW + w]
2166
- : tmp;
2167
- }
2168
- }
2169
- outData[ph * outputW + pw] = tmp;
2170
- } else {
2171
- for (int h = hstart; h < hend; ++h) {
2172
- for (int w = wstart; w < wend; ++w) {
2173
- if (outData[ph * outputW + pw] < inputData[h * imgSizeW + w]) {
2174
- outData[ph * outputW + pw] = inputData[h * imgSizeW + w];
2175
- maskData[ph * outputW + pw] = h * imgSizeW + w;
2176
- }
2160
+
2161
+ real maxval = -(real)FLT_MAX;
2162
+ int max_index = -1 ;
2163
+ for (int h = hstart; h < hend; ++h) {
2164
+ for (int w = wstart; w < wend; ++w) {
2165
+ if (maxval < inputData[h * imgSizeW + w]) {
2166
+ maxval = inputData[h * imgSizeW + w];
2167
+ max_index = h * imgSizeW + w;
2177
2168
}
2178
2169
}
2179
2170
}
2171
+
2172
+ outData[ph * outputW + pw] = maxval;
2173
+ if (maskData != NULL ) maskData[ph * outputW + pw] = max_index;
2180
2174
}
2181
2175
}
2182
2176
// compute offset
You can’t perform that action at this time.
0 commit comments