Repository: ivy-llc/ivy

Issue:
layer_norm



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/paddle/nn/functional/norm.py b/ivy/functional/frontends/paddle/nn/functional/norm.py
--- a/ivy/functional/frontends/paddle/nn/functional/norm.py
+++ b/ivy/functional/frontends/paddle/nn/functional/norm.py
@@ -1 +1,10 @@
 # local
+import ivy
+from ivy.func_wrapper import with_supported_dtypes
+from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
+
+
+@to_ivy_arrays_and_back
+@with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle")
+def layer_norm(x, normalized_shape, weight=None, bias=None, epsilon=1e-05, name=None):
+    return ivy.layer_norm(x, normalized_shape, weight, bias, epsilon)
diff --git a/ivy/functional/frontends/paddle/nn/functional/pooling.py b/ivy/functional/frontends/paddle/nn/functional/pooling.py
--- a/ivy/functional/frontends/paddle/nn/functional/pooling.py
+++ b/ivy/functional/frontends/paddle/nn/functional/pooling.py
@@ -81,3 +81,18 @@ def adaptive_avg_pool1d(x, output_size, name=None):
 @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle")
 def adaptive_avg_pool2d(x, output_size, data_format="NCHW", name=None):
     return ivy.adaptive_avg_pool2d(x, output_size)
+
+
+@to_ivy_arrays_and_back
+@with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle")
+def max_unpool1d(
+    x,
+    indices,
+    kernel_size,
+    stride=None,
+    padding=0,
+    data_format="NCL",
+    output_size=None,
+    name=None,
+):
+    return ivy.max_unpool1d(x, indices, kernel_size, stride, padding, data_format)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_norm.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_norm.py
--- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_norm.py
+++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_norm.py
@@ -1,3 +1,43 @@
 # global
+from hypothesis import strategies as st
 
 # local
+import ivy_tests.test_ivy.helpers as helpers
+from ivy_tests.test_ivy.helpers.testing_helpers import handle_frontend_test
+
+from ivy_tests.test_ivy.test_functional.test_nn.test_norms import (
+    _generate_data_layer_norm,
+)
+
+
+# layer_norm
+@handle_frontend_test(
+    fn_tree="paddle.nn.functional.layer_norm",
+    values_tuple=_generate_data_layer_norm(
+        available_dtypes=helpers.get_dtypes("float"),
+    ),
+    eps=st.floats(min_value=0.01, max_value=0.1),
+)
+def test_paddle_layer_norm(
+    *,
+    values_tuple,
+    normalized_shape,
+    eps,
+    test_flags,
+    frontend,
+    on_device,
+    fn_tree,
+):
+    (dtype, x, normalized_shape, scale, offset) = values_tuple
+    helpers.test_frontend_function(
+        input_dtypes=dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        on_device=on_device,
+        fn_tree=fn_tree,
+        x=x[0],
+        normalized_shape=normalized_shape,
+        weight=scale[0],
+        bias=offset[0],
+        epsilon=eps,
+    )
diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_pooling.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_pooling.py
--- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_pooling.py
+++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_pooling.py
@@ -180,3 +180,33 @@ def test_paddle_adaptive_avg_pool2d(
         x=x[0],
         output_size=output_size,
     )
+
+
+# max_unpool1d
+@handle_frontend_test(
+    fn_tree="paddle.nn.functional.max_unpool1d",
+    x_k_s_p=helpers.arrays_for_pooling(min_dims=3, max_dims=3, min_side=1, max_side=4),
+    indices=st.lists(st.integers(0, 1), min_size=1, max_size=4),
+)
+def test_paddle_max_unpool1d(
+    *,
+    x_k_s_p,
+    indices,
+    test_flags,
+    frontend,
+    on_device,
+    fn_tree,
+):
+    (input_dtype, x, kernel_size, stride, padding) = x_k_s_p
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        on_device=on_device,
+        fn_tree=fn_tree,
+        x=x[0],
+        indices=indices,
+        kernel_size=kernel_size,
+        stride=stride,
+        padding=padding,
+    )