Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Add tf.ifft(). #1341

Merged
merged 8 commits into from
Oct 25, 2018
Merged

Add tf.ifft(). #1341

merged 8 commits into from
Oct 25, 2018

Conversation

nsthorat
Copy link
Contributor

@nsthorat nsthorat commented Oct 24, 2018

This is the inverse of tf.fft(). Luckily this is simple as changing -2 * PI to 2 * PI.

Like tf.fft(), only implements 1D on CPU. For GPU, all dimensions are supported.

Towards tensorflow/tfjs#782

For reference:
https://www.mathworks.com/help/matlab/ref/ifft.html
https://www.tensorflow.org/api_docs/python/tf/spectral/ifft


This change is Reviewable

@nsthorat nsthorat requested a review from dsmilkov October 24, 2018 19:33
Copy link
Contributor

@dsmilkov dsmilkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 9 of 9 files at r1.
Reviewable status: 0 of 1 approvals obtained (waiting on @nsthorat and @dsmilkov)


src/kernels/backend_cpu.ts, line 2572 at r1 (raw file):

      if (inverse) {
        result = ops.complex(
                     ops.real(result).div(scalar(n)),

place scalar(n) in a temp variable so we don't upload twice to gpu (potentially)


src/kernels/webgl/fft_gpu.ts, line 34 at r1 (raw file):

    this.outputShape = inputShape;

    const pi = '3.1415926535897932384626433832795';

use built-in Math.PI


src/kernels/webgl/fft_gpu.ts, line 61 at r1 (raw file):

          float imag = getImag(batch, i);

          result += (

why the parenthesis?

Copy link
Contributor Author

@nsthorat nsthorat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @nsthorat)


src/kernels/backend_cpu.ts, line 2572 at r1 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

place scalar(n) in a temp variable so we don't upload twice to gpu (potentially)

This is in backend_cpu


src/kernels/webgl/fft_gpu.ts, line 34 at r1 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

use built-in Math.PI

Done


src/kernels/webgl/fft_gpu.ts, line 61 at r1 (raw file):

Previously, dsmilkov (Daniel Smilkov) wrote…

why the parenthesis?

No good reason, removed.

@nsthorat nsthorat merged commit cb176e4 into master Oct 25, 2018
@nsthorat nsthorat deleted the ifft branch October 25, 2018 21:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants