{"record":{"id":"ae8704dbde6e1c40","repo":"tracel-ai/burn","slug":"all-float-unsupported-dtype","errorCode":null,"errorMessage":"all_float: unsupported dtype {:?}","messagePattern":"all_float: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/comparison.rs","lineNumber":871,"sourceCode":"        DType::BF16 => iter_elements::<bf16>(&tensor).any(|x: bf16| x.to_f32() != 0.0),\n        _ => panic!(\"any_float: unsupported dtype {:?}\", tensor.dtype()),\n    };\n    bool_scalar(has_any, out_dtype)\n}\n\n/// Check if any element along a dimension is non-zero (float tensors).\npub fn any_float_dim(tensor: FlexTensor, dim: usize, out_dtype: BoolDType) -> FlexTensor {\n    reduce_bool_dim(&tensor, dim, false, |a, b| a || b, out_dtype)\n}\n\n/// Check if all elements are non-zero (float tensors).\npub fn all_float(tensor: FlexTensor, out_dtype: BoolDType) -> FlexTensor {\n    let all = match tensor.dtype() {\n        DType::F32 => iter_elements::<f32>(&tensor).all(|x| x != 0.0),\n        DType::F64 => iter_elements::<f64>(&tensor).all(|x| x != 0.0),\n        DType::F16 => iter_elements::<f16>(&tensor).all(|x: f16| x.to_f32() != 0.0),\n        DType::BF16 => iter_elements::<bf16>(&tensor).all(|x: bf16| x.to_f32() != 0.0),\n        _ => panic!(\"all_float: unsupported dtype {:?}\", tensor.dtype()),\n    };\n    bool_scalar(all, out_dtype)\n}\n\n/// Check if all elements along a dimension are non-zero (float tensors).\npub fn all_float_dim(tensor: FlexTensor, dim: usize, out_dtype: BoolDType) -> FlexTensor {\n    reduce_bool_dim(&tensor, dim, true, |a, b| a && b, out_dtype)\n}\n\n/// Check if any element is non-zero (int tensors).\npub fn any_int(tensor: FlexTensor, out_dtype: BoolDType) -> FlexTensor {\n    let has_any = match tensor.dtype() {\n        DType::I64 => iter_elements::<i64>(&tensor).any(|x| x != 0),\n        DType::I32 => iter_elements::<i32>(&tensor).any(|x| x != 0),\n        DType::I16 => iter_elements::<i16>(&tensor).any(|x| x != 0),\n        DType::I8 => iter_elements::<i8>(&tensor).any(|x| x != 0),\n        DType::U64 => iter_elements::<u64>(&tensor).any(|x| x != 0),\n        DType::U32 => iter_elements::<u32>(&tensor).any(|x| x != 0),","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/comparison.rs#L853-L889","documentation":"Dtype-dispatch exhaustiveness panic: `all_float` (all non-zero over a float tensor) supports only F32/F64/F16/BF16 and panics on any other dtype, signaling that a non-float tensor was dispatched into the float all-reduction path.","triggerScenarios":"Calling the public all_float(tensor, out_dtype) with an integer or Bool tensor.","commonSituations":"Generic any/all helper code that passes any tensor to all_float; a dtype change upstream (int cast, mask stored as U8) before the reduction call.","solutions":["Verify the dtype is float before calling; use all_int for integer tensors","Cast to F32 if float semantics are fine","Fix upstream dtype conversion so the tensor remains float"],"exampleFix":"// before\nlet all = all_float(u8_mask, BoolDType::Native);\n// after\nlet all = all_int(u8_mask, BoolDType::Native);","handlingStrategy":"type-guard","validationCode":"if !matches!(t.dtype(), DType::F32|DType::F64|DType::F16|DType::BF16) { /* route to all_int 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":["Mirror the any/all dispatch: all_float for floats, all_int for ints","Assert float dtype before reductions in generic helpers","Keep masks in float if you plan to use float reductions on them"],"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"}