From 00dedbd363252821f96a7ce4c218523193e9691d Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Thu, 22 Jun 2023 13:45:22 +0530 Subject: [PATCH 01/13] after pull the all files --- .../test_jax/test_jax_devicearray.py | 2 +- .../test_jax/test_jax_numpy_linalg.py | 3 +- .../test_nn/test_activations.py | 36 +++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py index ead6da2a14a11..b98d528567430 100644 --- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py +++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py @@ -324,7 +324,7 @@ def test_jax_devicearray_cumsum( method_flags=method_flags, on_device=on_device, ) - + @handle_frontend_method( class_tree=CLASS_TREE, diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_linalg.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_linalg.py index 0505815a42948..8cd18e67dbb76 100644 --- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_linalg.py +++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_linalg.py @@ -342,7 +342,7 @@ def test_jax_numpy_qr( frontend_ret = [x.astype(np.float64) for x in frontend_ret] Q, R = ret - frontend_Q, frontend_R = frontend_ret + frontend_Q, frontend_R = frontend_ret assert_all_close( ret_np=Q @ R, @@ -351,7 +351,6 @@ def test_jax_numpy_qr( ) - # eigvals @handle_frontend_test( fn_tree="jax.numpy.linalg.eigvals", diff --git a/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py b/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py index ae15835a58844..5903cf7108dbc 100644 --- a/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py +++ b/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py @@ -294,3 +294,39 @@ def test_mish( atol_=1e-02, x=x[0], ) + + +# elu +@handle_test( + fn_tree="functional.ivy.elu", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("float", full=False, key="elu"), + large_abs_safety_factor=16, + small_abs_safety_factor=16, + safety_factor_scale="log", + ), + alpha=st.floats(min_value=-1e-4, max_value=1e-4), +) +def test_elu( + *, + dtype_and_x, + alpha, + test_flags, + backend_fw, + fn_name, + on_device, + ground_truth_backend, +): + dtype, x = dtype_and_x + helpers.test_function( + ground_truth_backend=ground_truth_backend, + input_dtypes=dtype, + fw=backend_fw, + test_flags=test_flags, + fn_name=fn_name, + on_device=on_device, + rtol_=1e-2, + atol_=1e-2, + x=x[0], + alpha=alpha, + ) From 0ec4288cf0e5880c925c014b640b4d1d87d1f97e Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Fri, 23 Jun 2023 18:29:16 +0530 Subject: [PATCH 02/13] Revert "after pull the all files" This reverts commit 00dedbd363252821f96a7ce4c218523193e9691d. --- .../test_jax/test_jax_devicearray.py | 2 +- .../test_jax/test_jax_numpy_linalg.py | 3 +- .../test_nn/test_activations.py | 36 ------------------- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py index b98d528567430..ead6da2a14a11 100644 --- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py +++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py @@ -324,7 +324,7 @@ def test_jax_devicearray_cumsum( method_flags=method_flags, on_device=on_device, ) - + @handle_frontend_method( class_tree=CLASS_TREE, diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_linalg.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_linalg.py index 8cd18e67dbb76..0505815a42948 100644 --- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_linalg.py +++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_linalg.py @@ -342,7 +342,7 @@ def test_jax_numpy_qr( frontend_ret = [x.astype(np.float64) for x in frontend_ret] Q, R = ret - frontend_Q, frontend_R = frontend_ret + frontend_Q, frontend_R = frontend_ret assert_all_close( ret_np=Q @ R, @@ -351,6 +351,7 @@ def test_jax_numpy_qr( ) + # eigvals @handle_frontend_test( fn_tree="jax.numpy.linalg.eigvals", diff --git a/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py b/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py index 5903cf7108dbc..ae15835a58844 100644 --- a/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py +++ b/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py @@ -294,39 +294,3 @@ def test_mish( atol_=1e-02, x=x[0], ) - - -# elu -@handle_test( - fn_tree="functional.ivy.elu", - dtype_and_x=helpers.dtype_and_values( - available_dtypes=helpers.get_dtypes("float", full=False, key="elu"), - large_abs_safety_factor=16, - small_abs_safety_factor=16, - safety_factor_scale="log", - ), - alpha=st.floats(min_value=-1e-4, max_value=1e-4), -) -def test_elu( - *, - dtype_and_x, - alpha, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): - dtype, x = dtype_and_x - helpers.test_function( - ground_truth_backend=ground_truth_backend, - input_dtypes=dtype, - fw=backend_fw, - test_flags=test_flags, - fn_name=fn_name, - on_device=on_device, - rtol_=1e-2, - atol_=1e-2, - x=x[0], - alpha=alpha, - ) From 007add1f2d13eb3b58451b605cfe5d7ef371f6ca Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Sat, 24 Jun 2023 23:58:40 +0530 Subject: [PATCH 03/13] adding bitwise not --- .../frontends/paddle/tensor/logic.py | 19 +++++++++++ .../frontends/paddle/tensor/tensor.py | 7 ++++ .../test_tensor/test_paddle_tensor.py | 33 +++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/ivy/functional/frontends/paddle/tensor/logic.py b/ivy/functional/frontends/paddle/tensor/logic.py index ef87c5d7a0ef3..3c488044262f7 100644 --- a/ivy/functional/frontends/paddle/tensor/logic.py +++ b/ivy/functional/frontends/paddle/tensor/logic.py @@ -237,3 +237,22 @@ def is_tensor(x): @to_ivy_arrays_and_back def isclose(x, y, rtol=1e-05, atol=1e-08, equal_nan=False, name=None): return ivy.isclose(x, y, rtol=rtol, atol=atol, equal_nan=equal_nan) + + +@with_supported_dtypes( + { + "2.5.0 and below": ( + "bool", + "uint8", + "int8", + "int16", + "int32", + "int64", + ) + }, + "paddle", +) +@to_ivy_arrays_and_back +@handle_out_argument +def bitwise_not(x, /, *, name=None, out=None): + return ivy.bitwise_invert(x, out=out) \ No newline at end of file diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index 93204ca2c51ac..389212b80c2d4 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -223,3 +223,10 @@ def any(self, axis=None, keepdim=False, name=None): @with_supported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def astype(self, dtype): return ivy.astype(self._ivy_array, dtype=dtype) + + @with_supported_dtypes( + {"2.5.0 and below": ("bool", "uint8", "int8", "int16", "int32", "int64")}, + "paddle", + ) + def bitwise_not(self,out=None, name=None): + return paddle_frontend.bitwise_not(self,out=out) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py index 368498d1f89f9..9e3da16dabb29 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py @@ -1285,3 +1285,36 @@ def test_paddle_bitwise_xor( frontend=frontend, on_device=on_device, ) + + +# bitwise_not +@handle_frontend_method( + class_tree=CLASS_TREE, + init_tree="paddle.to_tensor", + method_name="bitwise_not", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + ), +) +def test_paddle_bitwise_not( + dtype_and_x, + frontend_method_data, + init_flags, + method_flags, + frontend, + on_device, +): + input_dtype, x = dtype_and_x + helpers.test_frontend_method( + init_input_dtypes=input_dtype, + init_all_as_kwargs_np={ + "data": x[0], + }, + method_input_dtypes=input_dtype, + method_all_as_kwargs_np={}, + frontend_method_data=frontend_method_data, + init_flags=init_flags, + method_flags=method_flags, + frontend=frontend, + on_device=on_device, + ) From 02f00914e548eee7b8eb70c350f9bcab91339ce3 Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Sun, 25 Jun 2023 00:00:37 +0530 Subject: [PATCH 04/13] Revert "adding bitwise not" This reverts commit 007add1f2d13eb3b58451b605cfe5d7ef371f6ca. --- .../frontends/paddle/tensor/logic.py | 19 ----------- .../frontends/paddle/tensor/tensor.py | 7 ---- .../test_tensor/test_paddle_tensor.py | 33 ------------------- 3 files changed, 59 deletions(-) diff --git a/ivy/functional/frontends/paddle/tensor/logic.py b/ivy/functional/frontends/paddle/tensor/logic.py index 3c488044262f7..ef87c5d7a0ef3 100644 --- a/ivy/functional/frontends/paddle/tensor/logic.py +++ b/ivy/functional/frontends/paddle/tensor/logic.py @@ -237,22 +237,3 @@ def is_tensor(x): @to_ivy_arrays_and_back def isclose(x, y, rtol=1e-05, atol=1e-08, equal_nan=False, name=None): return ivy.isclose(x, y, rtol=rtol, atol=atol, equal_nan=equal_nan) - - -@with_supported_dtypes( - { - "2.5.0 and below": ( - "bool", - "uint8", - "int8", - "int16", - "int32", - "int64", - ) - }, - "paddle", -) -@to_ivy_arrays_and_back -@handle_out_argument -def bitwise_not(x, /, *, name=None, out=None): - return ivy.bitwise_invert(x, out=out) \ No newline at end of file diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index 389212b80c2d4..93204ca2c51ac 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -223,10 +223,3 @@ def any(self, axis=None, keepdim=False, name=None): @with_supported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def astype(self, dtype): return ivy.astype(self._ivy_array, dtype=dtype) - - @with_supported_dtypes( - {"2.5.0 and below": ("bool", "uint8", "int8", "int16", "int32", "int64")}, - "paddle", - ) - def bitwise_not(self,out=None, name=None): - return paddle_frontend.bitwise_not(self,out=out) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py index 9e3da16dabb29..368498d1f89f9 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py @@ -1285,36 +1285,3 @@ def test_paddle_bitwise_xor( frontend=frontend, on_device=on_device, ) - - -# bitwise_not -@handle_frontend_method( - class_tree=CLASS_TREE, - init_tree="paddle.to_tensor", - method_name="bitwise_not", - dtype_and_x=helpers.dtype_and_values( - available_dtypes=helpers.get_dtypes("valid"), - ), -) -def test_paddle_bitwise_not( - dtype_and_x, - frontend_method_data, - init_flags, - method_flags, - frontend, - on_device, -): - input_dtype, x = dtype_and_x - helpers.test_frontend_method( - init_input_dtypes=input_dtype, - init_all_as_kwargs_np={ - "data": x[0], - }, - method_input_dtypes=input_dtype, - method_all_as_kwargs_np={}, - frontend_method_data=frontend_method_data, - init_flags=init_flags, - method_flags=method_flags, - frontend=frontend, - on_device=on_device, - ) From 67a68caaf5be9638121bd3894efcba41ca9fb4cd Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Tue, 27 Jun 2023 18:49:07 +0530 Subject: [PATCH 05/13] added divide method to paddle tensor --- .../frontends/paddle/tensor/tensor.py | 4 +++ .../test_tensor/test_paddle_tensor.py | 35 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index a5fd73318a855..17ab2d34a15f0 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -276,3 +276,7 @@ def greater_than(self, y, name=None): @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def rsqrt(self, name=None): return ivy.reciprocal(ivy.sqrt(self._ivy_array)) + + @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") + def divide(x, y, name=None): + return paddle_frontend.divide(x, y) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py index 7857131272498..f9e86c1bdab54 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py @@ -1448,3 +1448,38 @@ def test_paddle_greater_than( frontend=frontend, on_device=on_device, ) + + +# greater_than +@handle_frontend_method( + class_tree=CLASS_TREE, + init_tree="paddle.to_tensor", + method_name="divde", + dtypes_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + num_arrays=2, + shared_dtype=True, + safety_factor_scale="log", + small_abs_safety_factor=32, + ), +) +def test_paddle_divide( + dtypes_and_x, + frontend_method_data, + init_flags, + method_flags, + frontend, + on_device, +): + input_dtype, x = dtypes_and_x + helpers.test_frontend_method( + init_input_dtypes=input_dtype, + init_all_as_kwargs_np={"data": x[0]}, + method_input_dtypes=input_dtype, + method_all_as_kwargs_np={"y": x[1]}, + frontend_method_data=frontend_method_data, + init_flags=init_flags, + method_flags=method_flags, + frontend=frontend, + on_device=on_device, + ) From 4c31b4b8b3838c009797179e17c23c3d28c1192b Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Tue, 27 Jun 2023 18:51:40 +0530 Subject: [PATCH 06/13] Revert "added divide method to paddle tensor" This reverts commit 67a68caaf5be9638121bd3894efcba41ca9fb4cd. --- .../frontends/paddle/tensor/tensor.py | 4 --- .../test_tensor/test_paddle_tensor.py | 35 ------------------- 2 files changed, 39 deletions(-) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index 17ab2d34a15f0..a5fd73318a855 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -276,7 +276,3 @@ def greater_than(self, y, name=None): @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def rsqrt(self, name=None): return ivy.reciprocal(ivy.sqrt(self._ivy_array)) - - @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") - def divide(x, y, name=None): - return paddle_frontend.divide(x, y) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py index f9e86c1bdab54..7857131272498 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py @@ -1448,38 +1448,3 @@ def test_paddle_greater_than( frontend=frontend, on_device=on_device, ) - - -# greater_than -@handle_frontend_method( - class_tree=CLASS_TREE, - init_tree="paddle.to_tensor", - method_name="divde", - dtypes_and_x=helpers.dtype_and_values( - available_dtypes=helpers.get_dtypes("valid"), - num_arrays=2, - shared_dtype=True, - safety_factor_scale="log", - small_abs_safety_factor=32, - ), -) -def test_paddle_divide( - dtypes_and_x, - frontend_method_data, - init_flags, - method_flags, - frontend, - on_device, -): - input_dtype, x = dtypes_and_x - helpers.test_frontend_method( - init_input_dtypes=input_dtype, - init_all_as_kwargs_np={"data": x[0]}, - method_input_dtypes=input_dtype, - method_all_as_kwargs_np={"y": x[1]}, - frontend_method_data=frontend_method_data, - init_flags=init_flags, - method_flags=method_flags, - frontend=frontend, - on_device=on_device, - ) From eff24fc0a59d2d31916f9f5392aa64fe23a10bdb Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Sat, 8 Jul 2023 21:11:01 +0530 Subject: [PATCH 07/13] adding var to paddle frontend --- .../frontends/paddle/tensor/stat.py | 6 +++ .../frontends/paddle/tensor/tensor.py | 4 ++ .../test_tensor/test_paddle_stat.py | 33 ++++++++++++ .../test_tensor/test_paddle_tensor.py | 52 +++++++++++++++++-- 4 files changed, 92 insertions(+), 3 deletions(-) diff --git a/ivy/functional/frontends/paddle/tensor/stat.py b/ivy/functional/frontends/paddle/tensor/stat.py index 255a96fdefcd6..777ecbcb49cc2 100644 --- a/ivy/functional/frontends/paddle/tensor/stat.py +++ b/ivy/functional/frontends/paddle/tensor/stat.py @@ -45,3 +45,9 @@ def median(x, axis=None, keepdim=False, name=None): else ivy.astype(x, ivy.float32) ) return ivy.median(x, axis=axis, keepdims=keepdim) + + +@with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") +@to_ivy_arrays_and_back +def var(x, axis=None, unbiased=True, keepdim=False, *, out=None): + return ivy.var(x, axis=axis, correction=int(unbiased), keepdims=keepdim, out=out) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index 63139df153dad..954df17156deb 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -520,3 +520,7 @@ def logical_not(self, out=None, name=None): @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def sign(self, name=None): return ivy.sign(self._ivy_array) + + @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") + def var(self, axis=None, *, unbiased=True, keepdim=False): + return paddle_frontend.var(self, axis=axis, unbiased=unbiased, keepdim=keepdim) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_stat.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_stat.py index 74a3a8615ec18..3d93566f02da7 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_stat.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_stat.py @@ -128,3 +128,36 @@ def test_paddle_median( axis=axis, keepdim=keepdim, ) + + +# var +@handle_frontend_test( + fn_tree="paddle.var", + dtype_and_x=_statistical_dtype_values( + function="var", + min_value=-1e04, + max_value=1e04, + ), + keepdims=st.booleans(), +) +def test_paddle_var( + *, + dtype_and_x, + keepdims, + on_device, + fn_tree, + frontend, + test_flags, +): + input_dtype, x, axis, correction = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtype, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + x=x[0], + axis=axis, + unbiased=bool(correction), + keepdim=keepdims, + ) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py index 8a2587e41dd21..3c75a351c085d 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py @@ -12,6 +12,9 @@ from ivy_tests.test_ivy.test_functional.test_experimental.test_core.test_manipulation import ( # noqa E501 _get_dtype_values_k_axes_for_rot90, ) +from ivy_tests.test_ivy.test_functional.test_core.test_statistical import ( + _statistical_dtype_values, +) CLASS_TREE = "ivy.functional.frontends.paddle.Tensor" @@ -154,9 +157,13 @@ def test_paddle_instance_reshape( def _filter_query(query): return ( - query.ndim > 1 if isinstance(query, np.ndarray) else - not any(isinstance(i, np.ndarray) and i.ndim <= 1 for i in query) - if isinstance(query, tuple) else True + query.ndim > 1 + if isinstance(query, np.ndarray) + else ( + not any(isinstance(i, np.ndarray) and i.ndim <= 1 for i in query) + if isinstance(query, tuple) + else True + ) ) @@ -2510,3 +2517,42 @@ def test_paddle_cond( frontend=frontend, on_device=on_device, ) + + +# var +@handle_frontend_method( + class_tree=CLASS_TREE, + init_tree="paddle.to_tensor", + method_name="var", + dtype_and_x=_statistical_dtype_values( + function="var", + min_value=-1e04, + max_value=1e04, + ), + keepdim=st.booleans(), +) +def test_paddle_instance_var( + dtype_and_x, + keepdim, + frontend, + frontend_method_data, + init_flags, + method_flags, + on_device, +): + input_dtype, x, axis, correction = dtype_and_x + helpers.test_frontend_method( + init_input_dtypes=input_dtype, + init_all_as_kwargs_np={"data": x[0]}, + method_input_dtypes=input_dtype, + method_all_as_kwargs_np={ + "axis": axis, + "unbiased": bool(correction), + "keepdim": keepdim, + }, + frontend=frontend, + frontend_method_data=frontend_method_data, + init_flags=init_flags, + method_flags=method_flags, + on_device=on_device, + ) From 54536b0f10d289f3b24b08ddbda47eb3067e7a55 Mon Sep 17 00:00:00 2001 From: samunder singh <83540902+samthakur587@users.noreply.github.com> Date: Sat, 8 Jul 2023 21:19:30 +0530 Subject: [PATCH 08/13] Update tensor.py --- ivy/functional/frontends/paddle/tensor/tensor.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index 488c005060d8d..0322db956101a 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -523,12 +523,11 @@ def logical_not(self, out=None, name=None): @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def sign(self, name=None): - return ivy.sign(self._ivy_array) + return ivy.sign(self._ivy_array, np_variant=False) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def var(self, axis=None, *, unbiased=True, keepdim=False): return paddle_frontend.var(self, axis=axis, unbiased=unbiased, keepdim=keepdim) - return ivy.sign(self._ivy_array, np_variant=False) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def sgn(self, name=None): From 94535d3385d4fb7f7f518f907f5efac1a275440f Mon Sep 17 00:00:00 2001 From: samunder singh <83540902+samthakur587@users.noreply.github.com> Date: Sat, 15 Jul 2023 09:33:58 +0530 Subject: [PATCH 09/13] Update tensor.py --- ivy/functional/frontends/paddle/tensor/tensor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index 0322db956101a..fede69b59148d 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -525,7 +525,9 @@ def logical_not(self, out=None, name=None): def sign(self, name=None): return ivy.sign(self._ivy_array, np_variant=False) + @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") + def var(self, axis=None, *, unbiased=True, keepdim=False): return paddle_frontend.var(self, axis=axis, unbiased=unbiased, keepdim=keepdim) From c662a1c5256673632f78d4f63f136551a15b4bb6 Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Sat, 15 Jul 2023 10:06:56 +0530 Subject: [PATCH 10/13] solving the mereg conflit --- ivy/functional/frontends/paddle/tensor/tensor.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index fede69b59148d..4862b4e6a445b 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -525,10 +525,8 @@ def logical_not(self, out=None, name=None): def sign(self, name=None): return ivy.sign(self._ivy_array, np_variant=False) - @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") - - def var(self, axis=None, *, unbiased=True, keepdim=False): + def var(self, axis=None, unbiased=True, keepdim=False, name=None): return paddle_frontend.var(self, axis=axis, unbiased=unbiased, keepdim=keepdim) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") From 796b03e4c84b50b8513aa0f59b10b6641245448e Mon Sep 17 00:00:00 2001 From: Rishab Mallick Date: Thu, 20 Jul 2023 06:44:01 +0000 Subject: [PATCH 11/13] fix: updates supported dtyes and removes... redundant wrapping through stat.py --- .../frontends/paddle/tensor/stat.py | 6 ---- .../frontends/paddle/tensor/tensor.py | 10 ++++-- .../test_paddle/test_tensor/test_stat.py | 33 ------------------- 3 files changed, 8 insertions(+), 41 deletions(-) diff --git a/ivy/functional/frontends/paddle/tensor/stat.py b/ivy/functional/frontends/paddle/tensor/stat.py index 777ecbcb49cc2..255a96fdefcd6 100644 --- a/ivy/functional/frontends/paddle/tensor/stat.py +++ b/ivy/functional/frontends/paddle/tensor/stat.py @@ -45,9 +45,3 @@ def median(x, axis=None, keepdim=False, name=None): else ivy.astype(x, ivy.float32) ) return ivy.median(x, axis=axis, keepdims=keepdim) - - -@with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") -@to_ivy_arrays_and_back -def var(x, axis=None, unbiased=True, keepdim=False, *, out=None): - return ivy.var(x, axis=axis, correction=int(unbiased), keepdims=keepdim, out=out) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index bc409e1f8931b..99a18241ecc01 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -561,9 +561,15 @@ def logical_not(self, out=None, name=None): def sign(self, name=None): return paddle_frontend.Tensor(ivy.sign(self._ivy_array, np_variant=False)) - @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") + @with_supported_dtypes( + {"2.5.0 and below": ("float16", "float32", "float64")}, "paddle" + ) def var(self, axis=None, unbiased=True, keepdim=False, name=None): - return paddle_frontend.var(self, axis=axis, unbiased=unbiased, keepdim=keepdim) + return paddle_frontend.Tensor( + ivy.var( + self._ivy_array, axis=axis, correction=int(unbiased), keepdims=keepdim + ) + ) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def sgn(self, name=None): diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_stat.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_stat.py index 3d93566f02da7..74a3a8615ec18 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_stat.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_stat.py @@ -128,36 +128,3 @@ def test_paddle_median( axis=axis, keepdim=keepdim, ) - - -# var -@handle_frontend_test( - fn_tree="paddle.var", - dtype_and_x=_statistical_dtype_values( - function="var", - min_value=-1e04, - max_value=1e04, - ), - keepdims=st.booleans(), -) -def test_paddle_var( - *, - dtype_and_x, - keepdims, - on_device, - fn_tree, - frontend, - test_flags, -): - input_dtype, x, axis, correction = dtype_and_x - helpers.test_frontend_function( - input_dtypes=input_dtype, - frontend=frontend, - test_flags=test_flags, - fn_tree=fn_tree, - on_device=on_device, - x=x[0], - axis=axis, - unbiased=bool(correction), - keepdim=keepdims, - ) From fbc7e3f90b69116b55560e18581616f5d4583ebc Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Thu, 3 Aug 2023 13:13:00 +0530 Subject: [PATCH 12/13] changed dtype --- .../test_paddle/test_tensor/test_tensor.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py index 9c02f609fa19a..cd5378ceb3026 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py @@ -2711,23 +2711,19 @@ def test_paddle_cond( ) - # var @handle_frontend_method( class_tree=CLASS_TREE, init_tree="paddle.to_tensor", method_name="var", - dtype_and_x=_statistical_dtype_values( - function="var", - min_value=-1e04, - max_value=1e04, - ), + dtype_and_x=_statistical_dtype_values(function="var"), keepdim=st.booleans(), ) def test_paddle_instance_var( dtype_and_x, keepdim, frontend, + backend_fw, frontend_method_data, init_flags, method_flags, @@ -2746,10 +2742,12 @@ def test_paddle_instance_var( frontend=frontend, frontend_method_data=frontend_method_data, init_flags=init_flags, + backend_to_test=backend_fw, method_flags=method_flags, on_device=on_device, ) + @handle_frontend_method( class_tree=CLASS_TREE, init_tree="paddle.to_tensor", From b38f85b100c31174aa8b2ac6c317053fb3c6fef6 Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Tue, 8 Aug 2023 15:43:15 +0530 Subject: [PATCH 13/13] changes the dtype --- ivy/functional/frontends/paddle/tensor/tensor.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index a8dcb9d087e37..3041b046b78c2 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -577,9 +577,7 @@ def logical_not(self, out=None, name=None): def sign(self, name=None): return ivy.sign(self._ivy_array) - @with_supported_dtypes( - {"2.5.1 and below": ("float16", "float32", "float64")}, "paddle" - ) + @with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle") def var(self, axis=None, unbiased=True, keepdim=False, name=None): return paddle_frontend.Tensor( ivy.var(