{"record":{"id":"949a6c416b0fef86","repo":"tracel-ai/burn","slug":"unsupported-dtype-949a6c","errorCode":null,"errorMessage":"unsupported dtype: {:?}","messagePattern":"unsupported dtype: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-ndarray/src/tensor.rs","lineNumber":166,"sourceCode":"            F64 => f64, F32 => f32,\n            I64 => i64, I32 => i32, I16 => i16, I8 => i8,\n            U64 => u64, U32 => u32, U16 => u16, U8 => u8,\n            Bool => bool\n        ])\n    }};\n\n    ($tensor:expr, $element:ident, $op:expr, [$($dtype: ident => $ty: ty),*]) => {{\n        match $tensor {\n            $(\n                $crate::NdArrayTensor::$dtype(storage) => {\n                    #[allow(unused)]\n                    type $element = $ty;\n                    // Convert to SharedArray for compatibility with most operations\n                    $op(storage.into_shared()).into()\n                }\n            )*\n            #[allow(unreachable_patterns)]\n            other => unimplemented!(\"unsupported dtype: {:?}\", other.dtype())\n        }\n    }};\n    // Unary op: type automatically inferred by the compiler\n    ($tensor:expr, $op:expr) => {{\n        $crate::execute_with_dtype!($tensor, E, $op)\n    }};\n\n    // Unary op: generic type cannot be inferred for an operation\n    ($tensor:expr, $element:ident, $op:expr) => {{\n        $crate::execute_with_dtype!($tensor, $element, $op, [\n            F64 => f64, F32 => f32,\n            I64 => i64, I32 => i32, I16 => i16, I8 => i8,\n            U64 => u64, U32 => u32, U16 => u16, U8 => u8,\n            Bool => bool\n        ])\n    }};\n}\n","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-ndarray/src/tensor.rs#L148-L184","documentation":"The burn-ndarray `execute_with_dtype!` macro dispatches an operation on the tensor's runtime DType to a typed arm (f32, i32, bool, etc.). If the tensor's dtype matches none of the arms, the catch-all `other` arm panics with `unimplemented!(\"unsupported dtype: {:?}\")`. This is a compile-time-dispatch limitation: the backend only implements the listed element types, so exotic dtypes (e.g. f64, i16, quantized) cannot run.","triggerScenarios":"Calling any tensor operation via the NdArray backend on a tensor whose dtype is not one of the dtypes expanded by the macro (e.g. F64, I64, I16, quantized tensors), such as running a model that requires f64 precision or an op on an unsupported numeric type.","commonSituations":"Loading a checkpoint or model exported with f64/i64 weights into an ndarray backend compiled only for f32/i32; using a dtype added in a newer burn version while the backend macro arms were not extended; feeding CPU numpy data without casting to supported dtypes.","solutions":["Cast the tensor to a supported dtype before the operation (e.g. `.cast(burn::tensor::DType::F32)`).","Enable/compile the backend feature that includes the needed dtype (e.g. f64/i64 features for burn-ndarray).","If the model weights are f64, convert the weights to f32 at load/export time.","Check which dtypes the backend supports and align model/export configuration accordingly."],"exampleFix":"// before\nlet w: Tensor<B, 2> = Tensor::from_floats([f64_data], &device).cast(DType::F64);\nlet out = w.matmul(&x);\n// after\nlet out = w.cast(DType::F32).matmul(&x);","handlingStrategy":"validation","validationCode":"fn assert_supported_dtype<B: Backend>(t: &Tensor<B, 2>) -> bool {\n    matches!(t.dtype(), DType::F32 | DType::I32 | DType::Bool)\n}\nif !assert_supported_dtype(&t) { t = t.cast(DType::F32); }","typeGuard":"fn is_supported_dtype(d: DType) -> bool {\n    matches!(d, DType::F32 | DType::I64 | DType::I32 | DType::U32 | DType::U8 | DType::Bool | DType::F16 | DType::BF16)\n}","tryCatchPattern":null,"preventionTips":["Cast all external data (numpy, checkpoints) to f32/i32 at ingestion.","Enable only backend dtype features you also use in the model.","Unit-test each op with the exact dtypes your pipeline produces.","Check burn release notes for newly supported dtypes before upgrading models."],"tags":["burn","dtype","backend","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"}