hzfan 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_r394195540
##########
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:
Do we need to support `keepdims=None`? Seems that onp does not support it.
Same for 2 other operators.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services