Repository: ivy-llc/ivy

Issue:
stateless_uniform



Discussion:

Resolving patch:
diff --git a/ivy/functional/backends/jax/random.py b/ivy/functional/backends/jax/random.py
--- a/ivy/functional/backends/jax/random.py
+++ b/ivy/functional/backends/jax/random.py
@@ -57,11 +57,12 @@ def random_uniform(
     else:
         RNG_, rng_input = jax.random.split(_getRNG())
         _setRNG(RNG_)
-
     return to_device(
-        jax.random.uniform(rng_input, shape, minval=low, maxval=high, dtype=dtype),
+        jax.random.uniform(
+            rng_input, shape, minval=low, maxval=high, dtype=jnp.float32
+        ),
         device,
-    )
+    ).astype(dtype)
 
 
 def random_normal(
diff --git a/ivy/functional/backends/torch/random.py b/ivy/functional/backends/torch/random.py
--- a/ivy/functional/backends/torch/random.py
+++ b/ivy/functional/backends/torch/random.py
@@ -34,7 +34,9 @@ def random_uniform(
         torch.manual_seed(seed)
     if torch.is_tensor(shape):
         shape = shape.tolist()
-    return torch.rand(shape, device=device, dtype=dtype) * rand_range + low
+    return (
+        torch.rand(shape, device=device, dtype=torch.float) * rand_range + low
+    ).type(dtype)
 
 
 def random_normal(
diff --git a/ivy/functional/frontends/tensorflow/random.py b/ivy/functional/frontends/tensorflow/random.py
--- a/ivy/functional/frontends/tensorflow/random.py
+++ b/ivy/functional/frontends/tensorflow/random.py
@@ -28,3 +28,12 @@ def normal(shape, mean=0.0, stddev=1.0, dtype=ivy.float32, seed=None, name=None)
 @to_ivy_arrays_and_back
 def shuffle(value, seed=None, name=None):
     return ivy.shuffle(value, seed=seed)
+
+
+@to_ivy_arrays_and_back
+def stateless_uniform(
+    shape, seed, minval=0, maxval=None, dtype=ivy.float32, name=None, alg="auto_select"
+):
+    return ivy.random_uniform(
+        shape=shape, seed=seed[0] + seed[1], low=minval, high=maxval, dtype=dtype
+    )


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_random.py b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_random.py
--- a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_random.py
+++ b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_random.py
@@ -118,3 +118,51 @@ def test_tensorflow_shuffle(
         value=values[0],
         seed=seed,
     )
+
+
+# random_stateless_uniform
+@handle_frontend_test(
+    fn_tree="tensorflow.random.stateless_uniform",
+    shape=helpers.dtype_and_values(
+        available_dtypes=("int64", "int32"),
+        min_value=1,
+        max_value=5,
+        min_num_dims=1,
+        max_num_dims=1,
+        max_dim_size=9,
+    ),
+    seed=helpers.dtype_and_values(
+        available_dtypes=("int64", "int32"), min_value=0, max_value=10, shape=[2]
+    ),
+    minmaxval=helpers.get_bounds(dtype="int32"),
+    dtype=helpers.array_dtypes(
+        available_dtypes=("int32", "int64", "float16", "float32", "float64"),
+    ),
+    test_with_out=st.just(False),
+)
+def test_tensorflow_stateless_uniform(
+    shape,
+    seed,
+    minmaxval,
+    dtype,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+):
+    shape_input_dtypes, shape = shape
+    seed_input_dtypes, seed = seed
+
+    helpers.test_frontend_function(
+        input_dtypes=shape_input_dtypes + seed_input_dtypes,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_values=False,
+        shape=shape[0],
+        seed=seed[0],
+        minval=int(minmaxval[0]),
+        maxval=int(minmaxval[1]),
+        dtype=dtype[0],
+    )