{"record":{"id":"5f1a1adb806da81a","repo":"tracel-ai/burn","slug":"conv1d-unsupported-dtype","errorCode":null,"errorMessage":"conv1d: unsupported dtype {:?}","messagePattern":"conv1d: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/module.rs","lineNumber":58,"sourceCode":"    let half_data: alloc::vec::Vec<E> = data.iter().map(|&v| from_f32(v)).collect();\n    let bytes = Bytes::from_elems(half_data);\n    FlexTensor::new(bytes, Layout::contiguous(shape), E::dtype())\n}\n\nimpl ModuleOps<Flex> for Flex {\n    fn conv1d(\n        x: FloatTensor<Flex>,\n        weight: FloatTensor<Flex>,\n        bias: Option<FloatTensor<Flex>>,\n        options: ConvOptions<1>,\n    ) -> FloatTensor<Flex> {\n        let (x, options) = pad_asymmetric_conv_input::<Flex, 1>(x, options);\n        match x.dtype() {\n            DType::F32 => conv::conv1d_f32(x, weight, bias, &options),\n            DType::F64 => conv::conv1d_f64(x, weight, bias, &options),\n            DType::F16 => conv::conv1d_f16(x, weight, bias, &options),\n            DType::BF16 => conv::conv1d_bf16(x, weight, bias, &options),\n            dtype => panic!(\"conv1d: unsupported dtype {:?}\", dtype),\n        }\n    }\n\n    fn conv2d(\n        x: FloatTensor<Flex>,\n        weight: FloatTensor<Flex>,\n        bias: Option<FloatTensor<Flex>>,\n        options: ConvOptions<2>,\n    ) -> FloatTensor<Flex> {\n        let (x, options) = pad_asymmetric_conv_input::<Flex, 2>(x, options);\n        match x.dtype() {\n            DType::F32 => conv::conv2d_f32(x, weight, bias, &options),\n            DType::F64 => conv::conv2d_f64(x, weight, bias, &options),\n            DType::F16 => conv::conv2d_f16(x, weight, bias, &options),\n            DType::BF16 => conv::conv2d_bf16(x, weight, bias, &options),\n            dtype => panic!(\"conv2d: unsupported dtype {:?}\", dtype),\n        }\n    }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/module.rs#L40-L76","documentation":"conv1d in the burn-flex module ops dispatches on the input tensor's dtype to a per-dtype conv implementation, supporting only F32, F64, F16, and BF16. If the input tensor carries any other dtype (integer, bool, float8, etc.), the catch-all arm panics with this message. Convolution kernels only exist for float dtypes, so integer input is never valid here.","triggerScenarios":"Passing a tensor with dtype other than F32/F64/F16/BF16 (e.g. I8, I32, U8, Bool) as the input/weight of conv1d; a model whose input embedding layer emits integer tokens fed directly into a conv layer without embedding/casting.","commonSituations":"Feeding raw integer token ids or quantized int8 activations into a conv1d layer; misconfigured preprocessing that skips normalization/to-float conversion; porting a model from a framework that auto-promotes dtypes.","solutions":["Cast the conv input to a float dtype before conv1d: x.cast(DType::F32) (or BF16 for half-precision inference).","Verify tensor.dtype() of x and weight right before the call to identify the unexpected dtype and its origin.","Insert an embedding or one-hot conversion layer for integer inputs (token ids) before the conv stage.","If your checkpoint stores conv weights in an integer dtype, convert them at load time to f32."],"exampleFix":"// before\nlet out = conv1d(token_ids_tensor, weight, bias, options);\n// panic: conv1d: unsupported dtype I64\n\n// after\nlet x = token_ids_tensor.cast(burn::tensor::DType::F32);\nlet out = conv1d(x, weight, bias, options);","handlingStrategy":"validation","validationCode":"if !matches!(x.dtype(), DType::F32 | DType::F64 | DType::F16 | DType::BF16) {\n    x = x.cast(DType::F32);\n}\nlet out = conv1d(x, weight, bias, options);","typeGuard":"fn is_floating(t: &Tensor<Flex>) -> bool {\n    matches!(t.dtype(), DType::F32 | DType::F64 | DType::F16 | DType::BF16)\n}","tryCatchPattern":"let out = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| conv1d(x.clone(), w.clone(), b.clone(), opts.clone())))\n    .unwrap_or_else(|_| conv1d(x.cast(DType::F32), w, b, opts));","preventionTips":["Convert inputs (images, token ids, u8 buffers) to float at the very first layer boundary.","Use embedding lookups for integer indices instead of passing them to conv layers.","Log tensor.dtype() when wiring new model stages.","Pin preprocessing to emit f32 tensors in unit tests."],"tags":["burn","dtype","panic","conv","backend"],"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"}