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

[Hackathon 7th No.55] Add fft_conv1d to PaddleSpeech -part #3947

Merged
merged 8 commits into from
Dec 24, 2024

Conversation

DrRyanHuang
Copy link
Member

@DrRyanHuang DrRyanHuang commented Dec 11, 2024

PR types

New features

PR changes

APIs

Describe

fft_conv1d is much faster than conv1d when kernel_size >= 128

Implementation:

  • Standard conv1D applies convolutional kernels to the input signal using a sliding window approach.
  • fft_conv1d leverages the Fast Fourier Transform (FFT) to accelerate the convolution operation, ideally reducing the computational complexity from $$O(N \cdot K)$$ to $$O(N \log N)$$, where $$N$$ denotes the signal length and $$K$$ represents the kernel length.

Performance:

  • Standard conv1D: Typically performs well with small kernels or short input signals.
    Simple to implement and easy to debug.
  • fft_conv1d: Generally offers performance improvements when the kernel size is large (e.g., above 256) and the stride is 1. However, the introduction of FFT and IFFT incurs additional memory overhead.

Result:

ce70a8c4431c0b822ed723f8f48323e3

Copy link

paddle-bot bot commented Dec 11, 2024

Thanks for your contribution!

]


def __unfold(_input, kernel_size: int, stride: int):
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this api do?

paddlespeech/t2s/modules/fftconv1d.py Show resolved Hide resolved


# Currently, the API unfold in Paddle is extremely slow, so __unfold is implemented
# using the `.strides` and `.as_strided` APIs. However, these are only supported in
Copy link
Collaborator

Choose a reason for hiding this comment

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

paddle do not have .strides release api. Also for as_strided support >2.6, but can be combined with view and reshape .

paddlespeech/t2s/modules/fftconv1d.py Outdated Show resolved Hide resolved
# Paddle version 2.6 and above, so F.conv1d and Conv1D are used as replacements.
version = paddle.__version__

if version < '2.6':
Copy link
Collaborator

Choose a reason for hiding this comment

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

v2.6 and above cannot be used?

Copy link
Collaborator

@zxcd zxcd left a comment

Choose a reason for hiding this comment

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

LGTM

@zxcd zxcd merged commit ee4f158 into PaddlePaddle:develop Dec 24, 2024
5 checks passed
@DrRyanHuang DrRyanHuang deleted the fft_conv1d branch December 30, 2024 05:47
@luotao1 luotao1 changed the title [Hackathon 7th No.55] Add fft_conv1d to PaddleSpeech [Hackathon 7th No.55] Add fft_conv1d to PaddleSpeech -part Jan 3, 2025
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.

2 participants