{"record":{"id":"ab8bb87bc58ccf63","repo":"tracel-ai/burn","slug":"irfft-unsupported-dtype","errorCode":null,"errorMessage":"irfft: unsupported dtype {:?}","messagePattern":"irfft: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/module.rs","lineNumber":758,"sourceCode":"            DType::F64 => crate::ops::fft::rfft_f64(signal, dim, n),\n            DType::F16 => crate::ops::fft::rfft_f16(signal, dim, n),\n            DType::BF16 => crate::ops::fft::rfft_bf16(signal, dim, n),\n            dtype => panic!(\"rfft: unsupported dtype {:?}\", dtype),\n        }\n    }\n\n    fn irfft(\n        spectrum_re: FloatTensor<Flex>,\n        spectrum_im: FloatTensor<Flex>,\n        dim: usize,\n        n: Option<usize>,\n    ) -> FloatTensor<Flex> {\n        match spectrum_re.dtype() {\n            DType::F32 => crate::ops::fft::irfft_f32(spectrum_re, spectrum_im, dim, n),\n            DType::F64 => crate::ops::fft::irfft_f64(spectrum_re, spectrum_im, dim, n),\n            DType::F16 => crate::ops::fft::irfft_f16(spectrum_re, spectrum_im, dim, n),\n            DType::BF16 => crate::ops::fft::irfft_bf16(spectrum_re, spectrum_im, dim, n),\n            dtype => panic!(\"irfft: unsupported dtype {:?}\", dtype),\n        }\n    }\n\n    fn embedding(weights: FloatTensor<Flex>, indices: IntTensor<Flex>) -> FloatTensor<Flex> {\n        let [batch_size, seq_length] = indices.shape().dims();\n        let [_, d_model] = weights.shape().dims();\n\n        let indices = Flex::int_reshape(indices, Shape::from(alloc::vec![batch_size * seq_length]));\n        let output = Flex::float_select(weights, 0, indices);\n        Flex::float_reshape(\n            output,\n            Shape::from(alloc::vec![batch_size, seq_length, d_model]),\n        )\n    }\n\n    fn layer_norm(\n        tensor: FloatTensor<Flex>,\n        gamma: FloatTensor<Flex>,","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/module.rs#L740-L776","documentation":"The burn-flex backend's `irfft` dispatches on the real-part spectrum tensor's dtype to a typed inverse-FFT kernel (F32, F64, F16, BF16). Any other dtype (integer, bool, quantized) has no inverse-FFT implementation, so the backend panics. Inverse FFT only supports floating-point spectra.","triggerScenarios":"Calling `Tensor::irfft(dim, n)` (or `fft_irfft`) where the spectrum_re tensor dtype is not F32/F64/F16/BF16 — e.g. a spectrum produced/rounded through an integer dtype, or a quantized spectrum tensor.","commonSituations":"Persisting a spectrum to disk as ints and reloading without casting; passing an integer-valued spectrum computed manually; backend mismatches that strip the float dtype.","solutions":["Cast both spectrum_re and spectrum_im to a floating dtype: `.cast(DType::F32)` before irfft.","Verify `spectrum_re.dtype()` is F32, F64, F16, or BF16.","If the spectrum came from rfft output that was cast, keep it in its original float dtype."],"exampleFix":"// before\nlet signal = spectrum_re_int.irfft(1, 1024);\n// after\nlet signal = spectrum_re_int.cast(DType::F32)\n    .irfft(1, 1024);","handlingStrategy":"validation","validationCode":"assert!(matches!(spectrum_re.dtype(), DType::F32 | DType::F64 | DType::F16 | DType::BF16), \"irfft requires a float dtype, got {:?}\", spectrum_re.dtype());","typeGuard":"fn is_float_dtype(d: DType) -> bool {\n    matches!(d, DType::F32 | DType::F64 | DType::F16 | DType::BF16)\n}","tryCatchPattern":null,"preventionTips":["Keep spectra in their original float dtype from rfft; avoid int round-trips.","Cast both re/im parts to the same float dtype before irfft.","When serializing spectra, record the dtype and restore it on load."],"tags":["rust","burn","fft","dtype","panic"],"backgroundTag":"unsupported-dtype","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}