tracel-ai/burn · error

all_int: unsupported dtype {:?}

Error message

all_int: unsupported dtype {:?}

What it means

Dtype-dispatch exhaustiveness panic: `all_int` supports the full integer dtype set and panics for any non-integer dtype, meaning the Flex backend received an int all-reduction request for a tensor of the wrong kind.

Source

Thrown at crates/burn-flex/src/ops/comparison.rs:913

}

/// Check if any element along a dimension is non-zero (int tensors).
pub fn any_int_dim(tensor: FlexTensor, dim: usize, out_dtype: BoolDType) -> FlexTensor {
    reduce_bool_dim_int(&tensor, dim, false, |a, b| a || b, out_dtype)
}

/// Check if all elements are non-zero (int tensors).
pub fn all_int(tensor: FlexTensor, out_dtype: BoolDType) -> FlexTensor {
    let all = match tensor.dtype() {
        DType::I64 => iter_elements::<i64>(&tensor).all(|x| x != 0),
        DType::I32 => iter_elements::<i32>(&tensor).all(|x| x != 0),
        DType::I16 => iter_elements::<i16>(&tensor).all(|x| x != 0),
        DType::I8 => iter_elements::<i8>(&tensor).all(|x| x != 0),
        DType::U64 => iter_elements::<u64>(&tensor).all(|x| x != 0),
        DType::U32 => iter_elements::<u32>(&tensor).all(|x| x != 0),
        DType::U16 => iter_elements::<u16>(&tensor).all(|x| x != 0),
        DType::U8 => iter_elements::<u8>(&tensor).all(|x| x != 0),
        _ => panic!("all_int: unsupported dtype {:?}", tensor.dtype()),
    };
    bool_scalar(all, out_dtype)
}

/// Check if all elements along a dimension are non-zero (int tensors).
pub fn all_int_dim(tensor: FlexTensor, dim: usize, out_dtype: BoolDType) -> FlexTensor {
    reduce_bool_dim_int(&tensor, dim, true, |a, b| a && b, out_dtype)
}

/// Check if any bool element is true.
pub fn any_bool(tensor: FlexTensor, out_dtype: BoolDType) -> FlexTensor {
    let tensor = tensor.to_contiguous();
    let data: &[u8] = tensor.bytes();
    bool_scalar(data.iter().any(|&x| x != 0), out_dtype)
}

/// Check if any bool element along a dimension is true.
pub fn any_bool_dim(tensor: FlexTensor, dim: usize, out_dtype: BoolDType) -> FlexTensor {

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Route float tensors to all_float instead
  2. Cast to an integer dtype first if appropriate
  3. Add a dtype check/assert before calling all_int

Example fix

// before
let all = all_int(f64_tensor, BoolDType::Native);
// after
let all = all_float(f64_tensor, BoolDType::Native);
Defensive patterns

Strategy: type-guard

Validate before calling

if !matches!(t.dtype(), DType::I64|DType::I32|DType::I16|DType::I8|DType::U64|DType::U32|DType::U16|DType::U8) { /* route to all_float or cast */ }

Type guard

fn is_int_dtype(d: &DType) -> bool {
    matches!(d, DType::I64|DType::I32|DType::I16|DType::I8|DType::U64|DType::U32|DType::U16|DType::U8)
}

Prevention

When it happens

Trigger: Calling the public all_int(tensor, out_dtype) with a float or Bool tensor.

Common situations: Symmetric mistake to any_int: float tensor routed into the int reduction; dtype drifted upstream to F32 after a division/normalization.

Related errors


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