diff --git a/ivy/functional/frontends/paddle/tensor/stat.py b/ivy/functional/frontends/paddle/tensor/stat.py index 48c94b2fb583c..a97120e4e3d12 100644 --- a/ivy/functional/frontends/paddle/tensor/stat.py +++ b/ivy/functional/frontends/paddle/tensor/stat.py @@ -47,6 +47,16 @@ def median(x, axis=None, keepdim=False, name=None): return ivy.median(x, axis=axis, keepdims=keepdim) +@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle") +@to_ivy_arrays_and_back +def var(x, axis=None, unbiased=True, keepdim=False, name=None): + if unbiased: + correction = 1 + else: + correction = 0 + return ivy.var(x, axis=axis, correction=correction, keepdims=keepdim) + + @with_supported_dtypes( {"2.5.0 and below": ("float16", "float32", "float64", "uint16")}, "paddle", 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 411bf24362b67..f3c4fa485b3ca 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 @@ -133,6 +133,37 @@ def test_paddle_median( ) +# var +@handle_frontend_test( + fn_tree="paddle.var", + dtype_and_x=_statistical_dtype_values(function="var"), + unbiased=st.booleans(), + keepdim=st.booleans(), +) +def test_paddle_var( + *, + unbiased, + dtype_and_x, + keepdim, + fn_tree, + frontend, + backend_fw, + test_flags, +): + input_dtype, x, axis, _ = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtype, + backend_to_test=backend_fw, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + x=x[0], + axis=axis, + unbiased=unbiased, + keepdim=keepdim, + ) + + @handle_frontend_test( fn_tree="paddle.nanmedian", dtype_x_and_axis=helpers.dtype_values_axis(