You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2017/11/01 17:26:43 UTC

[incubator-mxnet] branch master updated: Fix of log10_grad, log2_grad (#8502)

This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new e22d993  Fix of log10_grad, log2_grad (#8502)
e22d993 is described below

commit e22d993a4442575b03be71a2cb6deddbbdc77387
Author: mseeger <ms...@gmail.com>
AuthorDate: Wed Nov 1 18:26:40 2017 +0100

    Fix of log10_grad, log2_grad (#8502)
---
 src/operator/mshadow_op.h | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/operator/mshadow_op.h b/src/operator/mshadow_op.h
index a0d6ee3..04db326 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);
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].