fix: use persistent=False for recomputable buffers in transforms#4188
fix: use persistent=False for recomputable buffers in transforms#4188prisha2410 wants to merge 1 commit intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/audio/4188
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @prisha2410! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Summary
Updates all
register_buffer()calls intorchaudio/transforms/_transforms.pyto use
persistent=Falsefor buffers that are recomputable from constructorarguments.
Motivation
Fixes #3059
When loading a pre-existing checkpoint into a model containing torchaudio
transforms, a
missing keyerror is raised because recomputable buffers(e.g. window functions, mel filterbanks, kernels) are saved in the state dict
even though they can be reconstructed from the constructor parameters.
Changes
Added
persistent=Falseto the following buffers across transforms:window— inSpectrogram,InverseSpectrogram,GriffinLim,ISTFT,PitchShift(5 locations)fb— inMelScale,InverseMelScale(2 locations)dct_mat— inMFCC,LFCC(2 locations)filter_mat— inLFCC(1 location)kernel— inResample(1 location)phase_advance— inTimeStretch(1 location)Verification
Before fix:
After fix:
cc @mthrok @nateanl