Skip to content

Commit

Permalink
P var (ivy-llc#18995)
Browse files Browse the repository at this point in the history
Co-authored-by: Rishab Mallick <rishabmallick6@gmail.com>
  • Loading branch information
2 people authored and sushmanthreddy committed Aug 17, 2023
1 parent b8a1282 commit 0915413
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ivy/functional/frontends/paddle/tensor/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,14 @@ 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": ("float32", "float64")}, "paddle")
def var(self, axis=None, unbiased=True, keepdim=False, name=None):
return paddle_frontend.Tensor(
ivy.var(
self._ivy_array, axis=axis, correction=int(unbiased), keepdims=keepdim
)
)

@with_unsupported_dtypes({"2.5.1 and below": ("float16", "bfloat16")}, "paddle")
def sgn(self, name=None):
return paddle_frontend.Tensor(ivy.sign(self._ivy_array, np_variant=True))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -2689,6 +2692,43 @@ def test_paddle_tensor_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"),
keepdim=st.booleans(),
)
def test_paddle_instance_var(
dtype_and_x,
keepdim,
frontend,
backend_fw,
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,
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",
Expand Down

0 comments on commit 0915413

Please sign in to comment.