resolve_fused_fft_size#

resolve_fused_fft_size(x_dim, y_dim, k_x, k_y, fft_size=None)#

Pick the FFT tile size for a fused 2D conv, or validate an explicit one.

The tile must satisfy two constraints simultaneously:

  • fft_size // 2 >= max(x_dim, y_dim) — the kernel’s own input cap.

  • fft_size // 2 >= ceil(k / 2) per axis — headroom for the top/left pre-pad of fft_size // 2 - k // 2 that realigns the crop with the torch reference (see the section header).

Parameters:
  • x_dim (int) – Input height X.

  • y_dim (int) – Input width Y.

  • k_x (int) – Kernel height K_x.

  • k_y (int) – Kernel width K_y.

  • fft_size (int | None) – Explicit tile size to validate. When None, the smallest admissible power-of-two tile is chosen.

Returns:

A tile size drawn from (8, 16, 32, 64, 128).

Raises:

ValueError – If no admissible tile exists (shape too large for the fused kernel), or if an explicit fft_size is not in the supported set or is too small for the given shapes.

Return type:

int