hzfan commented on a change in pull request #17831: [numpy] add new ffi for 
column_stack and hstack
URL: https://github.com/apache/incubator-mxnet/pull/17831#discussion_r393402743
 
 

 ##########
 File path: src/api/operator/numpy/np_matrix_op.cc
 ##########
 @@ -46,4 +47,46 @@ MXNET_REGISTER_API("_npi.expand_dims")
   *ret = ndoutputs[0];
 });
 
+MXNET_REGISTER_API("_npi.column_stack")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_column_stack");
+  nnvm::NodeAttrs attrs;
+  op::NumpyColumnStackParam param;
+  param.num_args = args.size();
+
+  attrs.parsed = param;
+  attrs.op = op;
+  SetAttrDict<op::NumpyColumnStackParam>(&attrs);
+  int num_outputs = 0;
+  NDArray** inputs = new NDArray*[param.num_args];
+  for (int i = 0; i < param.num_args; ++i) {
+    inputs[i] = args[i].operator mxnet::NDArray*();
+  }
+  auto ndoutputs = Invoke(op, &attrs, param.num_args, inputs, &num_outputs, 
nullptr);
+  *ret = ndoutputs[0];
+  delete[] inputs;
+});
+
+MXNET_REGISTER_API("_npi.hstack")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_hstack");
+  nnvm::NodeAttrs attrs;
+  op::ConcatParam param;
+  param.num_args = args.size();
+
+  attrs.parsed = param;
+  attrs.op = op;
+  SetAttrDict<op::ConcatParam>(&attrs);
+  int num_outputs = 0;
+  NDArray** inputs = new NDArray*[param.num_args];
 
 Review comment:
   Same here.

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

Reply via email to