You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/09/03 02:58:41 UTC

[GitHub] [incubator-mxnet] xinyu-intel commented on a change in pull request #16075: [WIP]Integrate MKL-DNN leakyrelu

xinyu-intel commented on a change in pull request #16075: [WIP]Integrate MKL-DNN leakyrelu
URL: https://github.com/apache/incubator-mxnet/pull/16075#discussion_r320076234
 
 

 ##########
 File path: src/operator/nn/mkldnn/mkldnn_act.cc
 ##########
 @@ -57,30 +57,56 @@ bool SupportMKLDNNAct(const ActivationParam& param, const NDArray &input) {
   return SupportMKLDNNAct(param);
 }
 
+bool SupportMKLDNNLeakyRelu(const LeakyReLUParam& param) {
+  return param.act_type == leakyrelu::kLeakyReLU
+      || param.act_type == leakyrelu::kELU;
+}
+
+bool SupportMKLDNNLeakyRelu(const LeakyReLUParam& param, const NDArray &input) {
+  // MKL-DNN Activation supports 1d, 2d, 3d, 4d data layout
+  if ((input.shape().ndim() < 1) ||
+      (input.shape().ndim() > 4) ||
+      (input.dtype() != mshadow::kFloat32))
+    return false;
+  return SupportMKLDNNLeakyRelu(param);
+}
+
 bool SupportQuantizedMKLDNNAct(const ActivationParam &param) {
   // TODO(zhennan): Add more activation type when mkldnn supports.
   //                Remove this when it's identity to SupportMKLDNNAct.
   return param.act_type == activation::kReLU;
 }
 
-mkldnn::algorithm GetMKLDNNActAlgo(const ActivationParam& param) {
-  switch (param.act_type) {
-    case activation::kReLU:
-      return mkldnn::algorithm::eltwise_relu;
-    case activation::kSigmoid:
-      return mkldnn::algorithm::eltwise_logistic;
-    case activation::kTanh:
-      return mkldnn::algorithm::eltwise_tanh;
-    case activation::kSoftReLU:
-      return mkldnn::algorithm::eltwise_soft_relu;
-    default:
-      LOG(FATAL) << "unknown activation type";
-      return mkldnn::algorithm::eltwise_relu;
+mkldnn::algorithm GetMKLDNNActAlgo(const MKLDNNActParam& param) {
+  if (param.is_leakyrelu) {
 
 Review comment:
   addressed

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services