{"record":{"id":"e50ceec52f0aff82","repo":"tracel-ai/burn","slug":"any-float-unsupported-dtype","errorCode":null,"errorMessage":"any_float: unsupported dtype {:?}","messagePattern":"any_float: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/comparison.rs","lineNumber":854,"sourceCode":"    let result: Vec<u8> = data\n        .iter()\n        .map(|&a| if a != rhs_val { 1 } else { 0 })\n        .collect();\n    make_bool_tensor(result, shape, out_dtype)\n}\n\n// ============================================================================\n// any / all operations\n// ============================================================================\n\n/// Check if any element is non-zero (float tensors).\npub fn any_float(tensor: FlexTensor, out_dtype: BoolDType) -> FlexTensor {\n    let has_any = match tensor.dtype() {\n        DType::F32 => iter_elements::<f32>(&tensor).any(|x| x != 0.0),\n        DType::F64 => iter_elements::<f64>(&tensor).any(|x| x != 0.0),\n        DType::F16 => iter_elements::<f16>(&tensor).any(|x: f16| x.to_f32() != 0.0),\n        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    };","sourceCodeStart":836,"sourceCodeEnd":872,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/comparison.rs#L836-L872","documentation":"Dtype-dispatch exhaustiveness panic: `any_float` (any non-zero over a float tensor) only handles F32/F64/F16/BF16; any other dtype reaching the float any-op triggers the panic, implying a kernel-dispatch bug that routed a non-float tensor into the float reduction.","triggerScenarios":"Calling the public any_float(tensor, out_dtype) with an integer (I64/I32/U8/...) or Bool tensor instead of a float tensor.","commonSituations":"Calling any_float generically on tensors of unknown dtype; a pipeline where the tensor was silently converted to an int dtype (e.g. after a cast or quantization) before the reduction.","solutions":["Check tensor.dtype() is a float variant before calling any_float; route int tensors to any_int","Cast the tensor to F32 first if float semantics are acceptable","Adjust upstream casts so the tensor stays float until after the reduction"],"exampleFix":"// before\nlet has_any = any_float(int_tensor, BoolDType::Native);\n// after\nlet has_any = any_int(int_tensor, BoolDType::Native);","handlingStrategy":"type-guard","validationCode":"if !matches!(t.dtype(), DType::F32|DType::F64|DType::F16|DType::BF16) { /* route to any_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":["Pick any_float vs any_int based on dtype, not call-site guesswork","Cast to F32 when mixed-dtype reductions are acceptable","Write a small dispatch helper: float -> any_float, int -> any_int"],"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"}