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 2017/11/01 17:26:44 UTC

[GitHub] piiswrong closed pull request #8502: Fix of log10_grad, log2_grad

piiswrong closed pull request #8502: Fix of log10_grad, log2_grad
URL: https://github.com/apache/incubator-mxnet/pull/8502
 
 
   

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/mshadow_op.h b/src/operator/mshadow_op.h
index a0d6ee3068..04db326496 100644
--- a/src/operator/mshadow_op.h
+++ b/src/operator/mshadow_op.h
@@ -147,12 +147,32 @@ MXNET_UNARY_MATH_OP(log_grad, 1.0f / math::id(a));
 MXNET_SIMPLE_UNARY_MATH_OP(log10);
 
 // Constant is 1 / log(10)
-MXNET_UNARY_MATH_OP(log10_grad, 0.43429448190325182765 / math::id(a));
+struct log10_grad {
+  template<typename DType>
+  MSHADOW_XINLINE static DType Map(DType a) {
+    return DType(0.4342944819f / static_cast<float>(a));
+  }
+};
+
+template<>
+MSHADOW_XINLINE double log10_grad::Map<double>(double a) {
+  return 0.43429448190325182765 / a;
+}
 
 MXNET_SIMPLE_UNARY_MATH_OP(log2);
 
 // Constant is 1 / log(2)
-MXNET_UNARY_MATH_OP(log2_grad, 1.44269504088896340737 / math::id(a));
+struct log2_grad {
+  template<typename DType>
+  MSHADOW_XINLINE static DType Map(DType a) {
+    return DType(1.442695041f / static_cast<float>(a));
+  }
+};
+
+template<>
+MSHADOW_XINLINE double log2_grad::Map<double>(double a) {
+  return 1.44269504088896340737 / a;
+}
 
 MXNET_SIMPLE_UNARY_MATH_OP(sin);
 


 

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


With regards,
Apache Git Services