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/11 07:13:48 UTC

[GitHub] [incubator-mxnet] Yiyan66 opened a new pull request #17812: [numpy] FFI binary bitwise ops

Yiyan66 opened a new pull request #17812: [numpy] FFI binary bitwise ops 
URL: https://github.com/apache/incubator-mxnet/pull/17812
 
 
   ## Description ##
   FFI bitwise_and, bitwise_or, bitwise_xor
   
   ## 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] hzfan commented on a change in pull request #17812: [numpy] FFI binary bitwise ops

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #17812: [numpy] FFI binary bitwise ops 
URL: https://github.com/apache/incubator-mxnet/pull/17812#discussion_r390781243
 
 

 ##########
 File path: python/mxnet/ndarray/numpy/_op.py
 ##########
 @@ -5848,7 +5848,9 @@ def bitwise_and(x1, x2, out=None, **kwargs):
     >>> np.bitwise_and(np.array([True, True], dtype='bool'), np.array([False, True], dtype='bool'))
     array([False,  True])
     """
-    return _ufunc_helper(x1, x2, _npi.bitwise_and, _np.bitwise_and, _npi.bitwise_and_scalar, None, out)
+    if isinstance(x1, numeric_types) and isinstance(x2, numeric_types):
+        _np.bitwise_and(x1, x2, out=out)
 
 Review comment:
   `return _np.bitwise_and(x1, x2, out=out)`. Same for two other ops.

----------------------------------------------------------------
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 #17812: [numpy] FFI binary bitwise ops

Posted by GitBox <gi...@apache.org>.
haojin2 commented on a change in pull request #17812: [numpy] FFI binary bitwise ops 
URL: https://github.com/apache/incubator-mxnet/pull/17812#discussion_r390781322
 
 

 ##########
 File path: src/api/operator/numpy/np_elemwise_broadcast_op.cc
 ##########
 @@ -36,4 +36,29 @@ MXNET_REGISTER_API("_npi.add")
   UFuncHelper(args, ret, op, op_scalar, nullptr);
 });
 
+
 
 Review comment:
   get rid of this blank line.

----------------------------------------------------------------
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 #17812: [numpy] FFI binary bitwise ops

Posted by GitBox <gi...@apache.org>.
haojin2 merged pull request #17812: [numpy] FFI binary bitwise ops 
URL: https://github.com/apache/incubator-mxnet/pull/17812
 
 
   

----------------------------------------------------------------
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 #17812: [numpy] FFI binary bitwise ops

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #17812: [numpy] FFI binary bitwise ops 
URL: https://github.com/apache/incubator-mxnet/pull/17812#discussion_r391414897
 
 

 ##########
 File path: src/api/operator/numpy/np_elemwise_broadcast_op.cc
 ##########
 @@ -36,4 +36,60 @@ MXNET_REGISTER_API("_npi.add")
   UFuncHelper(args, ret, op, op_scalar, nullptr);
 });
 
+MXNET_REGISTER_API("_npi.bitwise_or")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_bitwise_or");
+  const nnvm::Op* op_scalar = Op::Get("_npi_bitwise_or_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.bitwise_xor")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_bitwise_xor");
+  const nnvm::Op* op_scalar = Op::Get("_npi_bitwise_xor_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.bitwise_and")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_bitwise_and");
+  const nnvm::Op* op_scalar = Op::Get("_npi_bitwise_and_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.copysign")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_copysign");
+  const nnvm::Op* op_scalar = Op::Get("_npi_copysign_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
 
 Review comment:
   copysign is not commutative. The last arg should not be `nullptr`.

----------------------------------------------------------------
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 #17812: [numpy] FFI binary bitwise ops

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #17812: [numpy] FFI binary bitwise ops 
URL: https://github.com/apache/incubator-mxnet/pull/17812#discussion_r391415544
 
 

 ##########
 File path: src/api/operator/numpy/np_elemwise_broadcast_op.cc
 ##########
 @@ -36,4 +36,60 @@ MXNET_REGISTER_API("_npi.add")
   UFuncHelper(args, ret, op, op_scalar, nullptr);
 });
 
+MXNET_REGISTER_API("_npi.bitwise_or")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_bitwise_or");
+  const nnvm::Op* op_scalar = Op::Get("_npi_bitwise_or_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.bitwise_xor")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_bitwise_xor");
+  const nnvm::Op* op_scalar = Op::Get("_npi_bitwise_xor_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.bitwise_and")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_bitwise_and");
+  const nnvm::Op* op_scalar = Op::Get("_npi_bitwise_and_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.copysign")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_copysign");
+  const nnvm::Op* op_scalar = Op::Get("_npi_copysign_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.arctan2")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_arctan2");
+  const nnvm::Op* op_scalar = Op::Get("_npi_arctan2_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
 
 Review comment:
   arctan2 is not commutative. The last arg should not be nullptr. An example
   ```
   const nnvm::Op* op_rscalar = Op::Get("_npi_rarctan2_scalar");
   UFuncHelper(args, ret, op, op_scalar, op_rscalar);
   ```

----------------------------------------------------------------
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 #17812: [numpy] FFI binary bitwise ops

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #17812: [numpy] FFI binary bitwise ops 
URL: https://github.com/apache/incubator-mxnet/pull/17812#discussion_r391415985
 
 

 ##########
 File path: src/api/operator/numpy/np_elemwise_broadcast_op.cc
 ##########
 @@ -36,4 +36,60 @@ MXNET_REGISTER_API("_npi.add")
   UFuncHelper(args, ret, op, op_scalar, nullptr);
 });
 
+MXNET_REGISTER_API("_npi.bitwise_or")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_bitwise_or");
+  const nnvm::Op* op_scalar = Op::Get("_npi_bitwise_or_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.bitwise_xor")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_bitwise_xor");
+  const nnvm::Op* op_scalar = Op::Get("_npi_bitwise_xor_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.bitwise_and")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_bitwise_and");
+  const nnvm::Op* op_scalar = Op::Get("_npi_bitwise_and_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.copysign")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_copysign");
+  const nnvm::Op* op_scalar = Op::Get("_npi_copysign_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.arctan2")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_arctan2");
+  const nnvm::Op* op_scalar = Op::Get("_npi_arctan2_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.hypot")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_hypot");
+  const nnvm::Op* op_scalar = Op::Get("_npi_hypot_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
+});
+
+MXNET_REGISTER_API("_npi.ldexp")
+.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) {
+  using namespace runtime;
+  const nnvm::Op* op = Op::Get("_npi_ldexp");
+  const nnvm::Op* op_scalar = Op::Get("_npi_ldexp_scalar");
+  UFuncHelper(args, ret, op, op_scalar, nullptr);
 
 Review comment:
   Same

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