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

Specify fftLength in rfft op #1762

Merged
merged 5 commits into from
Jun 10, 2019
Merged

Conversation

Lewuathe
Copy link
Contributor

@Lewuathe Lewuathe commented May 18, 2019

In order to implement stft without introducing future breaking change, rfft should be able to get fftLength param in advance. That is compatible with TensorFlow core rfft ops.

See: https://www.tensorflow.org/api_docs/python/tf/signal/rfft


This change is Reviewable

@Lewuathe Lewuathe mentioned this pull request May 18, 2019
Copy link
Contributor

@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: 0 of 1 approvals obtained (waiting on @Lewuathe)


src/ops/spectral_ops.ts, line 109 at r1 (raw file):

 * @doc {heading: 'Operations', subheading: 'Spectral', namespace: 'spectral'}
 */
function rfft_(input: Tensor, fftLength: number = null): Tensor {

no need to specify null here


src/ops/spectral_ops.ts, line 109 at r1 (raw file):

 * @doc {heading: 'Operations', subheading: 'Spectral', namespace: 'spectral'}
 */
function rfft_(input: Tensor, fftLength: number = null): Tensor {

in tensorflow fftLength is a Tensor, can you make this a TensorLike and then convert it?


src/ops/spectral_ops_test.ts, line 219 at r1 (raw file):

  it('should return the same value without any fftLength', async () => {
    const t1Real = tf.tensor1d([-3, -2, -1, 1, 2, 3]);
    expectArraysClose(await tf.spectral.rfft(t1Real, 6).data(), [

can you pull the numbers to a constant const fftLength = 4; for readability

Copy link
Contributor Author

@Lewuathe Lewuathe 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: 0 of 1 approvals obtained (waiting on @nsthorat)


src/ops/spectral_ops.ts, line 109 at r1 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

no need to specify null here

But otherwise, it breaks the compatibility. I mean we always need to pass two arguments for rfft.


src/ops/spectral_ops.ts, line 109 at r1 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

in tensorflow fftLength is a Tensor, can you make this a TensorLike and then convert it?

How can we safely convert TensorLike to number? Is there any common way?


src/ops/spectral_ops_test.ts, line 219 at r1 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

can you pull the numbers to a constant const fftLength = 4; for readability

Sure will do.

Copy link
Contributor

@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: 0 of 1 approvals obtained (waiting on @Lewuathe)


src/ops/spectral_ops.ts, line 109 at r1 (raw file):

Previously, Lewuathe (Kai Sasaki) wrote…

But otherwise, it breaks the compatibility. I mean we always need to pass two arguments for rfft.

I just mean this with a question mark:

rfft_(input: Tensor, fftLength?: number)


src/ops/spectral_ops.ts, line 109 at r1 (raw file):

Previously, Lewuathe (Kai Sasaki) wrote…

How can we safely convert TensorLike to number? Is there any common way?

Ah, didn't realize the shape was a function of this. This is fine for now.


src/ops/spectral_ops_test.ts, line 219 at r1 (raw file):

Previously, Lewuathe (Kai Sasaki) wrote…

Sure will do.

Let me know when this is done.

Copy link
Contributor Author

@Lewuathe Lewuathe 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: 0 of 1 approvals obtained (waiting on @Lewuathe and @nsthorat)


src/ops/spectral_ops.ts, line 109 at r1 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

I just mean this with a question mark:

rfft_(input: Tensor, fftLength?: number)

Oh, I see. Thanks will do.

@Lewuathe
Copy link
Contributor Author

@nsthorat I updated accordingly. Could you take a look again?

Copy link
Contributor

@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.

Reviewed 2 of 2 files at r2.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained

@nsthorat nsthorat merged commit b69685f into tensorflow:master Jun 10, 2019
@nsthorat
Copy link
Contributor

Thanks @Lewuathe as always high quality PR :)

@Lewuathe Lewuathe deleted the fft-length-in-rfft branch June 11, 2019 01:38
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