Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add increment method to paddle frontend #27063

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
065255b
increment
muhammadhammad-tech Sep 29, 2023
3e06fd9
🤖 Lint code
ivy-branch Sep 29, 2023
12fe141
Merge branch 'main' into muhammadhammad-tech/issue26215
muhammadhammad-tech Sep 29, 2023
9bd4073
🤖 Lint code
ivy-branch Sep 29, 2023
24673d0
increment
muhammadhammad-tech Sep 30, 2023
ccea7f1
🤖 Lint code
ivy-branch Sep 30, 2023
4227ee0
revert changes
muhammadhammad-tech Oct 3, 2023
55d9d35
🤖 Lint code
ivy-branch Oct 3, 2023
bd6225b
resolve conflict
muhammadhammad-tech Oct 3, 2023
bb5ce81
changes made to test_mathh.py reverted
muhammadhammad-tech Oct 3, 2023
308dbdc
resolve conflict
muhammadhammad-tech Oct 3, 2023
7086f94
increment
muhammadhammad-tech Oct 5, 2023
51ad1b6
increment
muhammadhammad-tech Oct 5, 2023
b4de28e
🤖 Lint code
ivy-branch Oct 5, 2023
65084dc
Merge branch 'main' into muhammadhammad-tech/issue26215
muhammadhammad-tech Oct 5, 2023
0826f37
docs/demos
muhammadhammad-tech Oct 7, 2023
34b2da0
demo/docs resolve
muhammadhammad-tech Oct 9, 2023
73f70ee
increment
muhammadhammad-tech Oct 17, 2023
99a9573
Merge branch 'muhammadhammad-tech/issue26215' of https://github.com/m…
muhammadhammad-tech Oct 17, 2023
492cfd8
docs/demo conflict
muhammadhammad-tech Oct 17, 2023
280be68
demos
muhammadhammad-tech Oct 17, 2023
e2422aa
Revert "demos"
muhammadhammad-tech Oct 22, 2023
7b4a8cd
Revert "docs/demo conflict"
muhammadhammad-tech Oct 22, 2023
b70a6c8
Revert "increment"
muhammadhammad-tech Oct 22, 2023
2553134
Revert "demo/docs resolve"
muhammadhammad-tech Oct 22, 2023
69f35ab
Revert "docs/demos"
muhammadhammad-tech Oct 22, 2023
a16b64c
Revert "increment"
muhammadhammad-tech Oct 22, 2023
efb8544
Revert "resolve conflict"
muhammadhammad-tech Oct 22, 2023
a155c3f
reverted back to orginal dont conatin increment
muhammadhammad-tech Oct 22, 2023
9300e8a
increment
muhammadhammad-tech Oct 22, 2023
c78d469
Merge branch 'main' into muhammadhammad-tech/issue26215
muhammadhammad-tech Oct 24, 2023
628f2e2
🤖 Lint code
ivy-branch Oct 24, 2023
88b22d6
Merge branch 'main' into muhammadhammad-tech/issue26215
muhammadhammad-tech Oct 25, 2023
e20f6e8
🤖 Lint code
ivy-branch Oct 25, 2023
144d94a
Merge branch 'main' into muhammadhammad-tech/issue26215
muhammadhammad-tech Nov 1, 2023
4c89389
🤖 Lint code
ivy-branch Nov 1, 2023
2354570
increment fixies conflict resolved
muhammadhammad-tech Nov 3, 2023
5339a27
Merge branch 'main' into muhammadhammad-tech/issue26215
muhammadhammad-tech Dec 29, 2023
39ae2e1
Merge branch 'main' into muhammadhammad-tech/issue26215
muhammadhammad-tech Jan 21, 2024
be76383
🤖 Lint code
ivy-branch Jan 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ivy/functional/frontends/paddle/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,19 @@ 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.2 and below": ("float32", "float64")}, "paddle")
@with_supported_dtypes({"2.6.0 and below": ("float32", "float64")}, "paddle")
@to_ivy_arrays_and_back
def inner(x, y, name=None):
Expand Down
9 changes: 9 additions & 0 deletions ivy/functional/frontends/paddle/tensor/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,15 @@ def gather_(self, y, name=None):
return ivy.inplace_update(self, res)

@with_supported_dtypes(

{"2.5.1 and below": ("int32", "int64", "float32", "float64")}, "paddle"
)
def increment(self, value, name=None):
return paddle_frontend.increment(self, value)

@with_supported_dtypes(
{"2.5.1 and below": ("bool", "int32", "int64", "float32", "float64")}, "paddle"

{"2.6.0 and below": ("float32", "float64", "int32", "int64")}, "paddle"
)
def heaviside(self, 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 @@ -1291,6 +1291,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
Original file line number Diff line number Diff line change
Expand Up @@ -5846,6 +5846,21 @@ def test_paddle_tensor_heaviside(
)



# increment
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="paddle.to_tensor",
method_name="increment",
dtypes_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
num_arrays=1,
shape=(1,),
),
)
def test_paddle_tensor_increment(
dtypes_and_x,

# matmul
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down Expand Up @@ -5902,13 +5917,24 @@ def test_paddle_tensor_matmul(
def test_paddle_tensor_squeeze(
dtype_value,
axis,

frontend_method_data,
init_flags,
method_flags,
frontend,
on_device,
backend_fw,
):

input_dtype, x = dtypes_and_x
value = 5.0 # example value to increment
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
backend_to_test=backend_fw,
init_all_as_kwargs_np={"data": x[0]},
method_input_dtypes=input_dtype,
method_all_as_kwargs_np={"value": value},

input_dtype, x = dtype_value
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
Expand All @@ -5920,6 +5946,7 @@ def test_paddle_tensor_squeeze(
method_all_as_kwargs_np={
"axis": axis,
},

frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
Expand Down
Loading