From 6746684f9efaea12ce946c6f7b13a782f0c8bf91 Mon Sep 17 00:00:00 2001 From: Somasree Majumder Date: Tue, 27 Feb 2024 16:30:13 +0000 Subject: [PATCH 1/4] gh --- ivy_tests/test_ivy/helpers/testing_helpers.py | 9 ++++----- ivy_tests/test_ivy/test_stateful/test_activations.py | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ivy_tests/test_ivy/helpers/testing_helpers.py b/ivy_tests/test_ivy/helpers/testing_helpers.py index 6c76e6e9f645a..b4c490bcd684c 100644 --- a/ivy_tests/test_ivy/helpers/testing_helpers.py +++ b/ivy_tests/test_ivy/helpers/testing_helpers.py @@ -664,7 +664,9 @@ def handle_method( ) if init_num_positional_args is None: - init_num_positional_args = num_positional_args(fn_name=init_tree) + init_num_positional_args = num_positional_args( + fn_name=method_tree.rpartition(".")[0] + ) possible_arguments["init_flags"] = pf.init_method_flags( num_positional_args=init_num_positional_args, @@ -673,10 +675,7 @@ def handle_method( precision_mode=_get_runtime_flag_value(precision_mode), ) - if method_num_positional_args is None: - method_num_positional_args = num_positional_args_method( - method=callable_method - ) + method_num_positional_args = num_positional_args_method(method=callable_method) possible_arguments["method_flags"] = pf.method_flags( num_positional_args=method_num_positional_args, diff --git a/ivy_tests/test_ivy/test_stateful/test_activations.py b/ivy_tests/test_ivy/test_stateful/test_activations.py index 6a1892b165c6f..5c91c9b3d7718 100644 --- a/ivy_tests/test_ivy/test_stateful/test_activations.py +++ b/ivy_tests/test_ivy/test_stateful/test_activations.py @@ -20,7 +20,7 @@ small_abs_safety_factor=8, safety_factor_scale="log", ), - method_num_positional_args=helpers.num_positional_args(fn_name="ELU._forward"), + method_num_positional_args=helpers.num_positional_args(method="ELU._forward"), test_gradients=st.just(True), alpha=helpers.floats(min_value=0.1, max_value=1), ) @@ -45,8 +45,8 @@ def test_elu( method_flags=method_flags, init_input_dtypes=input_dtype, method_input_dtypes=input_dtype, - init_all_as_kwargs_np={}, - method_all_as_kwargs_np={"x": x[0], "alpha": alpha}, + init_all_as_kwargs_np={"x": x[0]}, + method_all_as_kwargs_np={"alpha": alpha}, class_name=class_name, method_name=method_name, rtol_=1e-2, From 2cd999e3456c969c64b697f888baaf0e48dfd498 Mon Sep 17 00:00:00 2001 From: Somasree Majumder Date: Tue, 27 Feb 2024 16:36:02 +0000 Subject: [PATCH 2/4] fix --- ivy_tests/test_ivy/test_stateful/test_activations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ivy_tests/test_ivy/test_stateful/test_activations.py b/ivy_tests/test_ivy/test_stateful/test_activations.py index 5c91c9b3d7718..eabd4ca9c4184 100644 --- a/ivy_tests/test_ivy/test_stateful/test_activations.py +++ b/ivy_tests/test_ivy/test_stateful/test_activations.py @@ -45,8 +45,8 @@ def test_elu( method_flags=method_flags, init_input_dtypes=input_dtype, method_input_dtypes=input_dtype, - init_all_as_kwargs_np={"x": x[0]}, - method_all_as_kwargs_np={"alpha": alpha}, + init_all_as_kwargs_np={"alpha": alpha}, + method_all_as_kwargs_np={"x": x[0]}, class_name=class_name, method_name=method_name, rtol_=1e-2, From 1d38f65c55636586022887516fe5fa127b7a7938 Mon Sep 17 00:00:00 2001 From: Somasree Majumder Date: Thu, 7 Mar 2024 04:15:42 +0000 Subject: [PATCH 3/4] all functions --- .../test_stateful/test_activations.py | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/ivy_tests/test_ivy/test_stateful/test_activations.py b/ivy_tests/test_ivy/test_stateful/test_activations.py index eabd4ca9c4184..64f698d81ca75 100644 --- a/ivy_tests/test_ivy/test_stateful/test_activations.py +++ b/ivy_tests/test_ivy/test_stateful/test_activations.py @@ -66,7 +66,7 @@ def test_elu( small_abs_safety_factor=8, safety_factor_scale="log", ), - method_num_positional_args=helpers.num_positional_args(fn_name="GEGLU._forward"), + method_num_positional_args=helpers.num_positional_args(method="GEGLU._forward"), test_gradients=st.just(True), ) def test_geglu( @@ -112,7 +112,7 @@ def test_geglu( safety_factor_scale="linear", ), approximate=st.booleans(), - method_num_positional_args=helpers.num_positional_args(fn_name="GELU._forward"), + method_num_positional_args=helpers.num_positional_args(method="GELU._forward"), test_gradients=st.just(True), ) def test_gelu( @@ -157,9 +157,7 @@ def test_gelu( safety_factor_scale="log", min_num_dims=2, ), - method_num_positional_args=helpers.num_positional_args( - fn_name="Hardswish._forward" - ), + method_num_positional_args=helpers.num_positional_args(method="Hardswish._forward"), test_gradients=st.just(True), ) def test_hardswish( @@ -204,9 +202,7 @@ def test_hardswish( safety_factor_scale="log", ), alpha=st.floats(min_value=-1e-4, max_value=1e-4), - method_num_positional_args=helpers.num_positional_args( - fn_name="LeakyReLU._forward" - ), + method_num_positional_args=helpers.num_positional_args(method="LeakyReLU._forward"), test_gradients=st.just(True), ) def test_leaky_relu( @@ -253,7 +249,7 @@ def test_leaky_relu( ), axis=helpers.ints(min_value=-1, max_value=0), method_num_positional_args=helpers.num_positional_args( - fn_name="LogSoftmax._forward" + method="LogSoftmax._forward" ), test_gradients=st.just(True), ) @@ -299,7 +295,7 @@ def test_log_softmax( safety_factor_scale="log", min_num_dims=2, ), - method_num_positional_args=helpers.num_positional_args(fn_name="Logit._forward"), + method_num_positional_args=helpers.num_positional_args(method="Logit._forward"), eps=helpers.floats(min_value=1e-4, max_value=1e-2), test_gradients=st.just(True), ) @@ -346,7 +342,7 @@ def test_logit( min_num_dims=2, ), method_num_positional_args=helpers.num_positional_args( - fn_name="LogSigmoid._forward" + method="LogSigmoid._forward" ), test_gradients=st.just(True), ) @@ -389,7 +385,7 @@ def test_logsigmoid( small_abs_safety_factor=8, safety_factor_scale="log", ), - method_num_positional_args=helpers.num_positional_args(fn_name="Mish._forward"), + method_num_positional_args=helpers.num_positional_args(method="Mish._forward"), test_gradients=st.just(True), ) def test_mish( @@ -435,7 +431,7 @@ def test_mish( small_abs_safety_factor=8, safety_factor_scale="log", ), - method_num_positional_args=helpers.num_positional_args(fn_name="PReLU._forward"), + method_num_positional_args=helpers.num_positional_args(method="PReLU._forward"), test_gradients=st.just(True), ) def test_prelu( @@ -477,7 +473,7 @@ def test_prelu( small_abs_safety_factor=8, safety_factor_scale="log", ), - method_num_positional_args=helpers.num_positional_args(fn_name="ReLU._forward"), + method_num_positional_args=helpers.num_positional_args(method="ReLU._forward"), test_gradients=st.just(True), ) def test_relu( @@ -521,7 +517,7 @@ def test_relu( safety_factor_scale="log", min_num_dims=2, ), - method_num_positional_args=helpers.num_positional_args(fn_name="ReLU6._forward"), + method_num_positional_args=helpers.num_positional_args(method="ReLU6._forward"), test_gradients=st.just(True), ) def test_relu6( @@ -565,7 +561,7 @@ def test_relu6( safety_factor_scale="log", min_num_dims=2, ), - method_num_positional_args=helpers.num_positional_args(fn_name="SeLU._forward"), + method_num_positional_args=helpers.num_positional_args(method="SeLU._forward"), test_gradients=st.just(True), ) def test_selu( @@ -609,7 +605,7 @@ def test_selu( safety_factor_scale="log", min_num_dims=2, ), - method_num_positional_args=helpers.num_positional_args(fn_name="Sigmoid._forward"), + method_num_positional_args=helpers.num_positional_args(method="Sigmoid._forward"), test_gradients=st.just(True), ) def test_sigmoid( @@ -651,7 +647,7 @@ def test_sigmoid( small_abs_safety_factor=8, safety_factor_scale="log", ), - method_num_positional_args=helpers.num_positional_args(fn_name="SiLU._forward"), + method_num_positional_args=helpers.num_positional_args(method="SiLU._forward"), test_gradients=st.just(True), ) def test_silu( @@ -695,7 +691,7 @@ def test_silu( safety_factor_scale="log", ), axis=helpers.ints(min_value=-1, max_value=0), - method_num_positional_args=helpers.num_positional_args(fn_name="Softmax._forward"), + method_num_positional_args=helpers.num_positional_args(method="Softmax._forward"), test_gradients=st.just(True), ) def test_softmax( @@ -741,7 +737,7 @@ def test_softmax( ), beta=st.one_of(helpers.number(min_value=0.1, max_value=10), st.none()), threshold=st.one_of(helpers.number(min_value=0.1, max_value=30), st.none()), - method_num_positional_args=helpers.num_positional_args(fn_name="Softplus._forward"), + method_num_positional_args=helpers.num_positional_args(method="Softplus._forward"), test_gradients=st.just(True), ) def test_softplus( @@ -787,7 +783,7 @@ def test_softplus( safety_factor_scale="log", min_num_dims=2, ), - method_num_positional_args=helpers.num_positional_args(fn_name="Tanh._forward"), + method_num_positional_args=helpers.num_positional_args(method="Tanh._forward"), test_gradients=st.just(True), ) def test_tanh( From a4d05c02476617feb7502626b692f38cab5faf9a Mon Sep 17 00:00:00 2001 From: Somasree Majumder Date: Thu, 7 Mar 2024 04:24:06 +0000 Subject: [PATCH 4/4] all functions --- ivy_tests/test_ivy/test_stateful/test_activations.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ivy_tests/test_ivy/test_stateful/test_activations.py b/ivy_tests/test_ivy/test_stateful/test_activations.py index 64f698d81ca75..5172faf7cbd9d 100644 --- a/ivy_tests/test_ivy/test_stateful/test_activations.py +++ b/ivy_tests/test_ivy/test_stateful/test_activations.py @@ -320,8 +320,8 @@ def test_logit( method_flags=method_flags, init_input_dtypes=input_dtype, method_input_dtypes=input_dtype, - init_all_as_kwargs_np={}, - method_all_as_kwargs_np={"x": x[0], "eps": eps}, + init_all_as_kwargs_np={"eps": eps}, + method_all_as_kwargs_np={"x": x[0]}, class_name=class_name, method_name=method_name, rtol_=1e-2, @@ -715,8 +715,8 @@ def test_softmax( method_flags=method_flags, init_input_dtypes=input_dtype, method_input_dtypes=input_dtype, - init_all_as_kwargs_np={}, - method_all_as_kwargs_np={"x": x[0], "axis": axis}, + init_all_as_kwargs_np={"axis": axis}, + method_all_as_kwargs_np={"x": x[0]}, class_name=class_name, method_name=method_name, rtol_=1e-2, @@ -762,8 +762,8 @@ def test_softplus( method_flags=method_flags, init_input_dtypes=input_dtype, method_input_dtypes=input_dtype, - init_all_as_kwargs_np={}, - method_all_as_kwargs_np={"x": x[0], "beta": beta, "threshold": threshold}, + init_all_as_kwargs_np={"beta": beta, "threshold": threshold}, + method_all_as_kwargs_np={"x": x[0]}, class_name=class_name, method_name=method_name, rtol_=1e-2,