espnet2.gan_svs.visinger2.ddsp.fft_convolve
Less than 1 minute
espnet2.gan_svs.visinger2.ddsp.fft_convolve
espnet2.gan_svs.visinger2.ddsp.fft_convolve(signal, kernel)
Perform convolution of a signal with a kernel using FFT.
This function takes an input signal and a kernel, both of which are expected to be 1D tensors. The convolution is performed in the frequency domain using Fast Fourier Transform (FFT) for efficient computation. The output signal is obtained by applying the inverse FFT to the product of the FFTs of the signal and the kernel.
- Parameters:
- signal (torch.Tensor) – The input signal tensor of shape (N, L), where N is the batch size and L is the length of the signal.
- kernel (torch.Tensor) – The convolution kernel tensor of shape (M, K), where M is the batch size (should match signal’s batch size) and K is the length of the kernel.
- Returns: The output tensor after convolution, with shape : (N, L + K - 1), where the length of the output is the sum of the lengths of the signal and kernel minus one.
- Return type: torch.Tensor
Examples
>>> signal = torch.tensor([[1.0, 2.0, 3.0]])
>>> kernel = torch.tensor([[0.5, 1.0]])
>>> output = fft_convolve(signal, kernel)
>>> print(output)
tensor([[1.5000, 3.0000, 4.5000, 3.0000]])
NOTE
The function applies zero-padding to both the input signal and the kernel to ensure that the convolution can be computed correctly without any boundary effects.
- Raises:ValueError – If the batch sizes of signal and kernel do not match.