{"record":{"id":"93e64cc9cf17a381","repo":"tracel-ai/burn","slug":"int-cumsum-unsupported-dtype","errorCode":null,"errorMessage":"int_cumsum: unsupported dtype {:?}","messagePattern":"int_cumsum: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/int.rs","lineNumber":696,"sourceCode":"    fn int_prod_dim(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {\n        crate::ops::reduce::prod_dim(tensor, dim)\n    }\n\n    fn int_mean_dim(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {\n        crate::ops::reduce::mean_dim(tensor, dim)\n    }\n\n    fn int_cumsum(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {\n        match tensor.dtype() {\n            DType::I64 => crate::ops::cumulative::cumsum::<i64>(tensor, dim),\n            DType::I32 => crate::ops::cumulative::cumsum::<i32>(tensor, dim),\n            DType::I16 => crate::ops::cumulative::cumsum::<i16>(tensor, dim),\n            DType::I8 => crate::ops::cumulative::cumsum::<i8>(tensor, dim),\n            DType::U64 => crate::ops::cumulative::cumsum::<u64>(tensor, dim),\n            DType::U32 => crate::ops::cumulative::cumsum::<u32>(tensor, dim),\n            DType::U16 => crate::ops::cumulative::cumsum::<u16>(tensor, dim),\n            DType::U8 => crate::ops::cumulative::cumsum::<u8>(tensor, dim),\n            dt => panic!(\"int_cumsum: unsupported dtype {:?}\", dt),\n        }\n    }\n\n    fn int_cumprod(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {\n        match tensor.dtype() {\n            DType::I64 => crate::ops::cumulative::cumprod::<i64>(tensor, dim),\n            DType::I32 => crate::ops::cumulative::cumprod::<i32>(tensor, dim),\n            DType::I16 => crate::ops::cumulative::cumprod::<i16>(tensor, dim),\n            DType::I8 => crate::ops::cumulative::cumprod::<i8>(tensor, dim),\n            DType::U64 => crate::ops::cumulative::cumprod::<u64>(tensor, dim),\n            DType::U32 => crate::ops::cumulative::cumprod::<u32>(tensor, dim),\n            DType::U16 => crate::ops::cumulative::cumprod::<u16>(tensor, dim),\n            DType::U8 => crate::ops::cumulative::cumprod::<u8>(tensor, dim),\n            dt => panic!(\"int_cumprod: unsupported dtype {:?}\", dt),\n        }\n    }\n\n    fn int_cummin(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/int.rs#L678-L714","documentation":"int_cumsum dispatches to the generic cumsum implementation for each supported integer dtype (I64..U8). The panic arm is only reachable when the tensor's dtype is not one of the eight integer dtypes — i.e. a float or bool tensor was passed to the integer cumulative-sum path. It is a defensive guard indicating the wrong tensor kind reached this op.","triggerScenarios":"Calling Tensor::cumsum (or int_cumsum via the backend) on a Flex tensor whose dtype is F32/F64/F16/BF16/Bool instead of an integer dtype.","commonSituations":"Applying cumsum to a float tensor expecting PyTorch-like generic behavior; dtype drift after an operation (e.g. division produced floats); loading data whose dtype was inferred as float but treated as int downstream.","solutions":["Verify tensor.dtype() is an integer type before calling cumsum; cast to i64/i32 first if needed.","Use the float tensor's cumsum/sum_dim path for float tensors instead of the int one.","Fix upstream ops (e.g. division, casts) that changed the tensor's dtype unexpectedly.","Assert the dtype at pipeline boundaries to fail early with a clearer message."],"exampleFix":"// before\nlet out = int_tensor.cumsum(dim); // panics if dtype is F32\n// after\nassert!(matches!(int_tensor.dtype(), DType::I64 | DType::I32 | _ if int_tensor.dtype().is_int()));\nlet out = int_tensor.cast::<i64>().cumsum(dim);","handlingStrategy":"validation","validationCode":"assert!(t.dtype().is_int(), \"cumsum requires an int tensor, got {:?}\", t.dtype());","typeGuard":"fn is_int_tensor(t: &FlexTensor) -> bool { matches!(t.dtype(), DType::I64 | DType::I32 | DType::I16 | DType::I8 | DType::U64 | DType::U32 | DType::U16 | DType::U8) }","tryCatchPattern":null,"preventionTips":["Cast to i64 before cumulative ops when dtype is uncertain","Assert dtypes at pipeline boundaries when porting from PyTorch","Track dtype-promoting ops (division, cast) upstream of reductions"],"tags":["rust","burn","dtype","cumsum"],"backgroundTag":"unsupported-dtype-for-op","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"}