{"record":{"id":"1ca5d9e0a27caf77","repo":"tracel-ai/burn","slug":"all-int-unsupported-dtype","errorCode":null,"errorMessage":"all_int: unsupported dtype {:?}","messagePattern":"all_int: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/comparison.rs","lineNumber":913,"sourceCode":"}\n\n/// Check if any element along a dimension is non-zero (int tensors).\npub fn any_int_dim(tensor: FlexTensor, dim: usize, out_dtype: BoolDType) -> FlexTensor {\n    reduce_bool_dim_int(&tensor, dim, false, |a, b| a || b, out_dtype)\n}\n\n/// Check if all elements are non-zero (int tensors).\npub fn all_int(tensor: FlexTensor, out_dtype: BoolDType) -> FlexTensor {\n    let all = match tensor.dtype() {\n        DType::I64 => iter_elements::<i64>(&tensor).all(|x| x != 0),\n        DType::I32 => iter_elements::<i32>(&tensor).all(|x| x != 0),\n        DType::I16 => iter_elements::<i16>(&tensor).all(|x| x != 0),\n        DType::I8 => iter_elements::<i8>(&tensor).all(|x| x != 0),\n        DType::U64 => iter_elements::<u64>(&tensor).all(|x| x != 0),\n        DType::U32 => iter_elements::<u32>(&tensor).all(|x| x != 0),\n        DType::U16 => iter_elements::<u16>(&tensor).all(|x| x != 0),\n        DType::U8 => iter_elements::<u8>(&tensor).all(|x| x != 0),\n        _ => panic!(\"all_int: unsupported dtype {:?}\", tensor.dtype()),\n    };\n    bool_scalar(all, out_dtype)\n}\n\n/// Check if all elements along a dimension are non-zero (int tensors).\npub fn all_int_dim(tensor: FlexTensor, dim: usize, out_dtype: BoolDType) -> FlexTensor {\n    reduce_bool_dim_int(&tensor, dim, true, |a, b| a && b, out_dtype)\n}\n\n/// Check if any bool element is true.\npub fn any_bool(tensor: FlexTensor, out_dtype: BoolDType) -> FlexTensor {\n    let tensor = tensor.to_contiguous();\n    let data: &[u8] = tensor.bytes();\n    bool_scalar(data.iter().any(|&x| x != 0), out_dtype)\n}\n\n/// Check if any bool element along a dimension is true.\npub fn any_bool_dim(tensor: FlexTensor, dim: usize, out_dtype: BoolDType) -> FlexTensor {","sourceCodeStart":895,"sourceCodeEnd":931,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/comparison.rs#L895-L931","documentation":"Dtype-dispatch exhaustiveness panic: `all_int` supports the full integer dtype set and panics for any non-integer dtype, meaning the Flex backend received an int all-reduction request for a tensor of the wrong kind.","triggerScenarios":"Calling the public all_int(tensor, out_dtype) with a float or Bool tensor.","commonSituations":"Symmetric mistake to any_int: float tensor routed into the int reduction; dtype drifted upstream to F32 after a division/normalization.","solutions":["Route float tensors to all_float instead","Cast to an integer dtype first if appropriate","Add a dtype check/assert before calling all_int"],"exampleFix":"// before\nlet all = all_int(f64_tensor, BoolDType::Native);\n// after\nlet all = all_float(f64_tensor, 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) { /* route to all_float 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":["Dispatch all_int/all_float by dtype family","Check for upstream ops that silently promote tensors to float","Cover int/float paths in tests for shared reduction utilities"],"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"}