Skip to content

Commit

Permalink
expand tests fft
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudiaComito committed Oct 11, 2023
1 parent 4c5d057 commit e5e015c
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions heat/fft/tests/test_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ def test_fft(self):
self.assertEqual(y.shape, x.shape)
self.assert_array_equal(y, np_y)

# 1D distributed
x = ht.random.randn(6, split=0)
y = ht.fft.fft(x)
np_y = np.fft.fft(x.numpy())
self.assertIsInstance(y, ht.DNDarray)
self.assertEqual(y.shape, x.shape)
self.assertTrue(y.split == 0)
self.assert_array_equal(y, np_y)

# n-D distributed
x = ht.random.randn(10, 8, 6, dtype=ht.float64, split=0)
# FFT along last axis
Expand All @@ -25,25 +34,32 @@ def test_fft(self):
self.assertTrue(y.split == 0)
self.assert_array_equal(y, np_y)

# FFT along distributed axis
y = ht.fft.fft(x, axis=0)
np_y = np.fft.fft(x.numpy(), axis=0)
# FFT along distributed axis, n not None
n = 8
y = ht.fft.fft(x, axis=0, n=n)
np_y = np.fft.fft(x.numpy(), axis=0, n=n)
self.assertIsInstance(y, ht.DNDarray)
self.assertEqual(y.shape, x.shape)
self.assertEqual(y.shape, np_y.shape)
self.assertTrue(y.split == 0)
self.assert_array_equal(y, np_y)

# complex input
x = x + 1j * ht.random.randn(10, 8, 6, dtype=ht.float64, split=0)
# FFT along last axis (distributed)
x.resplit_(axis=2)
y = ht.fft.fft(x)
np_y = np.fft.fft(x.numpy())
y = ht.fft.fft(x, n=n)
np_y = np.fft.fft(x.numpy(), n=n)
self.assertIsInstance(y, ht.DNDarray)
self.assertEqual(y.shape, x.shape)
self.assertEqual(y.shape, np_y.shape)
self.assertTrue(y.split == 2)
self.assert_array_equal(y, np_y)

# exceptions
# wrong input type
x = np.random.randn(6, 3, 3)
with self.assertRaises(TypeError):
ht.fft.fft(x)

def test_ifft(self):
# 1D non-distributed
x = ht.random.randn(6)
Expand Down

1 comment on commit e5e015c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: e5e015c Previous: 724a80b Ratio
matmul_split_0_N4_CPU - POWER 32.67786869411623 W (24.686547768808193) 11.38115920202092 W (10.623808934870924) 2.87
matmul_split_1_N4_CPU - POWER 33.06363044308138 W (25.591231557032273) 11.255847421647635 W (10.695264823780148) 2.94
matmul_split_1_N4_CPU - GPU_UTIL 2.5902245581150054 % (1.2351161403206878) 1.27960205078125 % (0.2880859375) 2.02
qr_split_0_N4_CPU - GPU_UTIL 2.948545068502426 % (2.0805196462107416) 1.2905536726117135 % (0.2673067836831179) 2.28
qr_split_1_N4_CPU - GPU_UTIL 3.1241379261016844 % (2.774222668891978) 1.4155546963214873 % (0.1911351522088796) 2.21
lanczos_N4_CPU - POWER 37.7212235778875 W (20.682540266858226) 18.78812961354826 W (15.972556799972525) 2.01
lanczos_N4_CPU - GPU_UTIL 3.075522804260254 % (2.6248382208055103) 1.47003173828125 % (0.1695679233807162) 2.09
reshape_N4_CPU - POWER 33.15315964131695 W (26.3094523426579) 15.546392996434914 W (13.964819009891047) 2.13

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ClaudiaComito

Please sign in to comment.