{"record":{"id":"2e9f68f4ce10702f","repo":"tracel-ai/burn","slug":"unsupported-type","errorCode":null,"errorMessage":"Unsupported type {:?}","messagePattern":"Unsupported type (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-cubecl/src/kernel/fft/base.rs","lineNumber":42,"sourceCode":"        return slice(tensor, &ranges);\n    }\n    let mut padded_shape = shape.clone();\n    padded_shape[dim] = target;\n    let padded = zeros(tensor.device.clone(), padded_shape, tensor.dtype);\n    let slices: Vec<Slice> = shape.iter().map(|&s| Slice::from(0..s)).collect();\n    crate::kernel::index::slice_assign(padded, &slices, tensor)\n}\n\n/// Launch the rfft kernel with optional padding for non-power-of-two sizes.\n///\n/// Signal is first truncated or zero-padded to `n` (when provided), then internally\n/// padded to the next power of two so the kernel operates on a pow2 length.\n/// Output bin count is `fft_size / 2 + 1` where `fft_size = next_pow2(n)`.\npub fn rfft(signal: CubeTensor, dim: usize, n: Option<usize>) -> (CubeTensor, CubeTensor) {\n    let dtype = match signal.dtype {\n        DType::F64 => f64::elem_type_native(),\n        DType::F32 => f32::elem_type_native(),\n        _ => panic!(\"Unsupported type {:?}\", signal.dtype),\n    };\n\n    let input_device = signal.device.clone();\n    let input_dtype = signal.dtype;\n    let input_shape = signal.shape();\n    let requested_n = n.unwrap_or(input_shape[dim]);\n    let fft_size = requested_n.next_power_of_two();\n\n    // Truncate/pad to requested_n, THEN pad to fft_size; otherwise for\n    // requested_n < input_len < fft_size we would keep bogus samples in [n, fft_size).\n    let signal = pad_to_length(signal, dim, requested_n);\n    let signal = pad_to_length(signal, dim, fft_size);\n\n    let signal_shape = signal.shape();\n    let mut output_shape = signal_shape.clone();\n    output_shape[dim] = fft_size / 2 + 1;\n\n    let output_re = empty_device_dtype(","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-cubecl/src/kernel/fft/base.rs#L24-L60","documentation":"`rfft` only supports floating-point inputs (F32/F64) because the FFT kernel is written for real float element types. Any other dtype (integer, bool, F16/BF16 if unlisted) triggers this panic before launch.","triggerScenarios":"Calling `tensor.rfft(dim, n)` on a tensor whose dtype is not F32 or F64.","commonSituations":"FFT on integer data (e.g. raw audio samples loaded as i16/i32); half-precision tensors from mixed-precision training; forgetting `.float()` conversion after decoding data.","solutions":["Convert the input with `.float()` (or `.to_dtype(DType::F32)`) before calling rfft","Cast to F64 only if double precision is genuinely needed","Cast integer audio data to float and normalize before the transform"],"exampleFix":"// before\nlet (re, im) = samples_i32.rfft(0, None); // panics\n// after\nlet (re, im) = samples_i32.float().rfft(0, None);","handlingStrategy":"validation","validationCode":"assert!(matches!(signal.dtype(), DType::F32 | DType::F64), \"rfft needs F32/F64\");","typeGuard":"fn fft_supported(t: &TensorBase) -> bool { matches!(t.dtype(), DType::F32 | DType::F64) }","tryCatchPattern":null,"preventionTips":["Always .float() non-float inputs before spectral ops","Watch for dtype drift in mixed-precision pipelines","Prefer F32 unless double precision is required"],"tags":["gpu","fft","dtype","validation"],"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"}