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_r174234577
 
 

 ##########
 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;
+      }
+  } else if (param.kernel.ndim() == 1) {
     CHECK_EQ(dshape.ndim(), 3U)
         << "Pooling: Input data should be 3D in (batch, channel, x)";
     if (param.global_pool) {
 
 Review comment:
   These `if` can be removed because the global_pool case is handled before.

----------------------------------------------------------------
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

Reply via email to