altanh commented on a change in pull request #8041:
URL: https://github.com/apache/tvm/pull/8041#discussion_r633781691



##########
File path: src/relay/op/random/kernel.cc
##########
@@ -85,5 +85,47 @@ RELAY_REGISTER_OP("random.threefry_split")
     .add_argument("key", "Tensor", "Input Threefry key")
     .add_type_rel("ThreefrySplit", ThreefrySplitRel);
 
+TVM_REGISTER_NODE_TYPE(UniformAttrs);
+
+bool UniformRel(const Array<Type>& types, int num_inputs, const Attrs& attrs,
+                const TypeReporter& reporter) {
+  const UniformAttrs* param = attrs.as<UniformAttrs>();
+  ICHECK_EQ(types.size(), 4) << "Uniform should have three input and one 
output";
+
+  std::vector<IndexExpr> oshape;
+  for (auto& x : param->out_shape) {
+    oshape.push_back(x);
+  }
+  DataType out_dtype = param->out_dtype;
+  // we are supporting float32 and float64 at the moment.
+  ICHECK(out_dtype.is_float() && (out_dtype.bits() == 32 || out_dtype.bits() 
== 64));

Review comment:
       Could you use the Diagnostics API for erroring out this check?
   
   See for example: 
https://github.com/apache/tvm/blob/main/src/relay/op/nn/nn.cc#L65

##########
File path: python/tvm/relay/op/strategy/generic.py
##########
@@ -1495,6 +1495,28 @@ def threefry_split_strategy(attrs, inputs, out_type, 
target):
     return strategy
 
 
+# uniform
+def wrap_compute_uniform(topi_compute):
+    """Wrap uniform topi compute"""
+
+    def _compute_uniform(attrs, inputs, _):
+        return list(topi_compute(inputs[0], inputs[1], inputs[2], 
attrs.out_shape, attrs.out_dtype))
+
+    return _compute_uniform
+
+
+@override_native_generic_func("uniform_strategy")
+def uniform_strategy(attrs, inputs, out_type, target):
+    """uniform generic strategy"""
+    strategy = _op.OpStrategy()
+    strategy.add_implementation(
+        wrap_compute_uniform(topi.random.uniform),
+        wrap_topi_schedule(topi.generic.schedule_extern),

Review comment:
       do we need to specialize some schedules for this op? could be a follow 
up PR just wondering how the perf works with just generic schedule




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


Reply via email to