Re: [eigen] tensor fft
• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: Re: [eigen] tensor fft
• From: Benoit Steiner <benoit.steiner.goog@xxxxxxxxx>
• Date: Wed, 24 Feb 2016 15:32:37 -0800
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=33/b7CiGIswo9YXuBGjeXAkllvVGuA3o1S6ecL8uDPw=; b=PwtYFAidXPVfQDkwcpyIQADrMLmjIAxb2RlOgKeZv+7m0xE6Mc0Pcy/dnGJWbXc9Iq 85moTBQdCXyC7T4WGzVnfI5zPU0PJi6YWd9QORiSL3asF/7G/xswa8JKfs5w7DH+KQOg /Ys3LFkWrMyghJ1nZQt/LGdkdCUa75U+BgcXxgnsJVBL6l4m3oXn8XeehNdEfmV1wDYB LD8/DC0riaKNoU1W9RnitnuINh86GJDoqcS3kP4uHGqYfQd75X/peFPK+X10a7Swx1n1 A/PxJFP/eJ6y69LbQNYVY7kq6Vf92lIoFvIYHtH4311HrzK1OBnisoiHv4bJOvydhPj+ 6ccQ==

The behavior can't be changed. However, you can extract a 2D tensor from your 3d input and compute the fft on it directly as follow:

Tensor<float, 3> tensor = bla.
` Eigen::array<int, 2> dims = {{0, 1}};`
Tensor<std::complex<float>, 2> full_2d_fft = tensor.chip<1>(0).template fft<Eigen::BothParts, Eigen::FFT_FORWARD>(dims);

`Note that since the result of the chip operation is a 2d tensor, you need to adjust dims accordingly. Moreover the result will also be a 2d tensor. By the way, the chipping is done on the fly (that is it's evaluated lazily), so it won't increase the amount of the memory required to compute the operation.`

`Benoit`

On Wed, Feb 24, 2016 at 3:15 PM, Chris wrote:
Hi Benoit,
Yes, that helps - thanks much.  By batch dimension you mean if in the example below the tensor is size(2,3,4), then 3 2D ffts are calculated (because 2nd dim is length 3) ?   If so, is there a way to turn that off (i.e. just run one 2D fft on 2nd dim (:,0,:)).

Chris

On 2/16/16 9:31 AM, Benoit Steiner wrote:
Unfortunately the FFT code isn't currently documented. You can take at look at https://bitbucket.org/eigen/eigen/src/cae994ddbfe07e3de34e69796c97ec600096edea/unsupported/test/cxx11_tensor_fft.cpp?at=default&fileviewer=file-view-default for examples of fft, and https://bitbucket.org/eigen/eigen/src/cae994ddbfe07e3de34e69796c97ec600096edea/unsupported/test/cxx11_tensor_ifft.cpp?at=default&fileviewer=file-view-default for examples of an inverse fft.

The fft method works as follow: it takes 2 template parameters, FFTResultType and FFTDir. The first parameter indicate what part of the fft transform you want to compute. You can compute the real part, the imaginary part, or both. The second parameter indicates whether you want to compute compute the fft or the inverse transform.

The fft method also takes an array of dimensions. These are the dimensions along which you want to perform the fft. For example, if you have a 3d tensor as input, you can perform a 1d fft by passing an array of 1 dimension. The 2 remaining dimensions will be considered as batch dimensions. You can also perform a 2d fft by passing a 2d array of dimensions, or a 3d fft by passing a 3d array as argument.

Here's an example:

Tensor<float, 3> tensor = bla.
`Eigen::array<int, 2> dims = {{0, 2}};`
Tensor<std::complex<float>, 3> full_2d_fft = tensor.template fft<Eigen::BothParts, Eigen::FFT_FORWARD>(dims);

This will compute a 2d fft alongside the first an the last dimension of your tensor. The 2nd dimensions will be considered a batch dimension.

Tensor<float, 3> inverse = full_2d_fft.template fft<Eigen::RealPart, Eigen::FFT_REVERSE>(dims);

This will compute the inverse of the initial fft, and should be equal to tensor (modulo numerical noise).

Hope this helps.

On Mon, Feb 15, 2016 at 11:19 AM, Chris wrote:
Hi,

Is there any documentation on how to use tensor fft?  I've looked through the test module and see there is real fft, etc. and some permutation of some input parameters, but I haven't found any documentation on them.

Thanks,
Chris

--

--
Benoit

 Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/