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/03/19 05:25:12 UTC

[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17866: [Numpy] Add ffi for np.sum, np.var and np.std

haojin2 commented on a change in pull request #17866: [Numpy] Add ffi for np.sum, np.var and np.std
URL: https://github.com/apache/incubator-mxnet/pull/17866#discussion_r394797364
 
 

 ##########
 File path: src/api/operator/numpy/np_broadcast_reduce_op_value.cc
 ##########
 @@ -50,4 +51,63 @@ MXNET_REGISTER_API("_npi.broadcast_to")
   *ret = ndoutputs[0];
 });
 
+MXNET_REGISTER_API("_npi.sum")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_sum");
+  op::NumpyReduceAxesParam param;
+  nnvm::NodeAttrs attrs;
+  attrs.op = op;
+
+  // parse axis
+  if (args[1].type_code() == kNull) {
+    param.axis = dmlc::nullopt;
+  } else {
+    if (args[1].type_code() == kDLInt) {
+      param.axis = Tuple<int>(1, args[1].operator int64_t());
+    } else {
+      param.axis = Tuple<int>(args[1].operator ObjectRef());
+    }
+  }
+
+  // parse dtype
+  if (args[2].type_code() == kNull) {
+    param.dtype = dmlc::nullopt;
+  } else {
+    param.dtype = String2MXNetTypeWithBool(args[2].operator std::string());
+  }
+
+  // parse keepdims
+  if (args[3].type_code() == kNull) {
 
 Review comment:
   By default the value in Python wrapper is `<No Value>` so I'm keeping it as `None` here.
   The behavior for `None` is equal to `False`.

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


With regards,
Apache Git Services