aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/test/cxx11_tensor_fft.cpp
diff options
context:
space:
mode:
authorGravatar RJ Ryan <rryan@mixxx.org>2017-12-31 10:44:56 -0500
committerGravatar RJ Ryan <rryan@mixxx.org>2017-12-31 10:44:56 -0500
commit59985cfd26416fb6b196af868c187e90d237c352 (patch)
tree66cb438384d1b79cbdb5dca768ad6e3cf2f1ab14 /unsupported/test/cxx11_tensor_fft.cpp
parentf9bdcea022e24bac4a66a937c37de92f7f22b9da (diff)
Disable use of recurrence for computing twiddle factors. Fixes FFT precision issues for large FFTs. https://github.com/tensorflow/tensorflow/issues/10749#issuecomment-354557689
Diffstat (limited to 'unsupported/test/cxx11_tensor_fft.cpp')
-rw-r--r--unsupported/test/cxx11_tensor_fft.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/unsupported/test/cxx11_tensor_fft.cpp b/unsupported/test/cxx11_tensor_fft.cpp
index 2f14ebc62..a55369477 100644
--- a/unsupported/test/cxx11_tensor_fft.cpp
+++ b/unsupported/test/cxx11_tensor_fft.cpp
@@ -224,6 +224,32 @@ static void test_fft_real_input_energy() {
}
}
+template <typename RealScalar>
+static void test_fft_non_power_of_2_round_trip(int exponent) {
+ int n = (1 << exponent) + 1;
+
+ Eigen::DSizes<long, 1> dimensions;
+ dimensions[0] = n;
+ const DSizes<long, 1> arr = dimensions;
+ Tensor<RealScalar, 1, ColMajor, long> input;
+
+ input.resize(arr);
+ input.setRandom();
+
+ array<int, 1> fft;
+ fft[0] = 0;
+
+ Tensor<std::complex<RealScalar>, 1, ColMajor> forward =
+ input.template fft<BothParts, FFT_FORWARD>(fft);
+
+ Tensor<RealScalar, 1, ColMajor, long> output =
+ forward.template fft<RealPart, FFT_REVERSE>(fft);
+
+ for (int i = 0; i < n; ++i) {
+ VERIFY_IS_APPROX(input[i], output[i]);
+ }
+}
+
void test_cxx11_tensor_fft() {
test_fft_complex_input_golden();
test_fft_real_input_golden();
@@ -270,4 +296,6 @@ void test_cxx11_tensor_fft() {
test_fft_real_input_energy<RowMajor, double, true, Eigen::BothParts, FFT_FORWARD, 4>();
test_fft_real_input_energy<RowMajor, float, false, Eigen::BothParts, FFT_FORWARD, 4>();
test_fft_real_input_energy<RowMajor, double, false, Eigen::BothParts, FFT_FORWARD, 4>();
+
+ test_fft_non_power_of_2_round_trip<float>(7);
}