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

add fft2 function to paddlepaddle frontend! #19058

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
8 changes: 8 additions & 0 deletions ivy/functional/frontends/paddle/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ def fftshift(x, axes=None, name=None):
roll = ivy.roll(x, shifts, axis=axes)

return roll
@with_supported_dtypes(
{"2.5.0 and below": ("complex64", "complex128")},
"paddle",
)
@to_ivy_arrays_and_back
def fft2(x, n=None, axes=(- 2, - 1), norm='backward', name=None):
ret = ivy.fft2(ivy.astype(x, "complex128"), axes, norm=norm, n=n)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have any specific reason for converting to complex128, let me know. Also ivy.fft2 doesn't take n as an argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bipinKrishnan I have updated the function there is no specific reason for implementing the complex128. please do let me know if other changes are required.

Copy link
Contributor

@bipinKrishnan bipinKrishnan Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, can you remove these type casting to avoid overheads? Also please make the other change about n argument that I mentioned in the comment above.

return ivy.astype(ret, x.dtype)
36 changes: 36 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_paddle/test_paddle_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,39 @@ def test_paddle_fttshift(dtype_x_axis, frontend, test_flags, fn_tree, on_device)
x=x[0],
axes=axes,
)
@handle_frontend_test(
fn_tree="paddle.fft.fft2",
dtype_x_axis=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("valid"),
min_value=-10,
max_value=10,
min_num_dims=2,
min_dim_size=2,
valid_axis=True,
force_int_axis=True,
),
n=st.one_of(
st.integers(min_value=2, max_value=10),
st.just(None),
),
norm=st.sampled_from(["backward", "ortho", "forward"]),
)
def test_paddle_fft2(
dtype_x_axis,
n,
norm,
frontend,
test_flags,
fn_tree,
):
input_dtypes, x, axes = dtype_x_axis
helpers.test_frontend_function(
input_dtypes=input_dtypes,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
x=x[0],
n=n,
axes=axes,
norm=norm,
)