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 : Implemented ifftshift and test #23882

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
49b8271
added ifftshift and test
VaishnaviMudaliar Sep 18, 2023
d407a33
Merge branch 'main' into ifftshift
VaishnaviMudaliar Sep 24, 2023
ecdf41f
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Sep 25, 2023
5778d39
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Sep 26, 2023
5146d28
🤖 Lint code
ivy-branch Sep 26, 2023
5728e55
added the missing code
VaishnaviMudaliar Sep 26, 2023
a02b553
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Sep 30, 2023
e8bc76f
deleted the unwanted code
VaishnaviMudaliar Sep 30, 2023
20663ae
🤖 Lint code
ivy-branch Sep 30, 2023
b08cf40
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Oct 3, 2023
ef9d33c
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Oct 4, 2023
1ff7f62
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Oct 4, 2023
bda0555
Update test_fft.py
VaishnaviMudaliar Oct 4, 2023
83975fc
🤖 Lint code
ivy-branch Oct 4, 2023
c5d31db
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Oct 4, 2023
42e9779
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Oct 5, 2023
b7bce22
Update test_fft.py
VaishnaviMudaliar Oct 5, 2023
5810bc7
🤖 Lint code
ivy-branch Oct 5, 2023
6ed241c
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Oct 7, 2023
0032f47
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Oct 9, 2023
05988f7
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Oct 12, 2023
30e8ee2
Updated the code
VaishnaviMudaliar Oct 12, 2023
3c821f3
code updated
VaishnaviMudaliar Oct 12, 2023
6fe2b50
🤖 Lint code
ivy-branch Oct 12, 2023
05d5a8a
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Oct 14, 2023
57a4345
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Oct 17, 2023
d7d8c37
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Nov 1, 2023
82693f1
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Nov 3, 2023
8eb3591
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Nov 8, 2023
4316f0a
Merge remote-tracking branch 'upstream/main' into pr/23882
NripeshN Dec 27, 2023
966f74a
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Feb 8, 2024
c1cebd4
Merge branch 'unifyai:main' into ifftshift
VaishnaviMudaliar Feb 21, 2024
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
27 changes: 27 additions & 0 deletions ivy/functional/frontends/jax/numpy/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,33 @@ def ifft2(a, s=None, axes=(-2, -1), norm=None):
return ivy.array(ivy.ifft2(a, s=s, dim=axes, norm=norm), dtype=ivy.dtype(a))


@to_ivy_arrays_and_back
def ifftshift(x, axes=None):
# Check if an array
if not ivy.is_array(x):
raise ValueError("Input 'x' must be an array")

# Get the shape of x
shape = ivy.shape(x)

# If axes is None, shift all axes
if axes is None:
axes = list(range(len(shape)))

# Initialize a list to store the shift values
shift_values = []

# Calculate shift values for each axis
for axis in axes:
axis_size = shape[axis]
shift = -ivy.floor(axis_size / 2).astype(ivy.int32)
shift_values.append(shift)

# Perform the shift using Ivy's roll function
result = ivy.roll(x, shift_values, axes)
return result


@to_ivy_arrays_and_back
@with_unsupported_dtypes({"1.25.2 and below": ("float16", "bfloat16")}, "numpy")
def rfft(a, n=None, axis=-1, norm=None):
Expand Down
24 changes: 24 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 @@ -242,6 +242,30 @@ def test_jax_numpy_ifft2(
)


# ifftshift
@handle_frontend_test(
fn_tree="jax.numpy.fft.ifftshift",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"), shape=(4,), array_api_dtypes=True
),
)
def test_jax_numpy_ifftshift(
dtype_and_x, backend_fw, frontend, test_flags, fn_tree, on_device
):
input_dtype, arr = dtype_and_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
frontend=frontend,
backend_to_test=backend_fw,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
test_values=True,
x=arr[0],
axes=None,
)


Copy link
Contributor

Choose a reason for hiding this comment

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

The test function is missing some code here

# rfft
@handle_frontend_test(
fn_tree="jax.numpy.fft.rfft",
Expand Down
Loading