168 float defaultInitializer = DefaultInitializer(params.
m_PoolType);
170 Accumulator accumulate = GetAccumulator(params.
m_PoolType);
171 Executor execute = GetExecutor(params.
m_PoolType);
183 for (
int n = 0; n < batchSize; n++)
185 for (
int c = 0; c < channels; c++)
187 for (
int yOutput = 0; yOutput < heightOutput; yOutput++)
190 int hstart = (yOutput * strideY) - padTop;
191 int hend = hstart + poolHeight;
194 hend = std::min(hend, heightInput + padBottom);
196 int height = hend - hstart;
197 bool hclamped = ClampRange(hstart, hend, heightInput);
199 for (
int xOutput = 0; xOutput < widthOutput; xOutput++)
201 int wstart = (xOutput * strideX) - padLeft;
202 int wend = wstart + poolWidth;
206 wend = std::min(wend, widthInput + padRight);
208 float result = defaultInitializer;
216 if (OnPaddingOnly(hstart, hend, heightInput) ||
217 OnPaddingOnly(wstart, wend, widthInput))
225 outputIndex = n * heightOutput * widthOutput * channels +
226 yOutput * widthOutput * channels +
232 outputIndex = n * heightOutput * widthOutput * channels +
233 c * heightOutput * widthOutput +
234 yOutput * widthOutput +
238 rOutputEncoder[
static_cast<unsigned int>(outputIndex)];
239 rOutputEncoder.
Set(result);
243 bool clamped = hclamped |= ClampRange(wstart, wend, widthInput);
252 for (
auto yInput = hstart; yInput < hend; yInput++)
254 for (
auto xInput = wstart; xInput < wend; xInput++)
260 inputIndex = n * heightInput * widthInput * channels +
261 yInput * widthInput * channels +
268 inputIndex = n * heightInput * widthInput * channels +
269 c * heightInput * widthInput +
270 yInput * widthInput +
274 accumulate(result, decodedInputVec[
static_cast<unsigned int>(inputIndex)]);
278 execute(result, poolAreaSize);
284 outputIndex = n * heightOutput * widthOutput * channels +
285 yOutput * widthOutput * channels +
291 outputIndex = n * heightOutput * widthOutput * channels +
292 c * heightOutput * widthOutput +
293 yOutput * widthOutput +
297 rOutputEncoder[
static_cast<unsigned int>(outputIndex)];
298 rOutputEncoder.
Set(result);