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 2018/11/21 04:54:04 UTC

[GitHub] anirudh2290 commented on a change in pull request #12749: [MXNET-1029] Feature request: randint operator

anirudh2290 commented on a change in pull request #12749: [MXNET-1029] Feature request: randint operator
URL: https://github.com/apache/incubator-mxnet/pull/12749#discussion_r235252093
 
 

 ##########
 File path: src/operator/random/sample_op.h
 ##########
 @@ -694,13 +751,47 @@ inline bool SampleOpType(const nnvm::NodeAttrs& attrs,
   }
   bool dtype_ok = (dtype == kFloat16) || (dtype == kFloat32) ||
   (dtype == kFloat64);
-  CHECK_EQ(dtype_ok, true) << "Output type must be float16, float32, or float64: dtype is "
+  CHECK_EQ(dtype_ok, true) << "Output type must be float16, float32, float64: dtype is "
   << dtype_out << " vs " << kFloat16 << " or " << kFloat32 << " or "
   << kFloat64;
   TYPE_ASSIGN_CHECK(*out_type, 0, dtype);
   return true;
 }
 
+template<>
+inline bool SampleOpType<SampleRandIntParam>(const nnvm::NodeAttrs& attrs,
+                         std::vector<int> *in_type,
+                         std::vector<int> *out_type) {
+  const SampleRandIntParam& param = nnvm::get<SampleRandIntParam>(attrs.parsed);
+  CHECK_EQ(in_type->size(), 0);
+  CHECK_EQ(out_type->size(), 1);
+  int dtype = -1;
+  int dtype_out = (*out_type)[0];
+  if (dtype_out != -1) {
+    // Output type can be inferred, use it and make sure it matches
+    dtype = dtype_out;
+    if (param.dtype != -1) {
+      // dtype given in args, check that it matches the output type
+      CHECK_EQ(dtype_out, param.dtype) << "Output type does not match requested type: "
+      << dtype_out << " vs " << param.dtype;
+    }
+  } else {
+    // Output type can't be inferred
+    if (param.dtype != -1) {
+      // Use dtype given in args
+      dtype = param.dtype;
+    } else {
+      // Use default
+      dtype = kFloat32;
+    }
+  }
+  bool dtype_ok = (dtype == kInt32) || (dtype == kInt64);
+  CHECK_EQ(dtype_ok, true) << "Output type must be int32, int64: dtype is "
 
 Review comment:
   CHECK(dtype_ok)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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