larroy closed pull request #13340: fix ActivationGradCompute on CPU (had an 
assertion when not on GPU & MKL)
URL: https://github.com/apache/incubator-mxnet/pull/13340
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/operator/nn/activation-inl.h b/src/operator/nn/activation-inl.h
index 2705177f951..8ea6b7563ef 100644
--- a/src/operator/nn/activation-inl.h
+++ b/src/operator/nn/activation-inl.h
@@ -199,12 +199,20 @@ void ActivationGradCompute(const nnvm::NodeAttrs& attrs,
                            const std::vector<OpReqType>& req,
                            const std::vector<TBlob>& outputs) {
   const ActivationParam& param = nnvm::get<ActivationParam>(attrs.parsed);
+
+  const int act_type = param.act_type;
 #if (MXNET_USE_CUDNN == 1 || MXNET_USE_MKLDNN == 1)
-  bool relu = param.act_type == activation::kReLU;
-  CHECK_EQ(inputs.size(), relu ? 2U : 3U);
+  if (act_type != activation::kReLU && act_type != activation::kSoftSign) {
+    CHECK_EQ(inputs.size(), 3U);
+  } else {
+    CHECK_EQ(inputs.size(), 2U);
+  }
 #else
-  bool softsign = param.act_type == activation::kSoftSign;
-  CHECK_EQ(inputs.size(), softsign ? 3U : 2U);
+  if (act_type == activation::kSoftSign) {
+    CHECK_EQ(inputs.size(), 3U);
+  } else {
+    CHECK_EQ(inputs.size(), 2U);
+  }
 #endif
   CHECK_EQ(outputs.size(), 1U);
   CHECK_EQ(req.size(), 1U);


 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to