Skip to content

Commit

Permalink
added round inplace function (ivy-llc#22275)
Browse files Browse the repository at this point in the history
Co-authored-by: sherry30 <sherrytst30@gmail.com>
  • Loading branch information
ArsalanAli915 and sherry30 authored Aug 23, 2023
1 parent 57f92f3 commit 9878ab8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ivy/functional/frontends/paddle/tensor/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ def round(x, name=None):
return ivy.round(x)


@with_unsupported_dtypes({"2.5.1 and below": ("float16", "bfloat16")}, "paddle")
@to_ivy_arrays_and_back
def round_(x, name=None):
return ivy.inplace_update(x, round(x))


@with_unsupported_dtypes({"2.5.1 and below": ("float16", "bfloat16")}, "paddle")
@to_ivy_arrays_and_back
def ceil(x, name=None):
Expand Down Expand Up @@ -400,6 +406,11 @@ def rsqrt(x, name=None):
return 1 / ivy.sqrt(x)


@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
def rsqrt_(x, name=None):
return ivy.inplace_update(x, ivy.reciprocal(ivy.inplace_update(x, ivy.sqrt(x))))


@with_supported_dtypes(
{"2.5.1 and below": ("float32", "float64", "int32", "int64")}, "paddle"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,35 @@ def test_paddle_round(
)


# round_
@handle_frontend_test(
fn_tree="paddle.tensor.math.round_",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
min_value=1,
),
)
def test_paddle_round_(
*,
dtype_and_x,
frontend,
test_flags,
fn_tree,
backend_fw,
on_device,
):
input_dtype, x = 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,
on_device=on_device,
x=x[0],
)


# ceil
@handle_frontend_test(
fn_tree="paddle.tensor.math.ceil",
Expand Down Expand Up @@ -1748,6 +1777,34 @@ def test_paddle_rsqrt(
)


# rsqrt_
@handle_frontend_test(
fn_tree="paddle.tensor.math.rsqrt_",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
),
)
def test_paddle_rsqrt_(
*,
dtype_and_x,
frontend,
test_flags,
fn_tree,
on_device,
backend_fw,
):
input_dtype, x = 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,
on_device=on_device,
x=x[0],
)


# prod
@handle_frontend_test(
fn_tree="paddle.tensor.math.prod",
Expand Down

0 comments on commit 9878ab8

Please sign in to comment.