akarbown commented on a change in pull request #19896:
URL: https://github.com/apache/incubator-mxnet/pull/19896#discussion_r643227365



##########
File path: src/operator/contrib/adaptive_avg_pooling-inl.h
##########
@@ -43,6 +43,9 @@
 #include "../operator_common.h"
 #include "../mxnet_op.h"
 #include "../mshadow_op.h"
+#if MXNET_USE_MKLDNN == 1

Review comment:
       Please change it to MXNET_USE_ONEDNN.

##########
File path: src/operator/contrib/adaptive_avg_pooling.cc
##########
@@ -197,6 +198,81 @@ 
num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount())
   }
 }
 
+#if MXNET_USE_MKLDNN == 1

Review comment:
       Please change it to MXNET_USE_ONEDNN.

##########
File path: src/operator/contrib/adaptive_avg_pooling.cc
##########
@@ -197,6 +198,81 @@ 
num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount())
   }
 }
 
+#if MXNET_USE_MKLDNN == 1
+bool SupportMKLDNNAveragePooling(const NDArray &in_data,
+                                    const NDArray &out_data) {
+  for (int64_t idx = 2; idx < in_data.shape().ndim(); ++idx) {
+    const int s1 = in_data.shape()[idx];
+    const int s2 = out_data.shape()[idx];
+    if (s2 == 0) {
+      return false;
+    }
+    if (s1 % s2 != 0) {
+      return false;
+    }
+  }
+  const int IH = in_data.shape()[2];
+  const int IW = in_data.shape()[3];
+  const int OH = out_data.shape()[2];
+  const int OW = out_data.shape()[3];
+
+  const int strides_1 = floor((IH << 1) / OH) - floor(IH / OH);
+  const int strides_2 = floor((IW << 1) / OW) - floor(IW / OW);

Review comment:
       Maybe worth considering to rename 'strides_1, strides_2' to 
'strides_H/strides_W'?

##########
File path: src/operator/contrib/adaptive_avg_pooling.cc
##########
@@ -197,6 +198,81 @@ 
num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount())
   }
 }
 
+#if MXNET_USE_MKLDNN == 1
+bool SupportMKLDNNAveragePooling(const NDArray &in_data,
+                                    const NDArray &out_data) {
+  for (int64_t idx = 2; idx < in_data.shape().ndim(); ++idx) {
+    const int s1 = in_data.shape()[idx];
+    const int s2 = out_data.shape()[idx];
+    if (s2 == 0) {
+      return false;
+    }
+    if (s1 % s2 != 0) {
+      return false;
+    }
+  }
+  const int IH = in_data.shape()[2];
+  const int IW = in_data.shape()[3];
+  const int OH = out_data.shape()[2];
+  const int OW = out_data.shape()[3];
+
+  const int strides_1 = floor((IH << 1) / OH) - floor(IH / OH);
+  const int strides_2 = floor((IW << 1) / OW) - floor(IW / OW);
+  const int kernel_1 = ceil((IH << 1) / OH) - floor(IH / OH);
+  const int kernel_2 = ceil((IW << 1) / OW) - floor(IW / OW);

Review comment:
       The same as the comment above but connected with 'kernel_1/kernel2'?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to