{"record":{"id":"17dbaec1e5be9e90","repo":"tracel-ai/burn","slug":"compare-int-unsupported-dtype","errorCode":null,"errorMessage":"compare_int: unsupported dtype {:?}","messagePattern":"compare_int: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/comparison.rs","lineNumber":657,"sourceCode":"        DType::I32 => compare_typed(lhs, &rhs, out_dtype, |a: i32, b: i32| {\n            i64_cmp(a as i64, b as i64)\n        }),\n        DType::I16 => compare_typed(lhs, &rhs, out_dtype, |a: i16, b: i16| {\n            i64_cmp(a as i64, b as i64)\n        }),\n        DType::I8 => compare_typed(lhs, &rhs, out_dtype, |a: i8, b: i8| {\n            i64_cmp(a as i64, b as i64)\n        }),\n        DType::U32 => compare_typed(lhs, &rhs, out_dtype, |a: u32, b: u32| {\n            i64_cmp(a as i64, b as i64)\n        }),\n        DType::U16 => compare_typed(lhs, &rhs, out_dtype, |a: u16, b: u16| {\n            i64_cmp(a as i64, b as i64)\n        }),\n        DType::U8 => compare_typed(lhs, &rhs, out_dtype, |a: u8, b: u8| {\n            i64_cmp(a as i64, b as i64)\n        }),\n        other => panic!(\"compare_int: unsupported dtype {:?}\", other),\n    }\n}\n\nfn compare_int_elem<I64Cmp, U64Cmp>(\n    lhs: FlexTensor,\n    i64_rhs: i64,\n    u64_rhs: u64,\n    out_dtype: BoolDType,\n    i64_cmp: I64Cmp,\n    u64_cmp: U64Cmp,\n) -> FlexTensor\nwhere\n    I64Cmp: Fn(i64, i64) -> bool,\n    U64Cmp: Fn(u64, u64) -> bool,\n{\n    match lhs.dtype() {\n        DType::I64 => compare_elem_typed(lhs, i64_rhs, out_dtype, i64_cmp),\n        DType::U64 => compare_elem_typed(lhs, u64_rhs, out_dtype, u64_cmp),","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/comparison.rs#L639-L675","documentation":"compare_int dispatches integer comparison over a fixed set of int dtypes (I64..U8, compared via i64 widening). Any other dtype reaching it — i.e. a float or bool tensor passed where an integer comparison is expected — hits the catch-all panic.","triggerScenarios":"Calling int_greater/int_lower/int_equal (or their _equal variants) with a tensor whose dtype is not one of the supported integer dtypes (e.g. F32, F64, Bool).","commonSituations":"Passing a float tensor to an int comparison by mistake; a dtype-inference bug upstream that left the tensor as F16/BF16; generic code that assumes all numeric dtypes are routed through compare_int.","solutions":["Check tensor.dtype() before calling; use the float comparison ops (compare_f32/compare_typed) for float tensors","Convert the tensor to an integer dtype first if int semantics are intended","Verify upstream ops are producing the dtype you expect"],"exampleFix":"// before\nlet out = int_greater(a_f32, b_f32, BoolDType::Native);\n// after\nlet out = compare_f32(a_f32, b_f32, BoolDType::Native);","handlingStrategy":"validation","validationCode":"assert!(matches!(a.dtype(), DType::I64|DType::I32|DType::I16|DType::I8|DType::U64|DType::U32|DType::U16|DType::U8), \"compare_int needs an int tensor, got {:?}\", a.dtype());","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":["Branch on dtype family: compare_f32/compare_typed for floats, compare_int for ints","Assert dtypes at API boundaries where tensors enter your code","Track dtype through your pipeline to catch silent conversions"],"tags":["rust","burn","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"}