{"record":{"id":"008bb704f3cbb37d","repo":"tracel-ai/burn","slug":"unsupported-dtype-dtype","errorCode":null,"errorMessage":"Unsupported dtype: {dtype:?}","messagePattern":"Unsupported dtype: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-ndarray/src/tensor.rs","lineNumber":84,"sourceCode":"\n    if E1::dtype() == dtype {\n        return array.into();\n    }\n\n    match dtype {\n        DType::F64 => cast::<E1, f64>(array).into(),\n        DType::F32 => cast::<E1, f32>(array).into(),\n        DType::Flex32 => cast::<E1, f32>(array).into(),\n        DType::I64 => cast::<E1, i64>(array).into(),\n        DType::I32 => cast::<E1, i32>(array).into(),\n        DType::I16 => cast::<E1, i16>(array).into(),\n        DType::I8 => cast::<E1, i8>(array).into(),\n        DType::U64 => cast::<E1, u64>(array).into(),\n        DType::U32 => cast::<E1, u32>(array).into(),\n        DType::U16 => cast::<E1, u16>(array).into(),\n        DType::U8 => cast::<E1, u8>(array).into(),\n        DType::Bool(BoolStore::Native) => cast::<E1, bool>(array).into(),\n        dtype => panic!(\"Unsupported dtype: {dtype:?}\"),\n    }\n}\n\nmacro_rules! impl_from {\n    ($($ty: ty => $dtype: ident),*) => {\n        // From SharedArray (owned) -> NdArrayTensor\n        $(impl From<SharedArray<$ty>> for NdArrayTensor {\n           fn from(value: SharedArray<$ty>) -> NdArrayTensor {\n                NdArrayTensor::$dtype(NdArrayStorage::from_owned(value))\n           }\n        })*\n\n        // From NdArrayStorage -> NdArrayTensor\n        $(impl From<NdArrayStorage<$ty>> for NdArrayTensor {\n           fn from(value: NdArrayStorage<$ty>) -> NdArrayTensor {\n                NdArrayTensor::$dtype(value)\n           }\n        })*","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-ndarray/src/tensor.rs#L66-L102","documentation":"cast_to_dtype in burn-ndarray converts a tensor's element type via an exhaustive match over DType. Reaching the fallback arm means the requested (or internal) dtype is not among the supported conversion targets on this backend, so it panics.","triggerScenarios":"Calling tensor.cast(DType::X) or backend cast_to_dtype with a dtype variant not handled by the ndarray cast macro (e.g. Bool(BoolStore::LE), BF16, or F64 depending on build features).","commonSituations":"Saving/loading tensors with unusual bool storage formats or half-precision dtypes not enabled in the ndarray backend; version changes where new DType variants were added but the ndarray cast match wasn't updated.","solutions":["Cast to a supported dtype: F32/F16/I64/I32/I16/I8/U64/U32/U16/U8 or Bool(BoolStore::Native)","Use Bool(BoolStore::Native) rather than alternate bool storage encodings","Enable relevant backend features (e.g. half support) or upgrade burn where the variant may now be handled"],"exampleFix":"// before\ntensor.cast(DType::Bool(BoolStore::LE));\n// after\ntensor.cast(DType::Bool(BoolStore::Native));","handlingStrategy":"validation","validationCode":"const SUPPORTED: &[DType] = &[\n    DType::F32, DType::F16, DType::I64, DType::I32, DType::I16, DType::I8,\n    DType::U64, DType::U32, DType::U16, DType::U8, DType::Bool(BoolStore::Native),\n];\nassert!(SUPPORTED.contains(&target_dtype));","typeGuard":"fn is_castable_dtype(d: DType) -> bool {\n    !matches!(d, DType::Bool(BoolStore::LE)) // plus any variant your burn build lacks\n}","tryCatchPattern":null,"preventionTips":["Restrict saved/load dtypes to the supported set","Use native bool storage","Pin the burn version and test dtype round-trips in CI"],"tags":["rust","burn-ndarray","dtype","casting"],"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"}