Skip to content

Commit

Permalink
Add subtract_ to paddle frontend
Browse files Browse the repository at this point in the history
Co-authored-by: Anwaar Khalid <[email protected]>
  • Loading branch information
Guilhermeslucas and hello-fri-end authored Sep 14, 2023
1 parent 18cc469 commit 4153e78
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ivy/functional/frontends/paddle/tensor/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ def rsqrt_(x, name=None):
@to_ivy_arrays_and_back
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))
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,38 @@ def test_paddle_sqrt_(
on_device=on_device,
x=x[0],
)


# subtract_
@handle_frontend_test(
fn_tree="paddle.tensor.math.subtract_",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
num_arrays=2,
allow_inf=False,
large_abs_safety_factor=2,
small_abs_safety_factor=2,
safety_factor_scale="log",
shared_dtype=True,
),
)
def test_paddle_subtract_(
*,
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,
fn_tree=fn_tree,
test_flags=test_flags,
on_device=on_device,
x=x[0],
y=x[1],
)

0 comments on commit 4153e78

Please sign in to comment.