tkonolige commented on code in PR #12284:
URL: https://github.com/apache/tvm/pull/12284#discussion_r936845448


##########
tests/python/topi/python/test_topi_prng.py:
##########
@@ -157,8 +185,27 @@ def test_uniform(target, dev):
         assert np.max(rands) <= 10.0
 
 
+@tvm.testing.parametrize_targets
+def test_multinomial(target, dev):
+    def _verify_multinomial(size, num_samples):

Review Comment:
   Could you do some rough checking of expected value and variance of the 
distribution. It's always hard to tell if these random things are implemented 
correctly, but I think this would help.



##########
python/tvm/relay/frontend/pytorch.py:
##########
@@ -3386,6 +3386,19 @@ def trilu(self, inputs, input_types, mode):
         upper = True if mode == "triu" else False
         return _op.trilu(data, k, upper)
 
+    def multinomial(self, inputs, input_types):
+        probs = inputs[0]
+        num_samples = inputs[1]
+        replacement = inputs[2] if inputs[2] else True
+        assert not (
+            replacement is False and num_samples > 1
+        ), "Multinomial without replacement is not yet supported."
+        seed = np.random.randint(1e6)

Review Comment:
   Ideally there would be one seed that we pass through the entire graph that 
is set or initialized at runtime. But I don't think we have the infrastructure 
for that yet. This is fine for now but maybe you could add a comment about how 
to improve this in the future?



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

To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to