{"record":{"id":"d1b1b8b943d2664a","repo":"tracel-ai/burn","slug":"prod-dim-unsupported-dtype","errorCode":null,"errorMessage":"prod_dim: unsupported dtype {:?}","messagePattern":"prod_dim: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/reduce.rs","lineNumber":420,"sourceCode":"            f16::from_f32,\n        ),\n        DType::BF16 => reduce_dim_half(\n            &tensor,\n            dim,\n            1.0,\n            |acc, x| acc * x,\n            bf16::to_f32,\n            bf16::from_f32,\n        ),\n        DType::I8 => reduce_dim_widening::<i8, _>(&tensor, dim, 1, |acc, x| acc.wrapping_mul(x)),\n        DType::I16 => reduce_dim_widening::<i16, _>(&tensor, dim, 1, |acc, x| acc.wrapping_mul(x)),\n        DType::I32 => reduce_dim_widening::<i32, _>(&tensor, dim, 1, |acc, x| acc.wrapping_mul(x)),\n        DType::I64 => reduce_dim_impl::<i64, _>(&tensor, dim, 1, |acc, x| acc * x),\n        DType::U8 => reduce_dim_widening::<u8, _>(&tensor, dim, 1, |acc, x| acc.wrapping_mul(x)),\n        DType::U16 => reduce_dim_widening::<u16, _>(&tensor, dim, 1, |acc, x| acc.wrapping_mul(x)),\n        DType::U32 => reduce_dim_widening::<u32, _>(&tensor, dim, 1, |acc, x| acc.wrapping_mul(x)),\n        DType::U64 => reduce_dim_impl::<u64, _>(&tensor, dim, 1, |acc, x| acc * x),\n        _ => panic!(\"prod_dim: unsupported dtype {:?}\", tensor.dtype()),\n    }\n}\n\n// ============================================================================\n// Max / Min (all elements)\n// ============================================================================\n\n/// Max of all elements, returning a scalar tensor of shape \\[1\\].\npub fn max(tensor: FlexTensor) -> FlexTensor {\n    // Asserted here rather than per dtype: every path seeds the fold with an infinity, so without\n    // this they report that seed as the max of nothing instead of failing.\n    assert!(\n        tensor.layout().shape().num_elements() > 0,\n        \"max: cannot reduce an empty tensor\"\n    );\n    match tensor.dtype() {\n        DType::F32 => max_f32_reduce(&tensor),\n        DType::F64 => float_extremum_f64_reduce::<true>(&tensor),","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/reduce.rs#L402-L438","documentation":"burn-flex's `prod_dim` reduces a product along a dimension, supporting float dtypes and integer dtypes I8–I64 / U8–U64 with widening accumulators (identity 1). Unsupported dtypes like Bool or quantized hit the catch-all panic.","triggerScenarios":"Calling `Tensor::prod_dim(dim)` on a Bool or quantized tensor — e.g. per-row logical AND of a mask implemented via product.","commonSituations":"Per-sequence conjunction over boolean masks without casting; product over quantized values; generic trait code receiving unexpected dtypes.","solutions":["Cast first: `mask.cast(DType::I32).prod_dim(1)`.","Use explicit boolean reduction semantics where possible after casting.","Dequantize quantized tensors before reducing."],"exampleFix":"// before\nlet row_and = mask.prod_dim(1); // Bool\n// after\nlet row_and = mask.cast(DType::I32).prod_dim(1);","handlingStrategy":"validation","validationCode":"assert!(!matches!(t.dtype(), DType::Bool | DType::QFloat(_)), \"prod_dim unsupported for {:?}; cast or dequantize first\", t.dtype());","typeGuard":"fn is_prod_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 to I32/F32 before prod_dim.","For boolean per-row AND, cast mask then prod_dim, or use explicit comparison.","Dequantize QFloat tensors before dim products."],"tags":["rust","burn","reduce","prod","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"}