How to use PyFFTW's wisom

637 Views Asked by At

I didn't see an actual example on pyfftw's documentation of how to use the 'wisdom' feature so I'm a little confused.

My code looks something like the following:

# first FFT
input = pyfftw.zeros_aligned(arraySize, dtype='complex64')
input[:] = image
fftwObj = pyfftw.builders.fft2(input, planner_effort='FFTW_EXHAUSTIVE')
imageFFT = fftwObj(input)

wisdom = pyfftw.export_wisdom()

pyfftw.import_wisdom(wisdom)

# second FFT with the same input size but different input
input = pyfftw.zeros_aligned(arraySize, dtype='complex64')
input[:] = image2
fftwObj = pyfftw.builders.fft2(input, planner_effort='FFTW_EXHAUSTIVE')
imageFFT2 = fftwObj(input)

The docs say that export_wisdom outputs a tuple of strings and that import_wisdom takes in this tuple as an argument.

When am I supposed to export the wisdom and am I supposed to save this tuple out to a file for each FFT?

When do I load it back in? Before the call to each FFT?

1

There are 1 best solutions below

10
On BEST ANSWER

Basically, exporting and importing wisdom is a method to maintain state between sessions.

The wisdom is the knowledge about how best to plan an FFT. During a session, the internal "wisdom" is made up of all the plans that are made, and the wisdom that has been imported. Repeatedly importing the same wisdom file is not useful because that knowledge is already known after the first import.

You export wisdom when you want the knowledge about a particular transform plan to be used instead of having to work it out again. It need only plan for that transform once per session though.