Skip to content

Commit

Permalink
frontend paddle irfftn
Browse files Browse the repository at this point in the history
  • Loading branch information
xingshuodong committed Sep 3, 2023
1 parent ea17de0 commit 93be5d7
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .vs/ivy/v17/.wsuo
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
21 changes: 21 additions & 0 deletions ivy/functional/frontends/paddle/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,24 @@ def irfft(x, n=None, axis=-1.0, norm="backward", name=None):
if ivy.isreal(x):
time_domain = ivy.real(time_domain)
return time_domain


@with_supported_dtypes(
{"2.5.1 and below": ("complex64", "complex128")},
"paddle",
)
@to_ivy_arrays_and_back
def irfftn(x, s=None, axes=None, norm="backward", name=None):
shape = x.shape
ndim = len(shape)
if s is None:
s = [2 * (dim - 1) for dim in shape]
else:
s = list(s)
if axes is None:
axes = list(range(ndim))
else:
axes = list(axes)
result = ivy.irfft(x, s=s, axes=axes, norm=norm)

return result
45 changes: 45 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_paddle/test_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ivy_tests.test_ivy.helpers import handle_frontend_test



@handle_frontend_test(
fn_tree="paddle.fft.fft",
dtype_x_axis=helpers.dtype_values_axis(
Expand Down Expand Up @@ -220,3 +221,47 @@ def test_paddle_irfft(
valid_axis=True,
force_int_axis=True,
)





@handle_frontend_test(
fn_tree="paddle.fft.irfftn",
dtype_x_axis=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("valid"),
min_value=-10,
max_value=10,
min_num_dims=1,
min_dim_size=2,
valid_axis=True,
force_int_axis=True,
),
s=st.lists(st.integers(min_value=2, max_value=10), min_size=2, max_size=3),
axes=st.lists(st.integers(min_value=0), min_size=1, max_size=2),
norm=st.sampled_from(["backward", "ortho", "forward"]),
)
def test_paddle_irfftn(
dtype_x_axis,
s,
axes,
norm,
frontend,
backend_fw,
test_flags,
fn_tree,
):
input_dtypes, x, _ = dtype_x_axis

# Perform the irfftn using the frontend function
frontend_result, _ = helpers.test_frontend_function(
input_dtypes=input_dtypes,
frontend=frontend,
backend_to_test=backend_fw,
test_flags=test_flags,
fn_tree=fn_tree,
x=x[0],
s=s,
axes=axes,
norm=norm,
)

0 comments on commit 93be5d7

Please sign in to comment.