tracel-ai/burn · error

burn-flex does not support Bool(U32) storage (only Native an

Error message

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).

What it means

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.

Source

Thrown at crates/burn-flex/src/ops/comparison.rs:478

            .map(|idx| cmp(lhs_storage[idx], rhs) as u8)
            .collect(),
    };

    make_bool_tensor(result, shape, out_dtype)
}

/// Build a bool `FlexTensor` from a `Vec<u8>` of 0/1 bytes, tagged with the
/// requested output dtype.
///
/// burn-flex stores bools as 1 byte per element, so only Native and U8 are
/// supported. `Bool(U32)` would require 4-byte-per-element storage throughout
/// the backend; `dtype_usage` declares it unsupported and this function panics
/// if it's requested.
pub(crate) fn make_bool_tensor(data: Vec<u8>, shape: Shape, out_dtype: BoolDType) -> FlexTensor {
    let store = match out_dtype {
        BoolDType::Native => BoolStore::Native,
        BoolDType::U8 => BoolStore::U8,
        BoolDType::U32 => panic!(
            "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)."
        ),
    };
    let bytes = Bytes::from_elems(data);
    FlexTensor::new(bytes, Layout::contiguous(shape), DType::Bool(store))
}

// Specific comparison functions

pub fn greater(lhs: FlexTensor, rhs: FlexTensor, out_dtype: BoolDType) -> FlexTensor {
    compare(
        lhs,
        rhs,
        out_dtype,
        |a, b| a > b,
        |a, b| a > b,
        Some(CompareOp::Gt),

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Request BoolDType::Native or BoolDType::U8 for comparison outputs instead of U32
  2. Use a burn backend whose tensor kind declares Bool(U32) support
  3. Centralize the out_dtype choice so it follows the backend's declared bool storage dtype

Example fix

// before
let out = int_greater(a, b, BoolDType::U32);
// after
let out = int_greater(a, b, BoolDType::Native);
Defensive patterns

Strategy: validation

Validate before calling

if out_dtype == BoolDType::U32 {
    out_dtype = BoolDType::Native; // or select a backend declaring Bool(U32) support
}

Prevention

When it happens

Trigger: Calling any comparison op (compare_f32/compare_typed, elemwise variants like bool_not_equal_elem, int_greater*, etc.) with out_dtype=BoolDType::U32.

Common situations: 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.

Related errors


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/cdafa946879c46c4. Report an issue: GitHub.