tracel-ai/burn · error
int_cumsum: unsupported dtype {:?}
Error message
int_cumsum: unsupported dtype {:?} What it means
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.
Source
Thrown at crates/burn-flex/src/ops/int.rs:696
fn int_prod_dim(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {
crate::ops::reduce::prod_dim(tensor, dim)
}
fn int_mean_dim(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {
crate::ops::reduce::mean_dim(tensor, dim)
}
fn int_cumsum(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {
match tensor.dtype() {
DType::I64 => crate::ops::cumulative::cumsum::<i64>(tensor, dim),
DType::I32 => crate::ops::cumulative::cumsum::<i32>(tensor, dim),
DType::I16 => crate::ops::cumulative::cumsum::<i16>(tensor, dim),
DType::I8 => crate::ops::cumulative::cumsum::<i8>(tensor, dim),
DType::U64 => crate::ops::cumulative::cumsum::<u64>(tensor, dim),
DType::U32 => crate::ops::cumulative::cumsum::<u32>(tensor, dim),
DType::U16 => crate::ops::cumulative::cumsum::<u16>(tensor, dim),
DType::U8 => crate::ops::cumulative::cumsum::<u8>(tensor, dim),
dt => panic!("int_cumsum: unsupported dtype {:?}", dt),
}
}
fn int_cumprod(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {
match tensor.dtype() {
DType::I64 => crate::ops::cumulative::cumprod::<i64>(tensor, dim),
DType::I32 => crate::ops::cumulative::cumprod::<i32>(tensor, dim),
DType::I16 => crate::ops::cumulative::cumprod::<i16>(tensor, dim),
DType::I8 => crate::ops::cumulative::cumprod::<i8>(tensor, dim),
DType::U64 => crate::ops::cumulative::cumprod::<u64>(tensor, dim),
DType::U32 => crate::ops::cumulative::cumprod::<u32>(tensor, dim),
DType::U16 => crate::ops::cumulative::cumprod::<u16>(tensor, dim),
DType::U8 => crate::ops::cumulative::cumprod::<u8>(tensor, dim),
dt => panic!("int_cumprod: unsupported dtype {:?}", dt),
}
}
fn int_cummin(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {View on GitHub (pinned to d16f7ba2ed)
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.
Example fix
// before let out = int_tensor.cumsum(dim); // panics if dtype is F32 // after assert!(matches!(int_tensor.dtype(), DType::I64 | DType::I32 | _ if int_tensor.dtype().is_int())); let out = int_tensor.cast::<i64>().cumsum(dim);
Defensive patterns
Strategy: validation
Validate before calling
assert!(t.dtype().is_int(), "cumsum requires an int tensor, got {:?}", t.dtype()); Type guard
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) } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- float_cumsum: unsupported dtype {:?}
- burn-flex does not support Bool(U32) storage (only Native an
- compare_int: unsupported dtype {:?}
- compare_int_elem: unsupported dtype {:?}
- any_float: unsupported dtype {:?}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/93e64cc9cf17a381.
Report an issue: GitHub.