{"record":{"id":"109522a5490ce9ce","repo":"tracel-ai/burn","slug":"float-cumsum-unsupported-dtype","errorCode":null,"errorMessage":"float_cumsum: unsupported dtype {:?}","messagePattern":"float_cumsum: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/float.rs","lineNumber":772,"sourceCode":"    fn float_prod(tensor: FloatTensor<Flex>) -> FloatTensor<Flex> {\n        crate::ops::reduce::prod(tensor)\n    }\n\n    fn float_prod_dim(tensor: FloatTensor<Flex>, dim: usize) -> FloatTensor<Flex> {\n        crate::ops::reduce::prod_dim(tensor, dim)\n    }\n\n    fn float_cumsum(tensor: FloatTensor<Flex>, dim: usize) -> FloatTensor<Flex> {\n        match tensor.dtype() {\n            DType::F32 => crate::ops::cumulative::cumsum_f32(tensor, dim),\n            DType::F64 => crate::ops::cumulative::cumsum_f64(tensor, dim),\n            DType::F16 => {\n                crate::ops::cumulative::cumsum_half(tensor, dim, f16::to_f32, f16::from_f32)\n            }\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> {","sourceCodeStart":754,"sourceCodeEnd":790,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/float.rs#L754-L790","documentation":"float_cumsum computes the cumulative sum; F32/F64 use the f32 kernels and F16/BF16 go through cumsum_half with f32 round-tripping. The final match arm panics for any other dtype. Reaching it means a non-float tensor was fed to the float cumulative-sum op.","triggerScenarios":"Calling Tensor::cumsum (or cumsum_along_dim) on the burn-flex backend with a tensor whose dtype is not F32/F64/F16/BF16, e.g. an Int tensor.","commonSituations":"Cumulative counts over integer tensors; applying cumsum right after argmax/top-k without casting; generic ML code where the tensor kind was inferred as Int.","solutions":["Cast to float before cumsum: tensor.to_dtype(FloatDType::F32).cumsum(dim).","Compute cumsum on int tensors via float and cast back if exact int sums within range are acceptable.","Inspect the producing op to see why the tensor is not float; fix the dtype at the source.","Add an int cumsum implementation and dtype arm in crates/burn-flex/src/ops/float.rs / cumulative.rs."],"exampleFix":"// before\nlet c = counts.cumsum(1); // counts: Int tensor -> panic\n// after\nlet c = counts\n    .to_dtype(burn::tensor::FloatDType::F32)\n    .cumsum(1);","handlingStrategy":"validation","validationCode":"assert!(matches!(tensor.dtype(), DType::F32 | DType::F64 | DType::F16 | DType::BF16), \"cumsum 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":"// Panics are fatal; validate first:\nif is_float_dtype(&tensor.dtype()) { let c = tensor.cumsum(dim); }","preventionTips":["Cast counts/indices to float before any cumulative op.","Remember F16/BF16 cumsum round-trips through f32; use F32/F64 for precision-sensitive sums.","Type cumulative-scan helpers as Tensor<B, D, Float>.","Test with the exact dtype configuration of your training/inference pipeline."],"tags":["rust","dtype","panic","burn","cumsum"],"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"}