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/02 05:23:14 UTC

[GitHub] [incubator-mxnet] yzhliu commented on a change in pull request #18642: [numpy] Fix less/greater bug with scalar input

yzhliu commented on a change in pull request #18642:
URL: https://github.com/apache/incubator-mxnet/pull/18642#discussion_r448755291



##########
File path: src/api/operator/numpy/np_elemwise_broadcast_logic_op.cc
##########
@@ -44,31 +44,65 @@ MXNET_REGISTER_API("_npi.not_equal")
   UFuncHelper(args, ret, op, op_scalar, nullptr);
 });
 
+void set_UFuncHelper(runtime::MXNetArgs args, runtime::MXNetRetValue* ret,
+                     const nnvm::Op* op, const nnvm::Op* op_scalar,
+                     const nnvm::Op* op_rscalar) {
+  int result = 0;
+  if (args[1].type_code() == kNDArrayHandle) {
+    result++;
+    result <<= 1;
+  }
+  if (args[0].type_code() == kNDArrayHandle) {
+    result++;
+  }
+
+  switch (result) {

Review comment:
       this is a clever trick, yet I suggest to explicitly use `if (..&&..) ... else if (.. && ..) ... else` to make it more clear and readable.

##########
File path: src/api/operator/numpy/np_elemwise_broadcast_logic_op.cc
##########
@@ -44,31 +44,65 @@ MXNET_REGISTER_API("_npi.not_equal")
   UFuncHelper(args, ret, op, op_scalar, nullptr);
 });
 
+void set_UFuncHelper(runtime::MXNetArgs args, runtime::MXNetRetValue* ret,

Review comment:
       ```suggestion
   void SetUFuncHelper(runtime::MXNetArgs args, runtime::MXNetRetValue* ret,
   ```




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