haojin2 commented on a change in pull request #17254: [numpy] change unary 
infer type
URL: https://github.com/apache/incubator-mxnet/pull/17254#discussion_r365556866
 
 

 ##########
 File path: src/operator/numpy/np_elemwise_unary_op_basic.cc
 ##########
 @@ -82,6 +82,39 @@ NNVM_REGISTER_OP(_np_copy)
   .set_attr<FCompute>("FCompute<cpu>", UnaryOp::Compute<cpu, __kernel$>)       
           \
   .add_argument(__input_name$, "NDArray-or-Symbol", "The input array.")
 
+inline bool UnaryOpType(const nnvm::NodeAttrs& attrs,
+                              std::vector<int>* in_attrs,
+                              std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 1U);
+  CHECK_EQ(out_attrs->size(), 1U);
+  int a_type = in_attrs->at(0);
+  if (mxnet::common::is_float(a_type)) {
+    TYPE_ASSIGN_CHECK(*out_attrs, 0, in_attrs->at(0));
+  } else if (a_type == mshadow::kInt32 || a_type == mshadow::kInt64) {
+    TYPE_ASSIGN_CHECK(*out_attrs, 0, mshadow::kFloat64);
 
 Review comment:
   use `kFloat32` as default for now.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to