def test_irfft(self): inputs_val = np.random.random((1, N, N)).astype('float32') inputs = theano.shared(inputs_val) fft = theano.gpuarray.fft.curfft(inputs) f_fft = theano.function([], fft, mode=mode_with_gpu) res_fft = f_fft() m = fft.type() ifft = theano.gpuarray.fft.cuirfft(m) f_ifft = theano.function([m], ifft, mode=mode_with_gpu) res_ifft = f_ifft(res_fft) utt.assert_allclose(inputs_val, np.asarray(res_ifft)) inputs_val = numpy.random.random((1, N, N, 2)).astype('float32') inputs = theano.shared(inputs_val) irfft = theano.gpuarray.fft.cuirfft(inputs) f_irfft = theano.function([], irfft) res_irfft = f_irfft() inputs_ref = inputs_val[..., 0] + inputs_val[..., 1] * 1j irfft_ref = np.fft.irfftn(inputs_ref, axes=(1, 2)) utt.assert_allclose(irfft_ref, res_irfft, atol=1e-4, rtol=1e-4)
def test_irfft(self): inputs_val = np.random.random((1, N, N)).astype("float32") inputs = theano.shared(inputs_val) fft = theano.gpuarray.fft.curfft(inputs) f_fft = theano.function([], fft, mode=mode_with_gpu) res_fft = f_fft() m = fft.type() ifft = theano.gpuarray.fft.cuirfft(m) f_ifft = theano.function([m], ifft, mode=mode_with_gpu) res_ifft = f_ifft(res_fft) utt.assert_allclose(inputs_val, np.asarray(res_ifft)) inputs_val = np.random.random((1, N, N, 2)).astype("float32") inputs = theano.shared(inputs_val) irfft = theano.gpuarray.fft.cuirfft(inputs) f_irfft = theano.function([], irfft, mode=mode_with_gpu) res_irfft = f_irfft() inputs_ref = inputs_val[..., 0] + inputs_val[..., 1] * 1j irfft_ref = np.fft.irfftn(inputs_ref, axes=(1, 2)) utt.assert_allclose(irfft_ref, res_irfft, atol=1e-4, rtol=1e-4)