tracel-ai/burn · error

int_cummax: unsupported dtype {:?}

Error message

int_cummax: unsupported dtype {:?}

What it means

int_cummax computes the running maximum along a dimension for each supported integer dtype (I64..U8). The panic fires when the tensor dtype is not an integer type (float/bool), indicating a non-integer tensor reached the integer cumulative-max path. It is the same dtype-dispatch guard pattern used by the other cumulative ops.

Source

Thrown at crates/burn-flex/src/ops/int.rs:738

            DType::U64 => crate::ops::cumulative::cummin::<u64>(tensor, dim),
            DType::U32 => crate::ops::cumulative::cummin::<u32>(tensor, dim),
            DType::U16 => crate::ops::cumulative::cummin::<u16>(tensor, dim),
            DType::U8 => crate::ops::cumulative::cummin::<u8>(tensor, dim),
            dt => panic!("int_cummin: unsupported dtype {:?}", dt),
        }
    }

    fn int_cummax(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {
        match tensor.dtype() {
            DType::I64 => crate::ops::cumulative::cummax::<i64>(tensor, dim),
            DType::I32 => crate::ops::cumulative::cummax::<i32>(tensor, dim),
            DType::I16 => crate::ops::cumulative::cummax::<i16>(tensor, dim),
            DType::I8 => crate::ops::cumulative::cummax::<i8>(tensor, dim),
            DType::U64 => crate::ops::cumulative::cummax::<u64>(tensor, dim),
            DType::U32 => crate::ops::cumulative::cummax::<u32>(tensor, dim),
            DType::U16 => crate::ops::cumulative::cummax::<u16>(tensor, dim),
            DType::U8 => crate::ops::cumulative::cummax::<u8>(tensor, dim),
            dt => panic!("int_cummax: unsupported dtype {:?}", dt),
        }
    }

    fn int_argmax(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {
        crate::ops::reduce::argmax(tensor, dim)
    }

    fn int_argmin(tensor: IntTensor<Flex>, dim: usize) -> IntTensor<Flex> {
        crate::ops::reduce::argmin(tensor, dim)
    }

    fn int_abs(tensor: IntTensor<Flex>) -> IntTensor<Flex> {
        crate::ops::unary::int_abs(tensor)
    }

    fn bitwise_and(lhs: IntTensor<Flex>, rhs: IntTensor<Flex>) -> IntTensor<Flex> {
        int_binary_op(lhs, rhs, |a, b| a & b)
    }

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Check the dtype before the call and cast to an integer dtype if the values are logically integer.
  2. Use the float reduce path (max_dim / cumulative max on floats) for float tensors.
  3. Pin dtypes with explicit .cast::<i64>() calls after dtype-promoting operations.
  4. Add dtype assertions in tests covering the affected pipeline.

Example fix

// before
let out = t.cummax(dim); // t is F64 -> panic
// after
let out_i = t.cast::<i64>();
let out = out_i.cummax(dim);
Defensive patterns

Strategy: validation

Validate before calling

assert!(t.dtype().is_int(), "cummax 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

When it happens

Trigger: Calling cummax (int_cummax) on a Flex tensor with dtype F32/F64/F16/BF16 or Bool.

Common situations: Framework ports where cummax handles all dtypes; tensors promoted to float by a previous op (division, cast); data loaders inferring float dtype for integer columns.

Related errors


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/d4f681c1d356ddac. Report an issue: GitHub.