Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use istft from torch #523

Merged
merged 1 commit into from
May 13, 2020
Merged

Use istft from torch #523

merged 1 commit into from
May 13, 2020

Conversation

mthrok
Copy link
Collaborator

@mthrok mthrok commented Apr 7, 2020

Corresponding PR pytorch/pytorch#35569

This PR will use istft from torch repo, which is ported to C++.

This PR will not succeed until the upstream PR is merged and torch.istft becomes available.

@mthrok mthrok changed the title Use istft from torch Use istft from torch Apr 7, 2020
@cpuhrsch
Copy link
Contributor

cpuhrsch commented Apr 8, 2020

Did you double check that warnings is compatible with pytorch/pytorch?


return y
warnings.warn(
'istft has been moved to PyTorch and will be deprecated, please use torch.istft instead.')
Copy link

Choose a reason for hiding this comment

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

this should produce a UserWarning, which is our convention.

I don't know what it means that something "will be deprecated" -- something being deprecated means it will be changed eventually, so there's not really a delta between "will be deprecated" and "is deprecated".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops I meant, 'will be removed'...

@vincentqb vincentqb changed the title Use istft from torch [WIP] Use istft from torch Apr 8, 2020
Comment on lines 128 to 129
warnings.warn(
'istft has been moved to PyTorch and will be removed, please use torch.istft instead.')
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "torchaudio.istft has been moved to PyTorch and will be removed from torchaudio, please use torch.istft instead.'

Comment on lines 130 to 133
warnings.warn(
'`pad_mode` for istft function is deprecated and will be removed. '
'It was introduced accidentally and never used. '
'You can safely remove it from your function call')
Copy link
Contributor

Choose a reason for hiding this comment

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

In the sense that pad_mode was added to mirror the signature of stft, pad_mode in istft is indeed not needed. Also, pad_mode="reflect" in istft still provides a reasonable inverse to stft with pad_mode="constant", as shown in torchaudio tests.

If we are to show this warning, let's only do so if the user attempts to change the default value. An alternative is to set the default value to None, and show the warning if the user changes pad_mode to something else than that.

nit: 'The parameter pad_mode was ignored in isftft, and is thus being deprecated. Please set pad_mode to None to suppress this warning.')

@vincentqb
Copy link
Contributor

vincentqb commented Apr 8, 2020

Marked as "do not merge before istft"

@vincentqb vincentqb changed the title [WIP] Use istft from torch [DO NOT MERGE BEFORE ISTFT] Use istft from torch Apr 8, 2020
@vincentqb vincentqb changed the title [DO NOT MERGE BEFORE ISTFT] Use istft from torch Use istft from torch Apr 27, 2020
@vincentqb
Copy link
Contributor

Now that pytorch/pytorch#35569 has been merged, removed label marking as do not merge.

Copy link
Contributor

@vincentqb vincentqb left a comment

Choose a reason for hiding this comment

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

Tests are failling.

=========================== short test summary info ============================
FAILED test/test_functional.py::TestIstft::test_istft_requires_nola - Runtime...
FAILED test/test_functional.py::TestIstft::test_istft_requires_non_empty - Ru...
FAILED test/test_functional.py::TestIstft::test_istft_requires_overlap_windows
FAILED test/test_torchscript_consistency.py::TestFunctionalCPU::test_griffinlim
FAILED test/test_torchscript_consistency.py::TestTransformsCPU::test_GriffinLim
====== 5 failed, 207 passed, 57 skipped, 34 warnings in 315.87s (0:05:15) ======

@codecov
Copy link

codecov bot commented May 7, 2020

Codecov Report

Merging #523 into master will decrease coverage by 0.21%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #523      +/-   ##
==========================================
- Coverage   89.03%   88.81%   -0.22%     
==========================================
  Files          21       21              
  Lines        2261     2218      -43     
==========================================
- Hits         2013     1970      -43     
  Misses        248      248              
Impacted Files Coverage Δ
torchaudio/functional.py 95.24% <100.00%> (-0.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3a4f356...c37c88c. Read the comment docs.

Copy link
Contributor

@vincentqb vincentqb left a comment

Choose a reason for hiding this comment

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

LGTM

@vincentqb vincentqb merged commit 9835db7 into pytorch:master May 13, 2020
@mthrok mthrok deleted the istft branch May 15, 2020 03:18
bhargavkathivarapu pushed a commit to bhargavkathivarapu/audio that referenced this pull request May 19, 2020
Comment on lines -115 to -117
# pack batch
shape = stft_matrix.size()
stft_matrix = stft_matrix.reshape(-1, shape[-3], shape[-2], shape[-1])
Copy link
Contributor

Choose a reason for hiding this comment

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

This is what enabled the implementation to support batching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants