You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/09/11 04:07:54 UTC

[GitHub] reminisce commented on a change in pull request #7577: Sparse operators for unary and binary elemwise NDArray operators.

reminisce commented on a change in pull request #7577: Sparse operators for unary and binary elemwise NDArray operators.
URL: https://github.com/apache/incubator-mxnet/pull/7577#discussion_r137977157
 
 

 ##########
 File path: src/operator/tensor/elemwise_binary_op_extended.cc
 ##########
 @@ -22,76 +22,79 @@
  * \brief CPU Implementation of unary function.
  */
 #include "./elemwise_unary_op.h"
-#include "./elemwise_binary_op.h"
+#include "./elemwise_binary_op-inl.h"
 
 namespace mxnet {
 namespace op {
-MXNET_OPERATOR_REGISTER_BINARY(_power)
+MXNET_OPERATOR_REGISTER_BINARY_WITH_SPARSE_CPU_DR(_power, mshadow_op::power)
 .add_alias("_Power")
-.set_attr<FCompute>("FCompute<cpu>", BinaryCompute<cpu, mshadow_op::power>)
 .set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_power"});
 
 NNVM_REGISTER_OP(_backward_power)
 .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}};
-  })
-.set_attr<FCompute>("FCompute<cpu>", BinaryBackwardUseIn<cpu, mshadow_op::power_grad,
-                                                              mshadow_op::power_rgrad>);
+                                [](const NodeAttrs &attrs) {
+                                  return std::vector<std::pair<int, int> >{{0, 1}};
+                                })
+.set_attr<FInferStorageType>("FInferStorageType", ElemwiseStorageType<3, 2>)
+.set_attr<FCompute>("FCompute<cpu>", ElemwiseBinaryOp::BackwardUseIn<
+  cpu, mshadow_op::power_grad, mshadow_op::power_rgrad>);
 
-MXNET_OPERATOR_REGISTER_BINARY(_maximum)
+MXNET_OPERATOR_REGISTER_BINARY_WITH_SPARSE_CPU(_maximum, mshadow_op::maximum)
+MXNET_ADD_SPARSE_OP_ALIAS(maximum)
 
 Review comment:
   I prefer to document it clearly that `sparse.maximum` does not perform broadcasting instead of renaming it, considering broadcasting and element-wise maximum would eventually be consolidated for sparse maximum.
 
----------------------------------------------------------------
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