Skip to content

Commit

Permalink
added tanh_ function to paddle frontend and test (ivy-llc#23176)
Browse files Browse the repository at this point in the history
  • Loading branch information
chitooNA authored and druvdub committed Oct 14, 2023
1 parent 77112f7 commit b68ea76
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
6 changes: 5 additions & 1 deletion ivy/functional/frontends/paddle/tensor/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ def rsqrt_(x, name=None):
def sqrt_(x, name=None):
return ivy.inplace_update(x, sqrt(x))


@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
@to_ivy_arrays_and_back
def subtract_(x, y, name=None):
return ivy.inplace_update(x, subtract(x, y))

@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
@to_ivy_arrays_and_back
def tanh_(x, name=None):
return ivy.inplace_update(x, tanh(x))
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ def test_paddle_rsqrt_(
x=x[0],
)


# sqrt_
@handle_frontend_test(
fn_tree="paddle.tensor.math.sqrt_",
Expand All @@ -206,8 +205,6 @@ def test_paddle_sqrt_(
on_device=on_device,
x=x[0],
)


# subtract_
@handle_frontend_test(
fn_tree="paddle.tensor.math.subtract_",
Expand Down Expand Up @@ -241,3 +238,31 @@ def test_paddle_subtract_(
x=x[0],
y=x[1],
)

#tanh_
@handle_frontend_test(
fn_tree="paddle.tensor.math.tanh_",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
),
)
def test_paddle_tanh_(
*,
dtype_and_x,
on_device,
fn_tree,
frontend,
test_flags,
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,
atol=1e-2,
x=x[0],
)

0 comments on commit b68ea76

Please sign in to comment.