From 310b1873863ca08909293314420c7c78eff3f805 Mon Sep 17 00:00:00 2001 From: Jaskirat Singh Date: Wed, 13 Sep 2023 21:38:21 +0530 Subject: [PATCH 1/7] Updated stat.py by adding quantile function --- ivy/functional/frontends/paddle/stat.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ivy/functional/frontends/paddle/stat.py b/ivy/functional/frontends/paddle/stat.py index 91b69d7441091..990fac8d4854d 100644 --- a/ivy/functional/frontends/paddle/stat.py +++ b/ivy/functional/frontends/paddle/stat.py @@ -74,3 +74,8 @@ def var(x, axis=None, unbiased=True, keepdim=False, name=None): else: correction = 0 return ivy.var(x, axis=axis, correction=correction, keepdims=keepdim) + +@with_supported_dtypes({"2.5.1 and below": ("float32", "float64", "int32", "int64")},"paddle",) +@to_ivy_arrays_and_back +def quantile(x, q, axis=None, keepdim=False): + return ivy.quantile(x, q, axis=axis, keepdims=keepdim) From 17aca2cb4a1cd24267e2277d9eaf8b37f63527b1 Mon Sep 17 00:00:00 2001 From: Jaskirat Singh Date: Wed, 13 Sep 2023 21:46:05 +0530 Subject: [PATCH 2/7] Update test_tensor.py --- .../test_paddle/test_tensor/test_tensor.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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 b934bca73234c..5ef38d20e56ee 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 @@ -3693,3 +3693,35 @@ def test_paddle_tensor_zero_( frontend=frontend, on_device=on_device, ) + +# quantile +@handle_frontend_test( + fn_tree="paddle.quantile", + dtype_and_x=_statistical_dtype_values(function="quantile"), + q=st.floats(0.0, 1.0), + keepdim=st.booleans(), +) +def test_paddle_quantile( + *, + dtype_and_x, + q, + keepdim, + on_device, + fn_tree, + frontend, + backend_fw, + test_flags, +): + input_dtypes, x, axis = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtypes, + frontend=frontend, + backend_to_test=backend_fw, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + x=x[0], + q=q, + axis=axis, + keepdim=keepdim, + ) From 16fe5cdc4f39aca0f8b80fe630ce6c978fd3b578 Mon Sep 17 00:00:00 2001 From: Jaskirat Singh Date: Wed, 13 Sep 2023 23:02:59 +0530 Subject: [PATCH 3/7] Update stat.py --- ivy/functional/frontends/paddle/stat.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ivy/functional/frontends/paddle/stat.py b/ivy/functional/frontends/paddle/stat.py index 990fac8d4854d..1a988ba9ee747 100644 --- a/ivy/functional/frontends/paddle/stat.py +++ b/ivy/functional/frontends/paddle/stat.py @@ -65,6 +65,14 @@ def std(x, axis=None, unbiased=True, keepdim=False, name=None): ) return ivy.std(x, axis=axis, correction=int(unbiased), keepdims=keepdim) +@with_supported_dtypes( + {"2.5.1 and below": ("float32", "float64", "int32", "int64")}, + "paddle", +) +@to_ivy_arrays_and_back +def quantile(x, q, axis=None, keepdim=False): + return ivy.quantile(x, q, axis=axis, keepdims=keepdim) + @with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle") @to_ivy_arrays_and_back @@ -74,8 +82,3 @@ def var(x, axis=None, unbiased=True, keepdim=False, name=None): else: correction = 0 return ivy.var(x, axis=axis, correction=correction, keepdims=keepdim) - -@with_supported_dtypes({"2.5.1 and below": ("float32", "float64", "int32", "int64")},"paddle",) -@to_ivy_arrays_and_back -def quantile(x, q, axis=None, keepdim=False): - return ivy.quantile(x, q, axis=axis, keepdims=keepdim) From 3428c4e607572813481111ec8cce4ae1734795d5 Mon Sep 17 00:00:00 2001 From: Jaskirat Singh Date: Wed, 13 Sep 2023 23:06:52 +0530 Subject: [PATCH 4/7] Update test_tensor.py --- .../test_paddle/test_tensor/test_tensor.py | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 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 5ef38d20e56ee..36aa524215f60 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 @@ -387,6 +387,38 @@ def test_paddle_is_floating_point( on_device=on_device, ) +# quantile +@handle_frontend_method( + fn_tree="paddle.quantile", + dtype_and_x=_statistical_dtype_values(function="quantile"), + q=st.floats(0.0, 1.0), + keepdim=st.booleans(), +) +def test_paddle_quantile( + *, + dtype_and_x, + q, + keepdim, + on_device, + fn_tree, + frontend, + backend_fw, + test_flags, +): + input_dtypes, x, axis = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtypes, + frontend=frontend, + backend_to_test=backend_fw, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + x=x[0], + q=q, + axis=axis, + keepdim=keepdim, + ) + # abs @handle_frontend_method( @@ -3693,35 +3725,3 @@ def test_paddle_tensor_zero_( frontend=frontend, on_device=on_device, ) - -# quantile -@handle_frontend_test( - fn_tree="paddle.quantile", - dtype_and_x=_statistical_dtype_values(function="quantile"), - q=st.floats(0.0, 1.0), - keepdim=st.booleans(), -) -def test_paddle_quantile( - *, - dtype_and_x, - q, - keepdim, - on_device, - fn_tree, - frontend, - backend_fw, - test_flags, -): - input_dtypes, x, axis = dtype_and_x - helpers.test_frontend_function( - input_dtypes=input_dtypes, - frontend=frontend, - backend_to_test=backend_fw, - test_flags=test_flags, - fn_tree=fn_tree, - on_device=on_device, - x=x[0], - q=q, - axis=axis, - keepdim=keepdim, - ) From 0d37339daa5f07089788a491ebe2c2a6598daa3a Mon Sep 17 00:00:00 2001 From: Jaskirat Singh Date: Wed, 13 Sep 2023 23:10:17 +0530 Subject: [PATCH 5/7] Updated stat.py --- ivy/functional/frontends/paddle/stat.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ivy/functional/frontends/paddle/stat.py b/ivy/functional/frontends/paddle/stat.py index 1a988ba9ee747..2529b7ea85e78 100644 --- a/ivy/functional/frontends/paddle/stat.py +++ b/ivy/functional/frontends/paddle/stat.py @@ -51,6 +51,14 @@ def numel(x, name=None): length = 1 # if 0 dimensional tensor with 1 element return ivy.array(prod if prod > 0 else ivy.array(length, dtype=ivy.int64)) +@with_supported_dtypes( + {"2.5.1 and below": ("float32", "float64", "int32", "int64")}, + "paddle", +) +@to_ivy_arrays_and_back +def quantile(x, q, axis=None, keepdim=False): + return ivy.quantile(x, q, axis=axis, keepdims=keepdim) + @with_supported_dtypes( {"2.5.1 and below": ("float32", "float64", "uint16")}, @@ -65,14 +73,6 @@ def std(x, axis=None, unbiased=True, keepdim=False, name=None): ) return ivy.std(x, axis=axis, correction=int(unbiased), keepdims=keepdim) -@with_supported_dtypes( - {"2.5.1 and below": ("float32", "float64", "int32", "int64")}, - "paddle", -) -@to_ivy_arrays_and_back -def quantile(x, q, axis=None, keepdim=False): - return ivy.quantile(x, q, axis=axis, keepdims=keepdim) - @with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle") @to_ivy_arrays_and_back From 152ba7e4462bd2fd96cb1346853eccd14c1c6002 Mon Sep 17 00:00:00 2001 From: Jaskirat Singh Date: Wed, 13 Sep 2023 23:21:13 +0530 Subject: [PATCH 6/7] Updated test_tensor.py --- .../test_frontends/test_paddle/test_tensor/test_tensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 36aa524215f60..31009a51f5476 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 @@ -389,7 +389,7 @@ def test_paddle_is_floating_point( # quantile @handle_frontend_method( - fn_tree="paddle.quantile", + init_tree="paddle.to_tensor", dtype_and_x=_statistical_dtype_values(function="quantile"), q=st.floats(0.0, 1.0), keepdim=st.booleans(), From 527955322cd232ec63765745cda111c69c9634b1 Mon Sep 17 00:00:00 2001 From: Jaskirat Singh Date: Wed, 13 Sep 2023 23:25:21 +0530 Subject: [PATCH 7/7] Update test_tensor.py --- .../test_frontends/test_paddle/test_tensor/test_tensor.py | 1 + 1 file changed, 1 insertion(+) 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 31009a51f5476..a1b4deaa33933 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 @@ -389,6 +389,7 @@ def test_paddle_is_floating_point( # quantile @handle_frontend_method( + class_tree=CLASS_TREE, init_tree="paddle.to_tensor", dtype_and_x=_statistical_dtype_values(function="quantile"), q=st.floats(0.0, 1.0),