diff --git a/ivy/functional/frontends/paddle/fft.py b/ivy/functional/frontends/paddle/fft.py index 5ea418f5153e6..c25b9d9a3aed3 100644 --- a/ivy/functional/frontends/paddle/fft.py +++ b/ivy/functional/frontends/paddle/fft.py @@ -357,3 +357,22 @@ def rfftfreq(n, d=1.0, dtype=None, name=None): pos_max = n // 2 + 1 indices = ivy.arange(0, pos_max, dtype=dtype) return indices * val + + +@with_supported_dtypes( + { + "2.5.2 and below": ( + "int32", + "int64", + "float32", + "float64", + ) + }, + "paddle", +) +@to_ivy_arrays_and_back +def rfftn(x, s=None, axes=None, norm="backward", name=None): + """Compute the N-dimensional discrete Fourier Transform over any number of axes in + an M-dimensional real array by means of the Fast Fourier Transform (FFT).""" + x = ivy.asarray(x, dtype=ivy.complex128) + return ivy.rfftn(x, s=s, axes=axes, norm=norm) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_fft.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_fft.py index 125e5d0857eb2..ba54bb0ac3c01 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_fft.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_fft.py @@ -6,6 +6,7 @@ from ivy_tests.test_ivy.helpers import handle_frontend_test from ivy_tests.test_ivy.test_functional.test_experimental.test_nn.test_layers import ( _x_and_ifftn, + _x_and_rfftn, ) @@ -612,6 +613,29 @@ def test_paddle_rfftfreq( ) +@handle_frontend_test( + fn_tree="paddle.fft.rfftn", + dtype_and_x=_x_and_rfftn(), +) +def test_paddle_rfftn( + dtype_and_x, frontend, backend_fw, test_flags, fn_tree, on_device +): + dtype, x, s, axes, norm = dtype_and_x + helpers.test_frontend_function( + input_dtypes=dtype, + backend_to_test=backend_fw, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + test_values=True, + x=x, + s=s, + axes=axes, + norm=norm, + ) + + # Use the custom strategy for s and axes axes_strategy = sequence_of_two_integers() s_strategy = sequence_of_two_integers()