larroy commented on a change in pull request #15531: [MXNET-978] Higher Order 
Gradient Support `arctan`, `arctanh`, `radians`.
URL: https://github.com/apache/incubator-mxnet/pull/15531#discussion_r317840212
 
 

 ##########
 File path: src/operator/tensor/elemwise_unary_op_trig.cc
 ##########
 @@ -227,7 +228,35 @@ The storage type of ``arctan`` output depends upon the 
input storage type:
 .set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{ "_backward_arctan" 
});
 
 MXNET_OPERATOR_REGISTER_BINARY_WITH_SPARSE_CPU_DR(_backward_arctan,
-                                                  
unary_bwd<mshadow_op::arctan_grad>);
+                                                  
unary_bwd<mshadow_op::arctan_grad>)
+.set_attr<nnvm::FGradient>("FGradient",
+    [](const nnvm::NodePtr& n, const std::vector<nnvm::NodeEntry>& ograds) {
+      // ograds[0]: head_grad_grads (dL/dxgrad)
+      // inputs[0]: dL/dy
+      // inputs[1]: x (ElemwiseGradUseIn)
+      // n: dL/dy * f'(x)
+      // f(x) = arctanh(x)
+      // dydx = f'(x) = 1/(1+x^2)
+      // f''(x) = f'(x) * f'(x) * -2 * x = (-2 * x) / (1 + x^2)^2
+      // return:
+      //     0: dL/dy_grad * dy/dx
+      //     1: dL/dy_grad * dL/dy * f''(x)
+      auto dldy = n->inputs[0];
+      auto x = n->inputs[1];
+      auto dldy_mul_dydx = nnvm::NodeEntry{n};
+      auto Op = mxnet::util::NodeOp{n};
 
 Review comment:
   Isn't this supposed to be camel case? "Regular functions have mixed case; 
accessors and mutators may be named like variables."
   
   

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to