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



##########
File path: tests/python/topi/python/test_topi_prng.py
##########
@@ -118,7 +135,24 @@ def test_threefry_wrapping(target, dev):
     ), f"{target} does not suppport wrapping unsigned integer arithmetic"
 
 
[email protected]_targets
+def test_uniform(target, dev):
+    gen = tvm.relay.random.threefry_key(0).data.asnumpy()
+    m = 1024
+    n = 1024
+    dtypes = ["float32", "float64"]
+    for dtype in dtypes:
+        low = np.array(5.0, dtype=dtype)
+        high = np.array(10.0, dtype=dtype)
+        new_gen, rands = uniform(target, dev, gen, low, high, (m, n), dtype)
+        assert (gen != new_gen).any()
+        assert abs(np.mean(rands) - 7.5) < 1e-1
+        assert abs(np.min(rands) - 5.0) < 1e-3
+        assert abs(np.max(rands) - 10.0) < 1e-3

Review comment:
       `<=` check?

##########
File path: tests/python/topi/python/test_topi_prng.py
##########
@@ -118,7 +135,24 @@ def test_threefry_wrapping(target, dev):
     ), f"{target} does not suppport wrapping unsigned integer arithmetic"
 
 
[email protected]_targets
+def test_uniform(target, dev):
+    gen = tvm.relay.random.threefry_key(0).data.asnumpy()
+    m = 1024
+    n = 1024
+    dtypes = ["float32", "float64"]
+    for dtype in dtypes:
+        low = np.array(5.0, dtype=dtype)
+        high = np.array(10.0, dtype=dtype)
+        new_gen, rands = uniform(target, dev, gen, low, high, (m, n), dtype)
+        assert (gen != new_gen).any()
+        assert abs(np.mean(rands) - 7.5) < 1e-1
+        assert abs(np.min(rands) - 5.0) < 1e-3

Review comment:
       could we change this to a `>=` check? 




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