larroy commented on a change in pull request #14613: [MXNET-978] Higher order gradient support for some unary operators URL: https://github.com/apache/incubator-mxnet/pull/14613#discussion_r287533229
########## File path: src/operator/tensor/elemwise_binary_op_basic.cc ########## @@ -233,7 +233,17 @@ The storage type of ``elemwise_mul`` output depends on storage types of inputs return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; }) .add_alias("_mul").add_alias("_Mul") -.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_mul"}); +.set_attr<nnvm::FGradient>("FGradient", + [](const nnvm::NodePtr& n, const std::vector<nnvm::NodeEntry>& ograds) { + auto lhs_grad = MakeNode("elemwise_mul", n->attrs.name + "_backward_lhs", + {ograds[0], n->inputs[1]}, nullptr, &n); + auto rhs_grad = MakeNode("elemwise_mul", n->attrs.name + "_backward_rhs", + {ograds[0], n->inputs[0]}, nullptr, &n); + std::vector<nnvm::NodeEntry> ret; + ret.emplace_back(nnvm::NodeEntry{lhs_grad, 0, 0}); Review comment: Can we simplify as per https://github.com/apache/incubator-mxnet/pull/14095 ? ret.emplace_back(MakeNode(...)); ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services