{"record":{"id":"649e0e816b8c1a9d","repo":"tracel-ai/burn","slug":"min-unsupported-dtype","errorCode":null,"errorMessage":"min: unsupported dtype {:?}","messagePattern":"min: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/reduce.rs","lineNumber":496,"sourceCode":"            f16::to_f32,\n            f16::from_f32,\n        ),\n        DType::BF16 => reduce_scalar_half(\n            &tensor,\n            select_float_extremum::<f32, false>,\n            f32::INFINITY,\n            bf16::to_f32,\n            bf16::from_f32,\n        ),\n        DType::I8 => min_impl::<i8>(&tensor),\n        DType::I16 => min_impl::<i16>(&tensor),\n        DType::I32 => min_impl::<i32>(&tensor),\n        DType::I64 => min_impl::<i64>(&tensor),\n        DType::U8 => min_impl::<u8>(&tensor),\n        DType::U16 => min_impl::<u16>(&tensor),\n        DType::U32 => min_impl::<u32>(&tensor),\n        DType::U64 => min_impl::<u64>(&tensor),\n        _ => panic!(\"min: unsupported dtype {:?}\", tensor.dtype()),\n    }\n}\n\n#[inline(always)]\nfn select_float_extremum<E: Float, const MAX: bool>(current: E, candidate: E) -> E {\n    let keep_current = if MAX {\n        current >= candidate\n    } else {\n        current <= candidate\n    };\n    if current.is_nan() || keep_current {\n        current\n    } else {\n        candidate\n    }\n}\n\n#[inline(always)]","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/reduce.rs#L478-L514","documentation":"The burn-flex `min` reduction panics when the tensor's dtype has no implemented min-reduction path. The match in reduce.rs:466-498 covers F32/F64/F16/BF16 and all integer types (I8-I64, U8-U64); any other dtype — practically only DType::Bool — falls into the catch-all `_` arm and panics. Burn panics rather than returning Result because reductions are expected to be total over the supported dtype set.","triggerScenarios":"Calling `ops::reduce::min(tensor)` (or a burn frontend min reduction dispatched to the flex backend) on a tensor whose dtype is not one of the 12 supported ones — in practice a Bool tensor, since bool is the only DType outside the handled set.","commonSituations":"Reducing a boolean mask (e.g. min/any-style reduction over a bool mask produced by a comparison); dtype drift after a casting change so a reduction receives an unexpected dtype; a newly added DType variant not yet wired into the flex reduce ops.","solutions":["Check `tensor.dtype()` before reducing; convert Bool to a numeric type first, e.g. `tensor.cast(DType::F32)` or `tensor.cast(DType::U8)` (F32/U8 both have min paths).","If you expected a float/int tensor, fix the upstream op that produced the wrong dtype (inspect the cast/comparison chain feeding `min`).","If you need bool min support, add a `DType::Bool` arm to the match in crates/burn-flex/src/ops/reduce.rs mapping to a bool element-wise min impl.","Run your pipeline with dtype assertions enabled so the mismatch surfaces at the producing op rather than at reduction."],"exampleFix":"// before\nlet m = min(mask_tensor); // panics: unsupported dtype Bool\n// after\nlet m = min(mask_tensor.cast(DType::F32));","handlingStrategy":"validation","validationCode":"fn ensure_min_supported(dtype: DType) -> Result<(), String> {\n    match dtype {\n        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 => Ok(()),\n        other => Err(format!(\"min: unsupported dtype {other:?}\")),\n    }\n}\n// before calling: ensure_min_supported(t.dtype())?;","typeGuard":"fn is_min_supported(dtype: DType) -> bool {\n    !matches!(dtype, DType::Bool)\n}","tryCatchPattern":"// Rust panic, not catchable portably; validate dtype first, or use catch_unwind:\nlet result = std::panic::catch_unwind(|| burn_flex_ops_reduce_min(tensor.clone()));\nmatch result { Ok(t) => t, Err(_) => fallback_min(tensor) }","preventionTips":["Always check tensor.dtype() before reduction ops","Cast Bool tensors to numeric dtypes before any reduction","Keep a helper that maps your pipeline dtypes to backend-supported sets","Add unit tests that run reductions over every dtype your models can emit"],"tags":["panic","dtype","burn","reduce-ops"],"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"}