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

Make resample kernel generation faster #2415

Closed
wants to merge 1 commit into from

Conversation

xvdp
Copy link

@xvdp xvdp commented May 27, 2022

Changes:

  1. loops are replaced with broadcasting
  2. device is cast at end of kernel creation
  3. dtype is defaulted to float32 ( float64) does nothing valuable
  4. defaults for beta and dtype are moved to function declaration

Fix #2414

1. loops are replaced with broadcasting
2. device is cast at end of kernel creation
3. dtype is defaulted to float32 ( float64) does nothing valuable
4. defaults for beta and dtype are moved to function declaration
@xvdp
Copy link
Author

xvdp commented May 27, 2022

Im not sure that the failures are in my code... i didnt change the style.

@facebook-github-bot
Copy link
Contributor

Hi @xvdp!

Thank you for your pull request and welcome to our community.

Action Required

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

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@carolineechen
Copy link
Contributor

Thanks for the PR! Can you rebase the PR and also separate out the changes into separate PRs? The unit test failures were addressed in #2422 (lint test is known to be failing so can ignore that for now). And the reasoning for separating the PR is so each change is contained and easier to review, and since we likely won't be ready to merge all changes at the same time (as mentioned on #2414, we would need more data to back up the device casting).

@@ -5,6 +5,7 @@
import warnings
from collections.abc import Sequence
from typing import Optional, Tuple, Union
from numpy import roll
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this used? NumPy is not mandatory requirement of torchaudio, so we would like to avoid the use of NumPy.

device: torch.device = torch.device("cpu"),
dtype: Optional[torch.dtype] = None,
dtype: Optional[torch.dtype] = torch.float32,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we keep the dtype effectiveness? The reason resample supports torch.float64 for the sake of use cases other than DL, which requires higher precision for quality.

@xvdp
Copy link
Author

xvdp commented Jun 3, 2022 via email

@mthrok mthrok changed the title fix to issue #2414, kernel creation uses loops. Changes: Make resample kernel generation faster Jun 6, 2022
@mthrok
Copy link
Collaborator

mthrok commented Jul 19, 2022

@xvdp Do you have any update? Let me know if you are busy, we will look into it on our side.

skim0514 pushed a commit to skim0514/audio that referenced this pull request Jul 19, 2022
facebook-github-bot pushed a commit that referenced this pull request Jul 20, 2022
Summary:
Modification from pull request #2415 to improve resample.

Benchmarked for a 89% time reduction, tested in comparison to original resample method.

Pull Request resolved: #2553

Reviewed By: carolineechen

Differential Revision: D37997533

Pulled By: skim0514

fbshipit-source-id: ef4b719450ac26794db6ea01f9882509f4fda5cf
@skim0514
Copy link
Contributor

Addressed in #2553

@skim0514 skim0514 closed this Jul 22, 2022
@xvdp
Copy link
Author

xvdp commented Oct 11, 2022 via email

@carolineechen
Copy link
Contributor

Hi @xvdp, thanks again for the suggestions. Since we did not get a response in July, we went ahead and pulled out broadcasting component from your PR in this one (#2553) and merged the change. We got an 89% speedup as mentioned from this, thanks!

For change 2 (device is cast at the end), we did not have the bandwidth to look into that change and potential improvements from it yet, so feel free to look into that.

For change 3 (using float32 instead of 64) and 4 (setting defaults in func declaration), we would like to stick to using the current approach. For float64 default, there may be dsp use cases where more specific dtype is necessary, and to avoid breaking backwards compatibility. And for the beta default, since not all resampling methods require a beta, we would like to leave it as None.

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

Successfully merging this pull request may close these issues.

Resample kernel creation uses loops...
5 participants