Skip to content

Commit

Permalink
[GPU] Force an input buffer copy for double precision complex-to-real…
Browse files Browse the repository at this point in the history
… IRFFTs.

Fixes #9946

PiperOrigin-RevId: 439414091
  • Loading branch information
hawkinsp authored and jax authors committed Apr 4, 2022
1 parent 6825f65 commit 71a5eb2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ PLEASE REMEMBER TO CHANGE THE '..main' WITH AN ACTUAL TAG in GITHUB LINK.
* {func}`jax.tree_util.tree_multimap` is deprecated. Use {func}`jax.tree_util.tree_map` instead ({jax-issue}`#5746`).

## jaxlib 0.3.3 (Unreleased)

* Bug fixes
* Fixed a bug where double-precision complex-to-real IRFFTs would mutate their
input buffers on GPU ({jax-issue}`#9946`).

## jax 0.3.4 (March 18, 2022)
* [GitHub
Expand Down
9 changes: 9 additions & 0 deletions tests/fft_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


import itertools
import unittest

import numpy as np

Expand Down Expand Up @@ -107,6 +108,14 @@ def testLaxFftAcceptsStringTypes(self):
self.assertAllClose(np.fft.fft(x).astype(np.complex64),
lax.fft(x, "FFT", fft_lengths=(10,)))

@parameterized.parameters((np.float32,), (np.float64,))
@unittest.skipIf(jax._src.lib.xla_extension_version < 63,
"Test fails for jaxlib <= 0.3.2")
def testLaxIrfftDoesNotMutateInputs(self, dtype):
x = jnp.array([[1.0, 2.0], [3.0, 4.0]], dtype=dtype) * (1+1j)
y = np.asarray(jnp.fft.irfft2(x))
z = np.asarray(jnp.fft.irfft2(x))
self.assertAllClose(y, z)

@parameterized.named_parameters(jtu.cases_from_list(
{"testcase_name": "_inverse={}_real={}_shape={}_axes={}_s={}_norm={}".format(
Expand Down

0 comments on commit 71a5eb2

Please sign in to comment.