{"record":{"id":"f2e1a3ed614ebbd1","repo":"tracel-ai/burn","slug":"unsupported-dtype-for-bool-from-data","errorCode":null,"errorMessage":"Unsupported dtype for `bool_from_data` {:?}","messagePattern":"Unsupported dtype for `bool_from_data` (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-cubecl/src/ops/bool_tensor.rs","lineNumber":52,"sourceCode":"\n    fn bool_zeros(shape: Shape, device: &Device<Self>, dtype: BoolDType) -> BoolTensor<Self> {\n        numeric::zeros(device.clone(), shape, dtype.into())\n    }\n\n    fn bool_ones(shape: Shape, device: &Device<Self>, dtype: BoolDType) -> BoolTensor<Self> {\n        numeric::ones(device.clone(), shape, dtype.into())\n    }\n\n    async fn bool_into_data(tensor: BoolTensor<Self>) -> Result<TensorData, ExecutionError> {\n        super::into_data(tensor).await\n    }\n\n    fn bool_from_data(data: TensorData, device: &Device<Self>) -> BoolTensor<Self> {\n        if !matches!(\n            data.dtype,\n            DType::Bool(BoolStore::U8) | DType::Bool(BoolStore::U32)\n        ) {\n            unimplemented!(\"Unsupported dtype for `bool_from_data` {:?}\", data.dtype);\n        }\n        super::from_data(data, device)\n    }\n\n    fn bool_into_int(tensor: BoolTensor<Self>, out_dtype: IntDType) -> IntTensor<Self> {\n        kernel::bool_cast(tensor, out_dtype.into())\n    }\n\n    fn bool_to_device(tensor: BoolTensor<Self>, device: &Device<Self>) -> BoolTensor<Self> {\n        super::to_device(tensor, device)\n    }\n\n    fn bool_reshape(tensor: BoolTensor<Self>, shape: Shape) -> BoolTensor<Self> {\n        super::reshape(tensor, shape)\n    }\n\n    fn bool_slice(tensor: BoolTensor<Self>, slices: &[Slice]) -> BoolTensor<Self> {\n        // Check if all steps are 1","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-cubecl/src/ops/bool_tensor.rs#L34-L70","documentation":"bool_from_data converts host TensorData into a GPU boolean tensor. The CubeCL backend only stores bools as U8 or U32 (BoolStore::U8/U32); any other dtype in the incoming data cannot be interpreted and triggers this unimplemented! panic.","triggerScenarios":"Calling bool_from_data (directly or via TensorData-backed bool tensor creation, e.g. Tensor::from_data with bool data tagged with a wrong DType) with data.dtype not DType::Bool(BoolStore::U8) or BoolStore::U32 — e.g. DType::Bool(BoolStore::Native) or numeric dtypes.","commonSituations":"Serializing tensors on CPU (native bool storage) and loading on the CubeCL backend; constructing TensorData manually with an incorrect dtype; cross-backend tensor migration.","solutions":["Ensure TensorData.dtype is DType::Bool(BoolStore::U8) or BoolStore::U32 before creating the tensor","Convert data bytes to u8/u32 storage when building TensorData (e.g. cast Vec<bool> to Vec<u8>)","Re-export the tensor from a compatible path or use the backend's conversion APIs","Upgrade burn — conversion layers for native bool may be added"],"exampleFix":"// before\nlet data = TensorData::new(bools_vec, shape); // dtype Bool(Native)\n// after\nlet bytes: Vec<u8> = bools_vec.iter().map(|&b| b as u8).collect();\nlet data = TensorData::new(bytes, shape).convert::<DTypeBoolU8>(); // bool u8 storage","handlingStrategy":"type-guard","validationCode":"fn bool_data_supported(data: &TensorData) -> bool {\n    matches!(data.dtype, DType::Bool(BoolStore::U8) | DType::Bool(BoolStore::U32))\n}","typeGuard":"fn is_storable_bool(dtype: DType) -> bool {\n    matches!(dtype, DType::Bool(BoolStore::U8 | BoolStore::U32))\n}","tryCatchPattern":"// Panic-based; convert first:\nif !bool_data_supported(&data) { let data = to_u8_bool_storage(data); }\nlet t = Tensor::<B, D>::from_data(data, &device);","preventionTips":["Always store bool tensors as u8/u32 when crossing to CubeCL","Cast Vec<bool> to Vec<u8> when building TensorData","Check dtype tags after deserialization"],"tags":["bool","dtype","tensor-data","unimplemented"],"backgroundTag":"unsupported-dtype-conversion","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"}