Skip to content

Commit 3c657c1

Browse files
79088371747908837174
andauthored
feat: add subtract_ function to paddle frontend math module (#28929)
Co-authored-by: 7908837174 <[email protected]>
1 parent 1940b51 commit 3c657c1

File tree

2 files changed

+41
-0
lines changed
  • ivy_tests/test_ivy/test_frontends/test_paddle
  • ivy/functional/frontends/paddle

2 files changed

+41
-0
lines changed

ivy/functional/frontends/paddle/math.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,12 @@ def subtract(x, y, name=None):
639639
return ivy.subtract(x, y)
640640

641641

642+
@with_unsupported_dtypes({"2.6.0 and below": ("float16", "bfloat16")}, "paddle")
643+
@to_ivy_arrays_and_back
644+
def subtract_(x, y, name=None):
645+
return ivy.inplace_update(x, subtract(x, y))
646+
647+
642648
@with_supported_dtypes(
643649
{
644650
"2.6.0 and below": (

ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,6 +2570,41 @@ def test_paddle_subtract(
25702570
)
25712571

25722572

2573+
# subtract_
2574+
@handle_frontend_test(
2575+
fn_tree="paddle.subtract_",
2576+
dtype_and_x=helpers.dtype_and_values(
2577+
available_dtypes=helpers.get_dtypes("float"),
2578+
num_arrays=2,
2579+
allow_inf=False,
2580+
large_abs_safety_factor=2,
2581+
small_abs_safety_factor=2,
2582+
safety_factor_scale="log",
2583+
shared_dtype=True,
2584+
),
2585+
)
2586+
def test_paddle_subtract_(
2587+
*,
2588+
dtype_and_x,
2589+
on_device,
2590+
fn_tree,
2591+
frontend,
2592+
test_flags,
2593+
backend_fw,
2594+
):
2595+
input_dtype, x = dtype_and_x
2596+
helpers.test_frontend_function(
2597+
input_dtypes=input_dtype,
2598+
backend_to_test=backend_fw,
2599+
frontend=frontend,
2600+
fn_tree=fn_tree,
2601+
test_flags=test_flags,
2602+
on_device=on_device,
2603+
x=x[0],
2604+
y=x[1],
2605+
)
2606+
2607+
25732608
@handle_frontend_test(
25742609
fn_tree="paddle.sum",
25752610
dtype_and_x=helpers.dtype_and_values(

0 commit comments

Comments
 (0)