tracel-ai/burn · error
todo!("rfft is not supported for ndarray")
Error message
todo!("rfft is not supported for ndarray") What it means
The ndarray backend's rfft (crates/burn-ndarray/src/ops/module.rs:406) is a stub that always panics with todo!("rfft is not supported for ndarray"). Real-valued FFT is simply not implemented for the CPU ndarray backend.
Source
Thrown at crates/burn-ndarray/src/ops/module.rs:406
}
fn attention(
query: FloatTensor<Self>,
key: FloatTensor<Self>,
value: FloatTensor<Self>,
mask: Option<burn_backend::tensor::BoolTensor<Self>>,
attn_bias: Option<FloatTensor<Self>>,
options: AttentionModuleOptions,
) -> FloatTensor<Self> {
attention_fallback::<Self>(query, key, value, mask, attn_bias, options)
}
fn rfft(
_signal: FloatTensor<Self>,
_dim: usize,
_n: Option<usize>,
) -> (FloatTensor<Self>, FloatTensor<Self>) {
todo!("rfft is not supported for ndarray")
}
fn irfft(
_spectrum_re: FloatTensor<Self>,
_spectrum_im: FloatTensor<Self>,
_dim: usize,
_n: Option<usize>,
) -> FloatTensor<Self> {
todo!("irfft is not supported for ndarray")
}
}
View on GitHub (pinned to d16f7ba2ed)
Solutions
- Switch to a backend that implements rfft (e.g. the candle or cubecl-backed backends).
- Compute the FFT outside burn (e.g. via the rustfft crate) and load the result back as a tensor.
- Implement rfft for burn-ndarray using rustfft and contribute it upstream.
Example fix
// before let (re, im) = signal.rfft(1, None); // panics on ndarray backend // after: use a supported backend #[cfg(feature = "candle")] let (re, im) = signal_candle.rfft(1, None);
Defensive patterns
Strategy: validation
Validate before calling
// guard before calling rfft on ndarray backend
if std::any::TypeId::of::<B>() != supported_fft_backend() { /* route to rustfft fallback */ } Prevention
- Avoid Tensor::rfft on the ndarray backend; use a backend with FFT support.
- Isolate FFT code behind a trait/backend feature gate.
- Check burn's op support table per backend before using spectral ops.
When it happens
Trigger: Calling Tensor::rfft (any dim/n) on a tensor whose backend is burn-ndarray.
Common situations: Running audio/signal-processing models (spectrogram, STFT) on CPU via ndarray; the same code works on a GPU backend that implements FFT.
Related errors
- todo!("irfft is not supported for ndarray")
- todo!("grid_sample_2d with {:?} mode is not implemented", op
- rfft: unsupported dtype {:?}
- irfft: unsupported dtype {:?}
- Dim not supported {ndims}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/a181c465d54c1259.
Report an issue: GitHub.