{"record":{"id":"8ca27e767c2912f7","repo":"tracel-ai/burn","slug":"float-cumprod-unsupported-dtype","errorCode":null,"errorMessage":"float_cumprod: unsupported dtype {:?}","messagePattern":"float_cumprod: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/float.rs","lineNumber":786,"sourceCode":"            }\n            DType::BF16 => {\n                crate::ops::cumulative::cumsum_half(tensor, dim, bf16::to_f32, bf16::from_f32)\n            }\n            _ => panic!(\"float_cumsum: unsupported dtype {:?}\", tensor.dtype()),\n        }\n    }\n\n    fn float_cumprod(tensor: FloatTensor<Flex>, dim: usize) -> FloatTensor<Flex> {\n        match tensor.dtype() {\n            DType::F32 => crate::ops::cumulative::cumprod_f32(tensor, dim),\n            DType::F64 => crate::ops::cumulative::cumprod_f64(tensor, dim),\n            DType::F16 => {\n                crate::ops::cumulative::cumprod_half(tensor, dim, f16::to_f32, f16::from_f32)\n            }\n            DType::BF16 => {\n                crate::ops::cumulative::cumprod_half(tensor, dim, bf16::to_f32, bf16::from_f32)\n            }\n            _ => panic!(\"float_cumprod: unsupported dtype {:?}\", tensor.dtype()),\n        }\n    }\n\n    fn float_cummin(tensor: FloatTensor<Flex>, dim: usize) -> FloatTensor<Flex> {\n        match tensor.dtype() {\n            DType::F32 => crate::ops::cumulative::cummin_f32(tensor, dim),\n            DType::F64 => crate::ops::cumulative::cummin_f64(tensor, dim),\n            DType::F16 => {\n                crate::ops::cumulative::cummin_half(tensor, dim, f16::to_f32, f16::from_f32)\n            }\n            DType::BF16 => {\n                crate::ops::cumulative::cummin_half(tensor, dim, bf16::to_f32, bf16::from_f32)\n            }\n            _ => panic!(\"float_cummin: unsupported dtype {:?}\", tensor.dtype()),\n        }\n    }\n\n    fn float_cummax(tensor: FloatTensor<Flex>, dim: usize) -> FloatTensor<Flex> {","sourceCodeStart":768,"sourceCodeEnd":804,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/float.rs#L768-L804","documentation":"float_cumprod computes the running product, supporting F32/F64 directly and F16/BF16 via half-precision kernels that round-trip through f32. Any other dtype reaching the op panics with the dtype printed. The backend intentionally restricts cumprod to float tensors.","triggerScenarios":"Calling Tensor::cumprod (cumprod along a dim) on burn-flex with an Int/Bool or otherwise non-float tensor.","commonSituations":"Computing running products of integer factors; cumulative-product utilities typed generically and instantiated with Int; forgetting that cumprod needs floats for the f32-based kernel.","solutions":["Cast the tensor to a float dtype before cumprod, then cast back if needed.","Verify the input-producing ops did not return Int tensors (e.g. comparisons, casts, indexing).","Use f64 instead of f32 when integer-range overflow matters, since integers converted to f32 lose precision above 2^24.","Add an integer cumprod path in the flex backend if integral semantics are required."],"exampleFix":"// before\nlet p = factors.cumprod(0); // factors: I64 -> panic\n// after\nlet p = factors\n    .to_dtype(burn::tensor::FloatDType::F64)\n    .cumprod(0);","handlingStrategy":"validation","validationCode":"assert!(matches!(tensor.dtype(), DType::F32 | DType::F64 | DType::F16 | DType::BF16), \"cumprod needs a float tensor, got {:?}\", tensor.dtype());","typeGuard":"fn is_float_dtype(dtype: &DType) -> bool { matches!(dtype, DType::F32 | DType::F64 | DType::F16 | DType::BF16) }","tryCatchPattern":"// Validate before the op; Rust panics cannot be caught:\nif is_float_dtype(&tensor.dtype()) { let p = tensor.cumprod(dim); }","preventionTips":["Use F64 for cumprod when large integer factors could exceed f32 precision.","Cast explicitly after integer-producing ops before cumulative operations.","Prefer typed tensor kinds to catch wrong dtypes at compile time.","Add dtype assertions in scan/reduction utility wrappers."],"tags":["rust","dtype","panic","burn","cumprod"],"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"}