sxjscience commented on a change in pull request #10000: [MXNET-80] Fix average pooling kernel size assignment error URL: https://github.com/apache/incubator-mxnet/pull/10000#discussion_r174234503
########## File path: src/operator/nn/pooling.cc ########## @@ -98,9 +103,24 @@ static bool PoolingShape(const nnvm::NodeAttrs &attrs, << "Pooling: Input data should be 3D in (batch, channel, x)" << " Or 4D in (batch, channel, y, x) " << " Or 5D in (batch, channel, d, y, x)"; + CHECK_LE(dshape.ndim(), 5U) + << "Pooling: Input data should be 3D in (batch, channel, x)" + << " Or 4D in (batch, channel, y, x) " + << " Or 5D in (batch, channel, d, y, x)"; TShape oshape = dshape; if (dshape.ndim() == 0) return false; - if (param.kernel.ndim() == 1) { + if (param.global_pool) { + if (dshape.ndim() == 3) { + oshape[2] = 1; + } else if (dshape.ndim() == 4) { + oshape[2] = 1; + oshape[3] = 1; + } else if (dshape.ndim() == 5) { + oshape[2] = 1; + oshape[3] = 1; + oshape[4] = 1; + } Review comment: Also, you can use a for-loop instead of if. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services