{"record":{"id":"f9e87153c3d9540d","repo":"tracel-ai/burn","slug":"rfft-unsupported-dtype","errorCode":null,"errorMessage":"rfft: unsupported dtype {:?}","messagePattern":"rfft: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/module.rs","lineNumber":743,"sourceCode":"        value: FloatTensor<Flex>,\n        mask: Option<BoolTensor<Flex>>,\n        attn_bias: Option<FloatTensor<Flex>>,\n        options: AttentionModuleOptions,\n    ) -> FloatTensor<Flex> {\n        crate::ops::attention::attention(query, key, value, mask, attn_bias, options)\n    }\n\n    fn rfft(\n        signal: FloatTensor<Flex>,\n        dim: usize,\n        n: Option<usize>,\n    ) -> (FloatTensor<Flex>, FloatTensor<Flex>) {\n        match signal.dtype() {\n            DType::F32 => crate::ops::fft::rfft_f32(signal, dim, n),\n            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","sourceCodeStart":725,"sourceCodeEnd":761,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/module.rs#L725-L761","documentation":"The burn-flex backend's `rfft` dispatches on the input tensor's dtype to a typed FFT implementation (F32, F64, F16, BF16). If the tensor carries any other dtype (e.g. an integer or quantized dtype), no FFT kernel exists and the backend panics. FFT is only defined for floating-point inputs.","triggerScenarios":"Calling `Tensor::rfft(dim, n)` (or the FloatTensorOperations `fft_rfft` entry) on a tensor whose dtype is not one of F32/F64/F16/BF16 — e.g. after casting a real-valued signal to an integer dtype, or passing a tensor with a DType::QFloat quantized dtype.","commonSituations":"Casting audio/signal tensors to int for storage and forgetting to cast back before FFT; mixing backends where an integer tensor leaks into a float-only op; using a dtype inferred from loaded data (e.g. i64 indices) instead of the model's float dtype.","solutions":["Cast the input tensor to a floating dtype before calling rfft: `tensor.cast(DType::F32)`.","Check `tensor.dtype()` and ensure it is F32, F64, F16, or BF16.","If the dtype came from data loading, add `.cast(YOUR_FLOAT_DTYPE)` right after tensor creation."],"exampleFix":"// before\nlet spectrum = signal.rfft(1, 1024); // signal dtype = I64\n// after\nlet spectrum = signal.cast(DType::F32).rfft(1, 1024);","handlingStrategy":"validation","validationCode":"assert!(matches!(signal.dtype(), DType::F32 | DType::F64 | DType::F16 | DType::BF16), \"rfft requires a float dtype, got {:?}\", signal.dtype());","typeGuard":"fn is_float_dtype(d: DType) -> bool {\n    matches!(d, DType::F32 | DType::F64 | DType::F16 | DType::BF16)\n}","tryCatchPattern":null,"preventionTips":["Always `.cast(DType::F32)` signal tensors before FFT ops.","Cast immediately after loading data from files or other backends.","Standardize on F32 for signal-processing pipelines."],"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"}