{"record":{"id":"1e219191d75b1604","repo":"tracel-ai/burn","slug":"max-unsupported-dtype","errorCode":null,"errorMessage":"max: unsupported dtype {:?}","messagePattern":"max: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/reduce.rs","lineNumber":461,"sourceCode":"            f16::to_f32,\n            f16::from_f32,\n        ),\n        DType::BF16 => reduce_scalar_half(\n            &tensor,\n            select_float_extremum::<f32, true>,\n            f32::NEG_INFINITY,\n            bf16::to_f32,\n            bf16::from_f32,\n        ),\n        DType::I8 => max_impl::<i8>(&tensor),\n        DType::I16 => max_impl::<i16>(&tensor),\n        DType::I32 => max_impl::<i32>(&tensor),\n        DType::I64 => max_impl::<i64>(&tensor),\n        DType::U8 => max_impl::<u8>(&tensor),\n        DType::U16 => max_impl::<u16>(&tensor),\n        DType::U32 => max_impl::<u32>(&tensor),\n        DType::U64 => max_impl::<u64>(&tensor),\n        _ => panic!(\"max: unsupported dtype {:?}\", tensor.dtype()),\n    }\n}\n\n/// Min of all elements, returning a scalar tensor of shape \\[1\\].\npub fn min(tensor: FlexTensor) -> FlexTensor {\n    assert!(\n        tensor.layout().shape().num_elements() > 0,\n        \"min: cannot reduce an empty tensor\"\n    );\n    match tensor.dtype() {\n        DType::F32 => min_f32_reduce(&tensor),\n        DType::F64 => float_extremum_f64_reduce::<false>(&tensor),\n        DType::F16 => reduce_scalar_half(\n            &tensor,\n            select_float_extremum::<f32, false>,\n            f32::INFINITY,\n            f16::to_f32,\n            f16::from_f32,","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/reduce.rs#L443-L479","documentation":"Dtype-dispatch exhaustiveness panic in the Flex max reduction: all float and integer dtypes are matched to dedicated implementations; an unmatched dtype (e.g. bool) reaching `max` panics, indicating a misrouted reduction op.","triggerScenarios":"Calling `Tensor::max()` on a Bool or quantized tensor — e.g. taking max over a boolean mask or over quantized activations before dequantization.","commonSituations":"Max over comparison results stored as bool; max over quantized tensors; dtype leaks from data loading pipelines into reduction-heavy code.","solutions":["Cast before reducing: `mask.cast(DType::I32).max()` or `.float().max()`.","For quantized tensors, call `.dequantize()` before max.","Check `tensor.dtype()` at the call site and add the appropriate cast."],"exampleFix":"// before\nlet m = mask.max(); // Bool\n// after\nlet m = mask.cast(DType::I32).max();","handlingStrategy":"validation","validationCode":"assert!(!matches!(t.dtype(), DType::Bool | DType::QFloat(_)), \"max unsupported for {:?}; cast or dequantize first\", t.dtype());","typeGuard":"fn is_max_capable(d: DType) -> bool {\n    matches!(d, DType::F32 | DType::F64 | DType::F16 | DType::BF16\n        | DType::I8 | DType::I16 | DType::I32 | DType::I64\n        | DType::U8 | DType::U16 | DType::U32 | DType::U64)\n}","tryCatchPattern":null,"preventionTips":["Cast Bool tensors to I32 before max.","Dequantize before max on quantized tensors.","Check dtypes at pipeline boundaries where tensors enter reduction code."],"tags":["rust","burn","reduce","max","dtype","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"}