{"record":{"id":"01730862620518ab","repo":"tracel-ai/burn","slug":"reduce-bool-dim-int-unsupported-dtype","errorCode":null,"errorMessage":"reduce_bool_dim_int: unsupported dtype {:?}","messagePattern":"reduce_bool_dim_int: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/comparison.rs","lineNumber":1068,"sourceCode":"    out_dtype: BoolDType,\n) -> FlexTensor {\n    let tensor = tensor.to_contiguous();\n    macro_rules! dispatch {\n        ($ty:ty) => {{\n            let data: &[$ty] = tensor.storage();\n            reduce_bool_dim_with(&tensor, dim, init, combine, out_dtype, |idx| data[idx] != 0)\n        }};\n    }\n    match tensor.dtype() {\n        DType::I64 => dispatch!(i64),\n        DType::I32 => dispatch!(i32),\n        DType::I16 => dispatch!(i16),\n        DType::I8 => dispatch!(i8),\n        DType::U64 => dispatch!(u64),\n        DType::U32 => dispatch!(u32),\n        DType::U16 => dispatch!(u16),\n        DType::U8 => dispatch!(u8),\n        other => panic!(\"reduce_bool_dim_int: unsupported dtype {:?}\", other),\n    }\n}\n\n/// Reduce along a dimension producing a bool tensor (for bool any/all_dim).\nfn reduce_bool_dim_raw(\n    tensor: &FlexTensor,\n    dim: usize,\n    init: bool,\n    combine: fn(bool, bool) -> bool,\n    out_dtype: BoolDType,\n) -> FlexTensor {\n    let tensor = tensor.to_contiguous();\n    let data: &[u8] = tensor.bytes();\n    reduce_bool_dim_with(&tensor, dim, init, combine, out_dtype, |idx| data[idx] != 0)\n}\n\n// Tests kept here probe flex-internal `reduce_bool_dim_with` dispatch on\n// non-contiguous inputs (stale-pointer-read regression, see prior incident","sourceCodeStart":1050,"sourceCodeEnd":1086,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/comparison.rs#L1050-L1086","documentation":"Dtype-dispatch exhaustiveness panic in `reduce_bool_dim_int`, the integer any/all-dim reduction: the match covers I64..U8; any other dtype (float/bool) reaching it panics, indicating an integer reduction was invoked on a non-integer tensor.","triggerScenarios":"Calling any_int_dim or all_int_dim with a float or bool tensor instead of one of the supported integer dtypes.","commonSituations":"Dim-wise any/all on float tensors misrouted to the int path; tensors converted to float upstream (normalization) before the reduction.","solutions":["Use any_float_dim/all_float_dim for float tensors","Cast the tensor to an integer dtype before the reduction","Check tensor.dtype() and branch to the correct reduce family"],"exampleFix":"// before\nlet col_all = all_int_dim(f32_tensor, 0, BoolDType::Native);\n// after\nlet col_all = all_float_dim(f32_tensor, 0, BoolDType::Native);","handlingStrategy":"type-guard","validationCode":"if !matches!(t.dtype(), DType::I64|DType::I32|DType::I16|DType::I8|DType::U64|DType::U32|DType::U16|DType::U8) { /* use any_float_dim/all_float_dim or cast */ }","typeGuard":"fn is_int_dtype(d: &DType) -> bool {\n    matches!(d, DType::I64|DType::I32|DType::I16|DType::I8|DType::U64|DType::U32|DType::U16|DType::U8)\n}","tryCatchPattern":null,"preventionTips":["Route float tensors to the *_float_dim variants","Verify dtypes after normalization/division ops that promote to float","Test dim-wise reductions for both dtype families"],"tags":["rust","burn","dtype","reduction","panic"],"backgroundTag":"unsupported-dtype","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}