braindecode.functional.fft_conv1d#

braindecode.functional.fft_conv1d(x, weight, bias=None)[source]#

F.conv1d(x, weight, bias, padding="same") computed with FFTs.

Equal to the direct convolution up to float rounding: the FFT is long enough for a linear (not circular) convolution. Its cost barely grows with the kernel size, so it is faster than the direct one for long kernels on CPU (see prefer_fft_conv()). float16/bfloat16 inputs are computed in float32 (spectral_input()) and cast back.

Parameters:
  • x (Tensor) – Input of shape (batch, in_channels, n_times).

  • weight (Tensor) – Kernels of shape (out_channels, in_channels, kernel_size).

  • bias (Optional[Tensor]) – Bias of shape (out_channels,).

Returns:

Output of shape (batch, out_channels, n_times), dtype and device of x. For an even kernel_size it is aligned like torch’s padding="same" (the extra zero padded on the right).

Return type:

Tensor