Skip to content

Commit

Permalink
added paddle frontend var (#20932)
Browse files Browse the repository at this point in the history
Co-authored-by: hirwa-nshuti <[email protected]>
  • Loading branch information
Aml-Hassan-Abd-El-hamid and fnhirwa authored Aug 16, 2023
1 parent bc23efe commit ee24083
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ivy/functional/frontends/paddle/tensor/stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ee24083

Please sign in to comment.