Repository: ivy-llc/ivy

Issue:
stateless_normal



Discussion:

Resolving patch:
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
@@ -45,3 +45,28 @@ def stateless_uniform(
 @to_ivy_arrays_and_back
 def poisson(shape, lam, dtype=ivy.float32, seed=None, name=None):
     return ivy.poisson(shape=shape, lam=lam, dtype=dtype, seed=seed)
+
+
+@with_unsupported_dtypes(
+    {"2.9.0 and below": ("int8", "int16", "unsigned")}, "tensorflow"
+)
+@to_ivy_arrays_and_back
+def stateless_normal(
+    shape, seed, mean=0.0, stddev=1.0, dtype=ivy.float32, name=None, alg="auto_select"
+):
+    return ivy.random_normal(
+        mean=mean, std=stddev, shape=shape, dtype=dtype, seed=seed[0] + seed[1]
+    )
+
+
+@with_unsupported_dtypes(
+    {"2.9.0 and below": ("int8", "int16", "unsigned")}, "tensorflow"
+)
+@to_ivy_arrays_and_back
+def stateless_poisson(shape, seed, lam, dtype=ivy.int32, name=None):
+    return ivy.poisson(shape=shape, lam=lam, dtype=dtype, seed=seed[0] + seed[1])
+
+
+@to_ivy_arrays_and_back
+def gamma(shape, alpha, beta=None, dtype=ivy.float32, seed=None, name=None):
+    return ivy.gamma(alpha, beta, shape=shape, dtype=dtype, seed=seed)


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
@@ -209,3 +209,151 @@ def test_tensorflow_poisson(
         seed=seed,
         test_values=False,
     )
+
+
+# stateless_normal
+@handle_frontend_test(
+    fn_tree="tensorflow.random.stateless_normal",
+    shape=helpers.get_shape(
+        allow_none=False,
+        min_num_dims=1,
+        max_num_dims=5,
+        min_dim_size=1,
+        max_dim_size=10,
+    ),
+    seed=helpers.dtype_and_values(
+        available_dtypes=("int64", "int32"), min_value=0, max_value=10, shape=[2]
+    ),
+    mean=st.floats(allow_nan=False, allow_infinity=False, width=32),
+    stddev=st.floats(allow_nan=False, allow_infinity=False, width=32, min_value=0),
+    dtype=helpers.get_dtypes("float", full=False),
+    test_with_out=st.just(False),
+)
+def test_tensorflow_stateless_normal(
+    frontend,
+    fn_tree,
+    on_device,
+    shape,
+    seed,
+    mean,
+    stddev,
+    dtype,
+    test_flags,
+):
+    input_dtypes, seed = seed
+    helpers.test_frontend_function(
+        input_dtypes=input_dtypes,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_values=False,
+        shape=shape,
+        seed=seed[0],
+        mean=mean,
+        stddev=stddev,
+        dtype=dtype[0],
+    )
+
+
+# stateless_poisson
+
+
+@st.composite
+def _shape_lam_dtype(draw):
+    dtype = draw(helpers.array_dtypes(available_dtypes=("float32", "float64")))
+    common_shape = draw(
+        helpers.get_shape(
+            allow_none=False,
+            min_num_dims=2,
+            max_num_dims=3,
+            min_dim_size=1,
+            max_dim_size=5,
+        )
+    )
+    _, lam = draw(
+        helpers.dtype_and_values(
+            available_dtypes=dtype, min_value=0, max_value=10, shape=(common_shape[-1],)
+        )
+    )
+    return common_shape, lam, dtype
+
+
+@handle_frontend_test(
+    fn_tree="tensorflow.random.stateless_poisson",
+    shape_lam_dtype=_shape_lam_dtype(),
+    seed=helpers.dtype_and_values(
+        available_dtypes=("int64", "int32"), min_value=0, max_value=10, shape=[2]
+    ),
+    test_with_out=st.just(False),
+)
+def test_tensorflow_stateless_poisson(
+    frontend,
+    fn_tree,
+    on_device,
+    shape_lam_dtype,
+    seed,
+    test_flags,
+):
+    shape, lam, dtype = shape_lam_dtype
+    input_dtypes, seed = seed
+    helpers.test_frontend_function(
+        input_dtypes=input_dtypes,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_values=False,
+        shape=shape,
+        seed=seed[0],
+        lam=lam[0],
+        dtype=dtype[0],
+    )
+
+
+# random gamma
+@handle_frontend_test(
+    fn_tree="tensorflow.random.gamma",
+    dtype=helpers.array_dtypes(
+        available_dtypes=("float32", "float64"),
+    ),
+    shape=helpers.get_shape(
+        allow_none=False,
+        min_num_dims=1,
+        max_num_dims=3,
+        min_dim_size=1,
+        max_dim_size=5,
+    ),
+    alpha=st.floats(
+        allow_infinity=False, allow_nan=False, width=32, min_value=1, max_value=3
+    ),
+    beta=st.floats(
+        allow_infinity=False, allow_nan=False, width=32, min_value=1, max_value=3
+    ),
+    seed=helpers.ints(min_value=0, max_value=10),
+    test_with_out=st.just(False),
+)
+def test_tensorflow_gamma(
+    frontend,
+    fn_tree,
+    on_device,
+    shape,
+    alpha,
+    beta,
+    dtype,
+    seed,
+    test_flags,
+):
+    helpers.test_frontend_function(
+        input_dtypes=dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        shape=shape,
+        alpha=alpha,
+        beta=beta,
+        dtype=dtype[0],
+        seed=seed,
+        test_values=False,
+    )