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 2019/09/02 11:59:25 UTC

[GitHub] [incubator-mxnet] haojin2 commented on a change in pull request #15901: [Numpy] operator hypot

haojin2 commented on a change in pull request #15901: [Numpy] operator hypot
URL: https://github.com/apache/incubator-mxnet/pull/15901#discussion_r319927973
 
 

 ##########
 File path: src/operator/numpy/np_elemwise_broadcast_op.cc
 ##########
 @@ -182,5 +182,59 @@ MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR(_npi_rpower_scalar)
 .set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Compute<cpu, mshadow_op::rpower>)
 .set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseOut{"_backward_rpower_scalar"});
 
+inline bool HypotOpType(const nnvm::NodeAttrs& attrs,
+                        std::vector<int>* in_attrs,
+                        std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 2U);
+  CHECK_EQ(out_attrs->size(), 1U);
+
+  TYPE_ASSIGN_CHECK(*out_attrs, 0, in_attrs->at(0));
+  TYPE_ASSIGN_CHECK(*out_attrs, 0, in_attrs->at(1));
+  TYPE_ASSIGN_CHECK(*in_attrs, 0, out_attrs->at(0));
+  TYPE_ASSIGN_CHECK(*in_attrs, 1, out_attrs->at(0));
+  // check if it is float16, float32 or float64. If not, raise error.
+  if (in_attrs->at(0) > mshadow::kFloat16) {
+    // do not support int now.
+    std::ostringstream os;
+    os << "Do not support `int` as input.\n";
+    throw ::mxnet::op::InferTypeError(os.str(), 0);
+  }
+  return out_attrs->at(0) != -1;
+}
 
 Review comment:
   Use such check:
   ```c++
   inline bool IsIntType(const int dtype) {
     return (dtype == mshadow::kUint8 ||
             dtype == mshadow::kInt32 ||
             dtype == mshadow::kInt8 ||
             dtype == mshadow::kInt64);
   }
   ```

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