Skip to content

Commit

Permalink
added paddle.sum frontend and test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
sabre-code authored Aug 30, 2023
1 parent b774e26 commit a35f9de
Show file tree
Hide file tree
Showing 2 changed files with 40 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 @@ -476,6 +476,17 @@ def subtract(x, y, name=None):
return ivy.subtract(x, y)


@with_supported_dtypes(
{"2.5.1 and below": ("bool", "int32", "int64", "float32", "float64")}, "paddle"
)
@to_ivy_arrays_and_back
def sum(x, axis=None, keepdim=False, name=None):
if x.dtype == ivy.int32:
arr = ivy.sum(x)
return arr.astype(ivy.int64)
return ivy.sum(x)


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


# sum
@handle_frontend_test(
fn_tree="paddle.sum",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
num_arrays=1,
),
)
def test_paddle_sum(
*,
dtype_and_x,
on_device,
fn_tree,
frontend,
backend_fw,
test_flags,
):
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],
)


# take
@handle_frontend_test(
fn_tree="paddle.take", dtype_and_values=_test_paddle_take_helper()
Expand Down

0 comments on commit a35f9de

Please sign in to comment.