tracel-ai/burn · error
reduce_bool_dim: unsupported dtype {:?}
Error message
reduce_bool_dim: unsupported dtype {:?} What it means
Dtype-dispatch exhaustiveness panic in `reduce_bool_dim`, the shared float any/all-dim reduction: only float dtypes are handled; a non-float tensor reaching it panics. Since it is called by any_float_dim/all_float_dim, hitting this implies an op-dispatch bug rather than user error.
Source
Thrown at crates/burn-flex/src/ops/comparison.rs:1040
DType::F64 => {
let data: &[f64] = tensor.storage();
reduce_bool_dim_with(&tensor, dim, init, combine, out_dtype, |idx| {
data[idx] != 0.0
})
}
DType::F16 => {
let data: &[f16] = tensor.storage();
reduce_bool_dim_with(&tensor, dim, init, combine, out_dtype, |idx| {
data[idx].to_f32() != 0.0
})
}
DType::BF16 => {
let data: &[bf16] = tensor.storage();
reduce_bool_dim_with(&tensor, dim, init, combine, out_dtype, |idx| {
data[idx].to_f32() != 0.0
})
}
_ => panic!("reduce_bool_dim: unsupported dtype {:?}", tensor.dtype()),
}
}
/// Reduce along a dimension producing a bool tensor (for int any/all_dim).
fn reduce_bool_dim_int(
tensor: &FlexTensor,
dim: usize,
init: bool,
combine: fn(bool, bool) -> bool,
out_dtype: BoolDType,
) -> FlexTensor {
let tensor = tensor.to_contiguous();
macro_rules! dispatch {
($ty:ty) => {{
let data: &[$ty] = tensor.storage();
reduce_bool_dim_with(&tensor, dim, init, combine, out_dtype, |idx| data[idx] != 0)
}};
}View on GitHub (pinned to d16f7ba2ed)
Solutions
- Use any_int_dim/all_int_dim for integer tensors
- Cast the tensor to F32 before the dim-wise float reduction
- Assert the dtype is a float variant before calling
Example fix
// before let row_any = any_float_dim(u8_tensor, 1, BoolDType::Native); // after let row_any = any_int_dim(u8_tensor, 1, BoolDType::Native);
Defensive patterns
Strategy: type-guard
Validate before calling
if !matches!(t.dtype(), DType::F32|DType::F64|DType::F16|DType::BF16) { /* use any_int_dim/all_int_dim or cast */ } Type guard
fn is_float_dtype(d: &DType) -> bool {
matches!(d, DType::F32|DType::F64|DType::F16|DType::BF16)
} Prevention
- Choose _float_dim vs _int_dim variants by dtype before the dim-wise reduction
- Assert dtype in wrappers over any_float_dim/all_float_dim
- Keep U8 masks with the int variants, not the float ones
When it happens
Trigger: Calling any_float_dim or all_float_dim with a tensor whose dtype is not F32/F64/F16/BF16 — typically an integer or bool tensor.
Common situations: Dim-wise any/all on masks stored as U8 or on int tensors; generic code that picks any_float_dim without inspecting dtype.
Related errors
- any_float: unsupported dtype {:?}
- all_float: unsupported dtype {:?}
- any_int: unsupported dtype {:?}
- all_int: unsupported dtype {:?}
- reduce_bool_dim_int: unsupported dtype {:?}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/0979b1412cbe96c7.
Report an issue: GitHub.