{"record":{"id":"0979b1412cbe96c7","repo":"tracel-ai/burn","slug":"reduce-bool-dim-unsupported-dtype","errorCode":null,"errorMessage":"reduce_bool_dim: unsupported dtype {:?}","messagePattern":"reduce_bool_dim: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/comparison.rs","lineNumber":1040,"sourceCode":"        DType::F64 => {\n            let data: &[f64] = tensor.storage();\n            reduce_bool_dim_with(&tensor, dim, init, combine, out_dtype, |idx| {\n                data[idx] != 0.0\n            })\n        }\n        DType::F16 => {\n            let data: &[f16] = tensor.storage();\n            reduce_bool_dim_with(&tensor, dim, init, combine, out_dtype, |idx| {\n                data[idx].to_f32() != 0.0\n            })\n        }\n        DType::BF16 => {\n            let data: &[bf16] = tensor.storage();\n            reduce_bool_dim_with(&tensor, dim, init, combine, out_dtype, |idx| {\n                data[idx].to_f32() != 0.0\n            })\n        }\n        _ => panic!(\"reduce_bool_dim: unsupported dtype {:?}\", tensor.dtype()),\n    }\n}\n\n/// Reduce along a dimension producing a bool tensor (for int any/all_dim).\nfn reduce_bool_dim_int(\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    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    }","sourceCodeStart":1022,"sourceCodeEnd":1058,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/comparison.rs#L1022-L1058","documentation":"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.","triggerScenarios":"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.","commonSituations":"Dim-wise any/all on masks stored as U8 or on int tensors; generic code that picks any_float_dim without inspecting dtype.","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"],"exampleFix":"// before\nlet row_any = any_float_dim(u8_tensor, 1, BoolDType::Native);\n// after\nlet row_any = any_int_dim(u8_tensor, 1, BoolDType::Native);","handlingStrategy":"type-guard","validationCode":"if !matches!(t.dtype(), DType::F32|DType::F64|DType::F16|DType::BF16) { /* use any_int_dim/all_int_dim or cast */ }","typeGuard":"fn is_float_dtype(d: &DType) -> bool {\n    matches!(d, DType::F32|DType::F64|DType::F16|DType::BF16)\n}","tryCatchPattern":null,"preventionTips":["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"],"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"}