{"record":{"id":"cdafa946879c46c4","repo":"tracel-ai/burn","slug":"burn-flex-does-not-support-bool-u32-storage-only","errorCode":null,"errorMessage":"burn-flex does not support Bool(U32) storage (only Native and U8). Use a backend that declares Bool(U32) support, or work with Bool(Native)/Bool(U8).","messagePattern":"burn-flex does not support Bool\\(U32\\) storage \\(only Native and U8\\)\\. Use a backend that declares Bool\\(U32\\) support, or work with Bool\\(Native\\)/Bool\\(U8\\)\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/comparison.rs","lineNumber":478,"sourceCode":"            .map(|idx| cmp(lhs_storage[idx], rhs) as u8)\n            .collect(),\n    };\n\n    make_bool_tensor(result, shape, out_dtype)\n}\n\n/// Build a bool `FlexTensor` from a `Vec<u8>` of 0/1 bytes, tagged with the\n/// requested output dtype.\n///\n/// burn-flex stores bools as 1 byte per element, so only Native and U8 are\n/// supported. `Bool(U32)` would require 4-byte-per-element storage throughout\n/// the backend; `dtype_usage` declares it unsupported and this function panics\n/// if it's requested.\npub(crate) fn make_bool_tensor(data: Vec<u8>, shape: Shape, out_dtype: BoolDType) -> FlexTensor {\n    let store = match out_dtype {\n        BoolDType::Native => BoolStore::Native,\n        BoolDType::U8 => BoolStore::U8,\n        BoolDType::U32 => panic!(\n            \"burn-flex does not support Bool(U32) storage (only Native and U8). \\\n             Use a backend that declares Bool(U32) support, or work with Bool(Native)/Bool(U8).\"\n        ),\n    };\n    let bytes = Bytes::from_elems(data);\n    FlexTensor::new(bytes, Layout::contiguous(shape), DType::Bool(store))\n}\n\n// Specific comparison functions\n\npub fn greater(lhs: FlexTensor, rhs: FlexTensor, out_dtype: BoolDType) -> FlexTensor {\n    compare(\n        lhs,\n        rhs,\n        out_dtype,\n        |a, b| a > b,\n        |a, b| a > b,\n        Some(CompareOp::Gt),","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/comparison.rs#L460-L496","documentation":"make_bool_tensor builds the FlexTensor that holds the result of a comparison op. The burn-flex backend only stores bool tensors as Native or U8; if the requested output dtype is Bool(U32) it panics immediately, since no Bool(U32) storage path exists in this backend.","triggerScenarios":"Calling any comparison op (compare_f32/compare_typed, elemwise variants like bool_not_equal_elem, int_greater*, etc.) with out_dtype=BoolDType::U32.","commonSituations":"Porting code written for a backend that uses U32 bool storage (e.g. some GPU backends); a generic burn client hardcoded to BoolDType::U32 regardless of backend; mismatch between the backend's declared bool dtype and what the caller requests.","solutions":["Request BoolDType::Native or BoolDType::U8 for comparison outputs instead of U32","Use a burn backend whose tensor kind declares Bool(U32) support","Centralize the out_dtype choice so it follows the backend's declared bool storage dtype"],"exampleFix":"// before\nlet out = int_greater(a, b, BoolDType::U32);\n// after\nlet out = int_greater(a, b, BoolDType::Native);","handlingStrategy":"validation","validationCode":"if out_dtype == BoolDType::U32 {\n    out_dtype = BoolDType::Native; // or select a backend declaring Bool(U32) support\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hardcode BoolDType::U32 with burn-flex; default to Native/U8","Derive the bool out_dtype from the backend's declared capabilities","Wrap backend selection in one module so dtype policy stays consistent"],"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"}