def testFFTCentralFreqBatch(self): # Same for batches for gpu in [True, False]: x = torch.FloatTensor(4, 10, 10, 2).fill_(0) x.narrow(3, 0, 1).fill_(1) if gpu: x = x.cuda() a = x.sum() fft = sl.Fft() fft(x, inplace=True) c = x[:, 0, 0, 0].sum() self.assertEqual(a, c)
def testFFTCentralFreq(self): # Checked the 0 frequency for gpu in [True, False]: x = torch.FloatTensor(10, 10, 2).fill_(0) x.narrow(2, 0, 1).fill_(1) if gpu: x = x.cuda() a = x.sum() fft = sl.Fft() fft(x, inplace=True) b = x[0, 0, 0] self.assertAlmostEqual(a, b, places=6)
def testFFTCentralFreq(self): # Checked the 0 frequency for gpu in [True, False]: x = torch.FloatTensor(10, 10, 2).fill_(0) x.narrow(2, 0, 1).fill_(1) if gpu: x = x.cuda() a = x.sum() fft = sl.Fft() fft(x, inplace=True) b = x[0, 0, 0] tt.assert_almost_equal(a.cpu(), b.cpu(), decimal=6)
def testFFTUnormalized(self): # Check for a random tensor: x = torch.FloatTensor(25, 17, 3, 2).bernoulli_(0.5) for gpu in [True, False]: if gpu: x = x.cuda() else: x = x.cpu() x.narrow(3, 1, 1).fill_(0) fft = sl.Fft() y = fft(x) z = fft(y, direction='C2R') z /= 17 * 3 # FFTs are unnormalized self.assertAlmostEqual(linfnorm(x.select(3, 0), z), 0, places=6)
def testFFTUnormalized(self): # Check for a random tensor: x = torch.FloatTensor(25, 17, 3, 2).bernoulli_(0.5) for gpu in [True, False]: if gpu: x = x.cuda() else: x = x.cpu() x.narrow(3, 1, 1).fill_(0) fft = sl.Fft() y = fft(x) z = fft(y, direction='C2R') z /= 17 * 3 # FFTs are unnormalized tt.assert_allclose(x.select(3, 0).cpu(), z.cpu(), atol=1e-6)