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/07/01 06:08:04 UTC

[GitHub] [incubator-mxnet] hzfan commented on a change in pull request #18614: [numpy] FFI flip, rollaxis, stack

hzfan commented on a change in pull request #18614:
URL: https://github.com/apache/incubator-mxnet/pull/18614#discussion_r448133071



##########
File path: src/api/operator/numpy/np_matrix_op.cc
##########
@@ -74,6 +74,68 @@ MXNET_REGISTER_API("_npi.expand_dims")
   *ret = ndoutputs[0];
 });
 
+MXNET_REGISTER_API("_npi.stack")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_stack");
+  nnvm::NodeAttrs attrs;
+  op::StackParam param;
+
+  int i = 0;
+  int num_inputs = 0;
+  std::vector<NDArray*> inputs;
+  while (args[i].type_code() != kDLInt) {
+    inputs.push_back(args[i].operator mxnet::NDArray*());
+    i++;
+    num_inputs++;
+  }
+
+  param.num_args = i;
+  param.axis = args[i].operator int64_t();
+  attrs.parsed = std::move(param);
+  attrs.op = op;
+  SetAttrDict<op::StackParam>(&attrs);
+  NDArray* out = args[i+1].operator mxnet::NDArray*();
+  NDArray** outputs = out == nullptr ? nullptr : &out;
+  int num_outputs = out != nullptr;
+  auto ndoutputs = Invoke(op, &attrs, num_inputs, &inputs[0], &num_outputs, outputs);

Review comment:
       Do we support stack an empty list of ndarray? like `stack([], axis=0)`




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