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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to