tracel-ai/burn · error
any_int: unsupported dtype {:?}
Error message
any_int: unsupported dtype {:?} What it means
Dtype-dispatch exhaustiveness panic: `any_int` covers all signed/unsigned integer dtypes; a float or bool tensor reaching this int any-reduction hits the fallback panic, indicating a misrouted op in the Flex backend's op table.
Source
Thrown at crates/burn-flex/src/ops/comparison.rs:892
}
/// Check if all elements along a dimension are non-zero (float tensors).
pub fn all_float_dim(tensor: FlexTensor, dim: usize, out_dtype: BoolDType) -> FlexTensor {
reduce_bool_dim(&tensor, dim, true, |a, b| a && b, out_dtype)
}
/// Check if any element is non-zero (int tensors).
pub fn any_int(tensor: FlexTensor, out_dtype: BoolDType) -> FlexTensor {
let has_any = match tensor.dtype() {
DType::I64 => iter_elements::<i64>(&tensor).any(|x| x != 0),
DType::I32 => iter_elements::<i32>(&tensor).any(|x| x != 0),
DType::I16 => iter_elements::<i16>(&tensor).any(|x| x != 0),
DType::I8 => iter_elements::<i8>(&tensor).any(|x| x != 0),
DType::U64 => iter_elements::<u64>(&tensor).any(|x| x != 0),
DType::U32 => iter_elements::<u32>(&tensor).any(|x| x != 0),
DType::U16 => iter_elements::<u16>(&tensor).any(|x| x != 0),
DType::U8 => iter_elements::<u8>(&tensor).any(|x| x != 0),
_ => panic!("any_int: unsupported dtype {:?}", tensor.dtype()),
};
bool_scalar(has_any, out_dtype)
}
/// 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),View on GitHub (pinned to d16f7ba2ed)
Solutions
- Check the dtype and call any_float for float tensors instead
- Cast the tensor to an integer dtype if int semantics are intended
- Assert the dtype family before dispatching to any_int/any_float
Example fix
// before let has_any = any_int(f32_tensor, BoolDType::Native); // after let has_any = any_float(f32_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 any_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
- Dispatch any_int/any_float by dtype family
- Avoid passing floats to int reductions expecting truncation — it panics
- Unit-test reduction helpers with both float and int tensors
When it happens
Trigger: Calling the public any_int(tensor, out_dtype) with a float (F32/F64/F16/BF16) or Bool tensor.
Common situations: Passing float tensors to the int variant by mistake; generic reduction helpers that don't branch on dtype family.
Related errors
- any_float: unsupported dtype {:?}
- all_float: unsupported dtype {:?}
- all_int: unsupported dtype {:?}
- reduce_bool_dim: unsupported dtype {:?}
- reduce_bool_dim_int: unsupported dtype {:?}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/4f5249acffaad3b0.
Report an issue: GitHub.