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 2020/05/06 09:13:31 UTC
[GitHub] [incubator-mxnet] hgt312 commented on a change in pull request #18250: fix mixed type backward
hgt312 commented on a change in pull request #18250:
URL: https://github.com/apache/incubator-mxnet/pull/18250#discussion_r420643035
##########
File path: src/operator/mshadow_op.h
##########
@@ -746,6 +746,10 @@ MXNET_BINARY_MATH_OP_NC(minus_sign, a - b > DType(0) ? DType(1) : -DType(1));
MXNET_BINARY_MATH_OP(rminus, b - a);
+MXNET_BINARY_MATH_OP_NC(self_grad, 1);
+
+MXNET_BINARY_MATH_OP_NC(minus_rgrad, -1);
+
Review comment:
Could use better func name? Like `posone`, `negone`?
##########
File path: src/operator/numpy/np_elemwise_broadcast_op.cc
##########
@@ -115,7 +115,22 @@ MXNET_OPERATOR_REGISTER_NP_BINARY_MIXED_PRECISION(_npi_add)
"FCompute<cpu>",
NumpyBinaryBroadcastComputeWithBool<cpu, op::mshadow_op::plus>)
#endif
-.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseNone{"_backward_broadcast_add"});
+.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_npi_broadcast_add"});
+
+NNVM_REGISTER_OP(_backward_npi_broadcast_add)
+.set_num_inputs(3)
+.set_num_outputs(2)
+.set_attr<nnvm::TIsBackward>("TIsBackward", true)
+.set_attr<nnvm::FInplaceOption>("FInplaceOption",
+ [](const NodeAttrs& attrs){
+ return std::vector<std::pair<int, int> >{{0, 1}};
Review comment:
```suggestion
return std::vector<std::pair<int, int> >{{0, 0}, {0, 1}};
```
----------------------------------------------------------------
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:
users@infra.apache.org