fftconv1d_fp32_blh#

fftconv1d_fp32_blh(x, kernel, shortcut=None)#

Non-causal 1D FFT convolution (BLH layout, channels-last) with optional shortcut.

Computes a “same”-aligned linear convolution per channel by zero-padding to \(F = \min(L + \lceil K/2 \rceil, 2L)\), multiplying in the frequency domain, inverting, and cropping centered with offset K // 2. The non-causal variant only needs enough headroom for half the kernel on each side, so it is cheaper than the causal variant.

When shortcut is provided, the per-channel residual is added:

\[y \leftarrow y + \text{shortcut} \odot x\]
Parameters:
  • x (Tensor) – Input tensor of shape [batch_size, seq_len, hidden_dim].

  • kernel (Tensor) – Kernel tensor of shape [1|B, kernel_len, hidden_dim].

  • shortcut (Tensor | None) – Optional [hidden_dim] per-channel residual scale.

Returns:

Output tensor of shape [batch_size, seq_len, hidden_dim] in the original dtype of x.

Return type:

Tensor