Skip to content

Commit

Permalink
increment
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadhammad-tech authored Oct 17, 2023
1 parent 34b2da0 commit 73f70ee
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ivy/functional/frontends/paddle/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,18 @@ def heaviside(x, y, name=None):
return ivy.heaviside(x, y)


@with_supported_dtypes(
{"2.5.1 and below": ("int32", "int64", "float32", "float64")}, "paddle"
)
@to_ivy_arrays_and_back
def increment(x, value=1.0, name=None):
if (
ivy.prod(ivy.shape(x)) != 1
): # TODO this function will be simplified as soon as ivy.increment is add
raise ValueError("The input tensor x must contain only one element.")
return ivy.add(x, value)


@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
@to_ivy_arrays_and_back
def inner(x, y, name=None):
Expand Down
30 changes: 30 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,36 @@ def test_paddle_heaviside(
)


# increment
@handle_frontend_test(
fn_tree="paddle.increment",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
num_arrays=1,
shape=(1,),
),
)
def test_paddle_increment(
*,
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],
)


# inner
@handle_frontend_test(
fn_tree="paddle.inner",
Expand Down

0 comments on commit 73f70ee

Please sign in to comment.