diff --git a/ivy/functional/frontends/paddle/math.py b/ivy/functional/frontends/paddle/math.py index 252d8f1be9c93..0d39c1639534c 100644 --- a/ivy/functional/frontends/paddle/math.py +++ b/ivy/functional/frontends/paddle/math.py @@ -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): diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index 059b777c6c4b7..33e287d5e8477 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -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): diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py index c93967b71cf46..0886cbf6233ca 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py @@ -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", diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py index bb38c75a90680..c40ddf57e1b4e 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py @@ -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, @@ -5902,6 +5917,7 @@ def test_paddle_tensor_matmul( def test_paddle_tensor_squeeze( dtype_value, axis, + frontend_method_data, init_flags, method_flags, @@ -5909,6 +5925,16 @@ def test_paddle_tensor_squeeze( 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, @@ -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,