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/04 11:34:43 UTC

[GitHub] [incubator-mxnet] JiangZhaoh opened a new pull request #17759: [numpy] FFI insert \ delete

JiangZhaoh opened a new pull request #17759: [numpy] FFI insert \ delete
URL: https://github.com/apache/incubator-mxnet/pull/17759
 
 
   ## Description ##
   (Brief description on what this PR is about)
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [ ] The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant [JIRA issue](https://issues.apache.org/jira/projects/MXNET/issues) created (except PRs with tiny changes)
   - [ ] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage:
   - Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
   - Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
   - Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
   - [ ] Code is well-documented: 
   - For user-facing API changes, API doc string has been updated. 
   - For new C++ functions in header files, their functionalities and arguments are documented. 
   - For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
   - Check the API doc at https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
   - [ ] To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [ ] Feature1, tests, (and when applicable, API doc)
   - [ ] Feature2, tests, (and when applicable, API doc)
   
   ## Comments ##
   - If this change is a backward incompatible change, why must this change be made.
   - Interesting edge cases to note 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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-611268003
 
 
   @mxnet-bot run ci [unix-gpu]

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

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603813920
 
 
   Jenkins CI successfully triggered : [windows-gpu]

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

[GitHub] [incubator-mxnet] reminisce commented on a change in pull request #17759: [numpy] FFI for insert \ delete

Posted by GitBox <gi...@apache.org>.
reminisce commented on a change in pull request #17759: [numpy] FFI for insert \ delete
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r388081422
 
 

 ##########
 File path: src/api/operator/numpy/np_insert_op.cc
 ##########
 @@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file np_insert_op.cc
+ * \brief Implementation of the API of functions in the following file:
+          src/operator/numpy/np_insert_op_scalar.cc
+          src/operator/numpy/np_insert_op_slice.cc
+          src/operator/numpy/np_insert_op_tensor.cc
+ */
+#include "../utils.h"
+#include "../../../operator/numpy/np_insert_op-inl.h"
+
+namespace mxnet {
+
+MXNET_REGISTER_API("_npi.insert_scalar")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_insert_scalar");
+  nnvm::NodeAttrs attrs;
+  op::NumpyInsertParam param;
+  NDArray** inputs = NULL;
 
 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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-610775800
 
 
   @mxnet-bot run ci [unix-gpu]

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

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-611805867
 
 
   Jenkins CI successfully triggered : [unix-gpu]

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

[GitHub] [incubator-mxnet] haojin2 merged pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
haojin2 merged pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759
 
 
   

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

[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
haojin2 commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r391937750
 
 

 ##########
 File path: src/operator/tensor/init_op.h
 ##########
 @@ -215,6 +215,21 @@ struct RangeParam : public dmlc::Parameter<RangeParam> {
     MXNET_ADD_ALL_TYPES
     .describe("Target data type.");
   }
+  void SetAttrDict(std::unordered_map<std::string, std::string>* dict) {
+    std::ostringstream start_s, stop_s, step_s, repeat_s, infer_range_s, dtype_s;
+    start_s << start;
+    stop_s << stop;
+    step_s << step;
+    repeat_s << repeat;
+    infer_range_s << infer_range;
+    dtype_s << dtype;
+    (*dict)["start"] = start_s.str();
+    (*dict)["stop"] = stop_s.str();
+    (*dict)["step"] = step_s.str();
+    (*dict)["repeat"] = repeat_s.str();
+    (*dict)["infer_range"] = infer_range_s.str();
+    (*dict)["dtype"] = dtype_s.str();
 
 Review comment:
   @hzfan shall we use `String2MXNetType` function 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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] JiangZhaoh removed a comment on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh removed a comment on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603172518
 
 
   @mxnet-bot run ci [ci/jenkins/mxnet-validation/windows-gpu]

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

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-611268025
 
 
   Jenkins CI successfully triggered : [unix-gpu]

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

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-610931956
 
 
   Jenkins CI successfully triggered : [unix-gpu]

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

[GitHub] [incubator-mxnet] reminisce commented on a change in pull request #17759: [numpy] FFI for insert \ delete

Posted by GitBox <gi...@apache.org>.
reminisce commented on a change in pull request #17759: [numpy] FFI for insert \ delete
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r388081467
 
 

 ##########
 File path: src/api/operator/numpy/np_insert_op.cc
 ##########
 @@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file np_insert_op.cc
+ * \brief Implementation of the API of functions in the following file:
+          src/operator/numpy/np_insert_op_scalar.cc
+          src/operator/numpy/np_insert_op_slice.cc
+          src/operator/numpy/np_insert_op_tensor.cc
+ */
+#include "../utils.h"
+#include "../../../operator/numpy/np_insert_op-inl.h"
+
+namespace mxnet {
+
+MXNET_REGISTER_API("_npi.insert_scalar")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_insert_scalar");
+  nnvm::NodeAttrs attrs;
+  op::NumpyInsertParam param;
+  NDArray** inputs = NULL;
+  int num_inputs;
+  param.start = dmlc::nullopt;
+  param.step = dmlc::nullopt;
+  param.stop = dmlc::nullopt;
+  if (args[1].type_code() == kDLInt ||
+      args[1].type_code() == kDLUInt ||
+      args[1].type_code() == kDLFloat) {
+    param.val = args[1].operator double();
+    inputs = new NDArray*[1]{args[0].operator mxnet::NDArray*()};
+    num_inputs = 1;
+  } else {
+    param.val = dmlc::nullopt;
+    inputs = new NDArray*[2]{args[0].operator mxnet::NDArray*(),
+                             args[1].operator mxnet::NDArray*()};
+    num_inputs = 2;
+  }
+  param.int_ind = args[2].operator int();
+  if (args[3].type_code() == kNull) {
+    param.axis = dmlc::nullopt;
+  } else {
+    param.axis = args[3].operator int();
+  }
+  attrs.parsed = std::move(param);
+  attrs.op = op;
+  int num_outputs = 0;
+  auto ndoutputs = Invoke<op::NumpyInsertParam>(op, &attrs, num_inputs, inputs, &num_outputs, nullptr);
+  *ret = ndoutputs[0];
+});
+
+MXNET_REGISTER_API("_npi.insert_slice")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_insert_slice");
+  nnvm::NodeAttrs attrs;
+  op::NumpyInsertParam param;
+  NDArray** inputs = NULL;
 
 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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-610775824
 
 
   Jenkins CI successfully triggered : [unix-gpu]

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

[GitHub] [incubator-mxnet] hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r392084890
 
 

 ##########
 File path: src/api/operator/numpy/np_window_op.cc
 ##########
 @@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file np_window_op.cc
+ * \brief Implementation of the API of functions in src/operator/numpy/np_window_op.cc
+ */
+#include <mxnet/api_registry.h>
+#include <mxnet/runtime/packed_func.h>
+#include "../utils.h"
+#include "../../../operator/numpy/np_window_op.h"
+
+namespace mxnet {
+
+inline static void SetNumpyWindowsParam(runtime::MXNetArgs args,
+                                 runtime::MXNetRetValue* ret,
 
 Review comment:
   Please align

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

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-610741146
 
 
   Jenkins CI successfully triggered : [centos-cpu]

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

[GitHub] [incubator-mxnet] hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r392084711
 
 

 ##########
 File path: src/operator/numpy/np_init_op.h
 ##########
 @@ -62,6 +62,17 @@ struct NumpyEyeParam : public dmlc::Parameter<NumpyEyeParam> {
     MXNET_ADD_ALL_TYPES
     .describe("Data-type of the returned array.");
   }
+  void SetAttrDict(std::unordered_map<std::string, std::string>* dict) {
+    std::ostringstream N_s, M_s, k_s, dtype_s;
+    N_s << N;
+    M_s << M;
+    k_s << k;
+    dtype_s << dtype;
+    (*dict)["N"] = N_s.str();
+    (*dict)["M"] = M_s.str();
+    (*dict)["k"] = k_s.str();
+    (*dict)["dtype"] = dtype_s.str();
 
 Review comment:
   Please use `String2MXNetTypeWithBool` in `op_utils.h`

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

[GitHub] [incubator-mxnet] JiangZhaoh edited a comment on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh edited a comment on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-610741017
 
 
   @mxnet-bot run ci [centos-cpu]

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

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-610931918
 
 
   @mxnet-bot run ci [unix-gpu]

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

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603813872
 
 
   @mxnet-bot run ci [windows-gpu]

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

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603172700
 
 
   Undefined action detected. 
   Permissible actions are : run ci [all], run ci [job1, job2] 
   Example : @mxnet-bot run ci [all] 
   Example : @mxnet-bot run ci [centos-cpu, clang]

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

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603571019
 
 
   Jenkins CI successfully triggered : [windows-gpu]

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

[GitHub] [incubator-mxnet] JiangZhaoh removed a comment on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh removed a comment on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603172684
 
 
   @mxnet-bot ci/jenkins/mxnet-validation/windows-gpu

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

[GitHub] [incubator-mxnet] hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r392084155
 
 

 ##########
 File path: src/operator/numpy/np_window_op.h
 ##########
 @@ -58,6 +58,13 @@ struct NumpyWindowsParam : public dmlc::Parameter<NumpyWindowsParam> {
     MXNET_ADD_ALL_TYPES
     .describe("Data-type of the returned array.");
   }
+  void SetAttrDict(std::unordered_map<std::string, std::string>* dict) {
+    std::ostringstream M_s, dtype_s;
+    M_s << M;
+    dtype_s << dtype;
 
 Review comment:
   Please use `String2MXNetTypeWithBool`  in `op_utils.h` here.
   ```
   (*dict)["dtype"] = String2MXNetTypeWithBool(dtype);
   ```

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

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603173253
 
 
   @mxnet-bot run ci [windows-gpu]

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

[GitHub] [incubator-mxnet] reminisce commented on a change in pull request #17759: [numpy] FFI for insert \ delete

Posted by GitBox <gi...@apache.org>.
reminisce commented on a change in pull request #17759: [numpy] FFI for insert \ delete
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r388080376
 
 

 ##########
 File path: src/api/operator/numpy/np_delete_op.cc
 ##########
 @@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file np_delete_op.cc
+ * \brief Implementation of the API of functions in src/operator/numpy/np_delete_op.cc
+ */
+#include "../utils.h"
+#include "../../../operator/numpy/np_delete_op-inl.h"
+
+namespace mxnet {
+
+MXNET_REGISTER_API("_npi.delete")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_delete");
 
 Review comment:
   Add `static`.

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

[GitHub] [incubator-mxnet] hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r392044570
 
 

 ##########
 File path: src/operator/tensor/init_op.h
 ##########
 @@ -215,6 +215,21 @@ struct RangeParam : public dmlc::Parameter<RangeParam> {
     MXNET_ADD_ALL_TYPES
     .describe("Target data type.");
   }
+  void SetAttrDict(std::unordered_map<std::string, std::string>* dict) {
+    std::ostringstream start_s, stop_s, step_s, repeat_s, infer_range_s, dtype_s;
+    start_s << start;
+    stop_s << stop;
+    step_s << step;
+    repeat_s << repeat;
+    infer_range_s << infer_range;
+    dtype_s << dtype;
+    (*dict)["start"] = start_s.str();
+    (*dict)["stop"] = stop_s.str();
+    (*dict)["step"] = step_s.str();
+    (*dict)["repeat"] = repeat_s.str();
+    (*dict)["infer_range"] = infer_range_s.str();
+    (*dict)["dtype"] = dtype_s.str();
 
 Review comment:
   Yes. Please use `String2MXNetTypeWithBool` in `op_utils.h`

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

[GitHub] [incubator-mxnet] hzfan commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
hzfan commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-605764185
 
 
   LGTM

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

[GitHub] [incubator-mxnet] hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r394795769
 
 

 ##########
 File path: src/api/operator/numpy/np_matmul_op.cc
 ##########
 @@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file np_matmul_op.cc
+ * \brief Implementation of the API of functions in src/operator/numpy/np_matmul_op.cc
+ */
+#include <mxnet/api_registry.h>
+#include <mxnet/runtime/packed_func.h>
+#include "../utils.h"
+#include "../../../operator/numpy/np_matmul_op-inl.h"
+
+namespace mxnet {
+
+MXNET_REGISTER_API("_npi.matmul")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  static const nnvm::Op* op = Op::Get("_npi_matmul");
+  nnvm::NodeAttrs attrs;
+  int num_inputs = 2;
+  NDArray* inputs[2] = {args[0].operator mxnet::NDArray*(),
+                        args[1].operator mxnet::NDArray*()};
+  attrs.op = op;
+  NDArray* out = args[2].operator mxnet::NDArray*();
+  NDArray** outputs = out == nullptr ? nullptr : &out;
+  int num_outputs = out != nullptr;
+  auto ndoutputs = Invoke(op, &attrs, num_inputs, inputs, &num_outputs, outputs);
+  *ret = ndoutputs[0];
 
 Review comment:
   Use `PythonArg` for `out`

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

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-611238467
 
 
   @mxnet-bot run ci [unix-gpu]

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

[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
haojin2 commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r391936815
 
 

 ##########
 File path: src/operator/tensor/init_op.h
 ##########
 @@ -215,6 +215,21 @@ struct RangeParam : public dmlc::Parameter<RangeParam> {
     MXNET_ADD_ALL_TYPES
     .describe("Target data type.");
   }
+  void SetAttrDict(std::unordered_map<std::string, std::string>* dict) {
 
 Review comment:
   one more blank line above.

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

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-610741017
 
 
   run ci [centos-cpu]

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

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-611805834
 
 
   @mxnet-bot run ci [unix-gpu]

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

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-611238497
 
 
   Jenkins CI successfully triggered : [unix-gpu]

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

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603172684
 
 
   @mxnet-bot ci/jenkins/mxnet-validation/windows-gpu

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

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603172518
 
 
   @mxnet-bot run ci [ci/jenkins/mxnet-validation/windows-gpu]

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

[GitHub] [incubator-mxnet] JiangZhaoh removed a comment on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh removed a comment on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603085065
 
 
   @mxnet-bot run ci [windows-gpu]

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

[GitHub] [incubator-mxnet] JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
JiangZhaoh commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603085065
 
 
   @mxnet-bot run ci [windows-gpu]

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

[GitHub] [incubator-mxnet] reminisce commented on a change in pull request #17759: [numpy] FFI for insert \ delete

Posted by GitBox <gi...@apache.org>.
reminisce commented on a change in pull request #17759: [numpy] FFI for insert \ delete
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r388081509
 
 

 ##########
 File path: src/api/operator/numpy/np_insert_op.cc
 ##########
 @@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file np_insert_op.cc
+ * \brief Implementation of the API of functions in the following file:
+          src/operator/numpy/np_insert_op_scalar.cc
+          src/operator/numpy/np_insert_op_slice.cc
+          src/operator/numpy/np_insert_op_tensor.cc
+ */
+#include "../utils.h"
+#include "../../../operator/numpy/np_insert_op-inl.h"
+
+namespace mxnet {
+
+MXNET_REGISTER_API("_npi.insert_scalar")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_insert_scalar");
+  nnvm::NodeAttrs attrs;
+  op::NumpyInsertParam param;
+  NDArray** inputs = NULL;
+  int num_inputs;
+  param.start = dmlc::nullopt;
+  param.step = dmlc::nullopt;
+  param.stop = dmlc::nullopt;
+  if (args[1].type_code() == kDLInt ||
+      args[1].type_code() == kDLUInt ||
+      args[1].type_code() == kDLFloat) {
+    param.val = args[1].operator double();
+    inputs = new NDArray*[1]{args[0].operator mxnet::NDArray*()};
+    num_inputs = 1;
+  } else {
+    param.val = dmlc::nullopt;
+    inputs = new NDArray*[2]{args[0].operator mxnet::NDArray*(),
+                             args[1].operator mxnet::NDArray*()};
+    num_inputs = 2;
+  }
+  param.int_ind = args[2].operator int();
+  if (args[3].type_code() == kNull) {
+    param.axis = dmlc::nullopt;
+  } else {
+    param.axis = args[3].operator int();
+  }
+  attrs.parsed = std::move(param);
+  attrs.op = op;
+  int num_outputs = 0;
+  auto ndoutputs = Invoke<op::NumpyInsertParam>(op, &attrs, num_inputs, inputs, &num_outputs, nullptr);
+  *ret = ndoutputs[0];
+});
+
+MXNET_REGISTER_API("_npi.insert_slice")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_insert_slice");
+  nnvm::NodeAttrs attrs;
+  op::NumpyInsertParam param;
+  NDArray** inputs = NULL;
+  int num_inputs;
+  if (args[1].type_code() == kDLInt ||
+      args[1].type_code() == kDLUInt ||
+      args[1].type_code() == kDLFloat) {
+    param.val = args[1].operator double();
+    inputs = new NDArray*[1]{args[0].operator mxnet::NDArray*()};
+    num_inputs = 1;
+  } else {
+    param.val = dmlc::nullopt;
+    inputs = new NDArray*[2]{args[0].operator mxnet::NDArray*(),
+                             args[1].operator mxnet::NDArray*()};
+    num_inputs = 2;
+  }
+  if (args[2].type_code() == kNull) {
+    param.start = dmlc::nullopt;
+  } else {
+    param.start = args[2].operator int();
+  }
+  if (args[3].type_code() == kNull) {
+    param.stop = dmlc::nullopt;
+  } else {
+    param.stop = args[3].operator int();
+  }
+  if (args[4].type_code() == kNull) {
+    param.step = dmlc::nullopt;
+  } else {
+    param.step = args[4].operator int();
+  }
+  if (args[5].type_code() == kNull) {
+    param.axis = dmlc::nullopt;
+  } else {
+    param.axis = args[5].operator int();
+  }
+  attrs.parsed = std::move(param);
+  attrs.op = op;
+  int num_outputs = 0;
+  auto ndoutputs = Invoke<op::NumpyInsertParam>(op, &attrs, num_inputs, inputs, &num_outputs, nullptr);
+  *ret = ndoutputs[0];
+});
+
+MXNET_REGISTER_API("_npi.insert_tensor")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_insert_tensor");
+  nnvm::NodeAttrs attrs;
+  op::NumpyInsertParam param;
+  param.start = dmlc::nullopt;
+  param.step = dmlc::nullopt;
+  param.stop = dmlc::nullopt;
+  NDArray** inputs = NULL;
 
 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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603172530
 
 
   None of the jobs entered are supported. 
   Jobs entered by user: [ci/jenkins/mxnet-validation/windows-gpu]
   CI supported Jobs: [centos-gpu, edge, windows-cpu, windows-gpu, centos-cpu, website, sanity, unix-cpu, unix-gpu, miscellaneous, clang]
   

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

[GitHub] [incubator-mxnet] reminisce commented on a change in pull request #17759: [numpy] FFI for insert \ delete

Posted by GitBox <gi...@apache.org>.
reminisce commented on a change in pull request #17759: [numpy] FFI for insert \ delete
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r388081334
 
 

 ##########
 File path: src/api/operator/numpy/np_delete_op.cc
 ##########
 @@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file np_delete_op.cc
+ * \brief Implementation of the API of functions in src/operator/numpy/np_delete_op.cc
+ */
+#include "../utils.h"
+#include "../../../operator/numpy/np_delete_op-inl.h"
+
+namespace mxnet {
+
+MXNET_REGISTER_API("_npi.delete")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_delete");
+  nnvm::NodeAttrs attrs;
+  op::NumpyDeleteParam param;
+  NDArray** inputs = NULL;
+  int num_inputs;
+  param.start = dmlc::nullopt;
+  param.step = dmlc::nullopt;
+  param.stop = dmlc::nullopt;
+  param.int_ind = dmlc::nullopt;
+  param.axis = dmlc::nullopt;
+  if (args.num_args == 3) {
+    if (args[1].type_code() == kDLInt ||
+        args[1].type_code() == kDLUInt ||
+        args[1].type_code() == kDLFloat) {
+      inputs = new NDArray*[1]{args[0].operator mxnet::NDArray*()};
+      if (args[1].type_code() == kNull) {
+        param.int_ind = dmlc::nullopt;
+      } else {
+        param.int_ind = args[1].operator int();
+      }
+      if (args[2].type_code() == kNull) {
+        param.axis = dmlc::nullopt;
+      } else {
+        param.axis = args[2].operator int();
+      }
+      num_inputs = 1;
+    } else {
+      inputs = new NDArray*[2]{args[0].operator mxnet::NDArray*(),
+                               args[1].operator mxnet::NDArray*()};
+      if (args[2].type_code() == kNull) {
+        param.axis = dmlc::nullopt;
+      } else {
+        param.axis = args[2].operator int();
+      }
+      num_inputs = 2;
+    }
+  } else {
+    inputs = new NDArray*[1]{args[0].operator mxnet::NDArray*()};
 
 Review comment:
   You can use `vector<NDArray*>` for `inputs` and pass `inputs.data()` to the funciton `Invoke`. Using `new` is dangerous if manual `delete` is missing.

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

[GitHub] [incubator-mxnet] haojin2 commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
haojin2 commented on issue #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#issuecomment-603570981
 
 
   @mxnet-bot run ci [windows-gpu]

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

[GitHub] [incubator-mxnet] hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #17759: [numpy] FFI for insert \ delete \ matmul etc.
URL: https://github.com/apache/incubator-mxnet/pull/17759#discussion_r392093261
 
 

 ##########
 File path: src/api/operator/numpy/np_matmul_op.cc
 ##########
 @@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file np_matmul_op.cc
+ * \brief Implementation of the API of functions in src/operator/numpy/np_matmul_op.cc
+ */
+#include <mxnet/api_registry.h>
+#include <mxnet/runtime/packed_func.h>
+#include "../utils.h"
+#include "../../../operator/numpy/np_matmul_op-inl.h"
+
+namespace mxnet {
+
+MXNET_REGISTER_API("_npi.matmul")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  static const nnvm::Op* op = Op::Get("_npi_matmul");
+  nnvm::NodeAttrs attrs;
+  int num_inputs = 2;
+  NDArray* inputs[2] = {args[0].operator mxnet::NDArray*(),
+                        args[1].operator mxnet::NDArray*()};
+  attrs.op = op;
+  NDArray* out = args[2].operator mxnet::NDArray*();
+  NDArray** outputs = out == nullptr ? nullptr : &out;
+  int num_outputs = out != nullptr;
+  auto ndoutputs = Invoke(op, &attrs, num_inputs, inputs, &num_outputs, outputs);
+  *ret = ndoutputs[0];
 
 Review comment:
   Please use `PythonArg` for `out`

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