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: added ifft2 #23588

Merged
merged 5 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 7 additions & 0 deletions ivy/functional/frontends/jax/numpy/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ def ifft(a, n=None, axis=-1, norm=None):
if norm is None:
norm = "backward"
return ivy.ifft(a, axis, norm=norm, n=n)


@to_ivy_arrays_and_back
def ifft2(a, s=None, axes=(-2, -1), norm=None):
if norm is None:
norm = "backward"
return ivy.array(ivy.ifft2(a, s=s, dim=axes, norm=norm), dtype=ivy.dtype(a))
51 changes: 51 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_jax/test_numpy/test_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,54 @@ def test_jax_numpy_ifft(
atol=1e-02,
rtol=1e-02,
)


# ifft2
@handle_frontend_test(
fn_tree="jax.numpy.fft.ifft2",
dtype_values=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("complex"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
available_dtypes=helpers.get_dtypes("complex"),
available_dtypes=helpers.get_dtypes("valid"),

This should always be valid - if only complex data-type is supported by the function then that's what valid will return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should always be valid - if only complex data-type is supported by the function then that's what valid will return.

Dear @hello-fri-end, just changed it to valid. Any other comments?

num_arrays=1,
min_value=-1e5,
max_value=1e5,
min_num_dims=2,
max_num_dims=5,
min_dim_size=2,
max_dim_size=5,
allow_inf=False,
large_abs_safety_factor=2.5,
small_abs_safety_factor=2.5,
safety_factor_scale="log",
),
axes=st.sampled_from([(0, 1), (-1, -2), (1, 0)]),
s=st.tuples(
st.integers(min_value=2, max_value=256), st.integers(min_value=2, max_value=256)
),
norm=st.sampled_from(["backward", "ortho", "forward", None]),
)
def test_jax_numpy_ifft2(
dtype_values,
s,
axes,
norm,
frontend,
backend_fw,
test_flags,
fn_tree,
on_device,
):
dtype, values = dtype_values
helpers.test_frontend_function(
input_dtypes=dtype,
frontend=frontend,
backend_to_test=backend_fw,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
a=values[0],
s=s,
axes=axes,
norm=norm,
atol=1e-02,
rtol=1e-02,
)
Loading