tracel-ai/burn · error

conv_transpose1d: unsupported dtype {:?}

Error message

conv_transpose1d: unsupported dtype {:?}

What it means

conv_transpose1d in the burn-flex backend selects between conv_transpose1d_f32/f64/f16/bf16 based on the input dtype; any other dtype panics. Transposed convolutions share the float-only restriction of regular convolutions, so integer or bool tensors cannot be used.

Source

Thrown at crates/burn-flex/src/ops/module.rs:274

            DType::F64 => conv::conv3d_f64(x, weight, bias, &options),
            DType::F16 => conv::conv3d_f16(x, weight, bias, &options),
            DType::BF16 => conv::conv3d_bf16(x, weight, bias, &options),
            dtype => panic!("conv3d: unsupported dtype {:?}", dtype),
        }
    }

    fn conv_transpose1d(
        x: FloatTensor<Flex>,
        weight: FloatTensor<Flex>,
        bias: Option<FloatTensor<Flex>>,
        options: ConvTransposeOptions<1>,
    ) -> FloatTensor<Flex> {
        match x.dtype() {
            DType::F32 => conv_transpose::conv_transpose1d_f32(x, weight, bias, &options),
            DType::F64 => conv_transpose::conv_transpose1d_f64(x, weight, bias, &options),
            DType::F16 => conv_transpose::conv_transpose1d_f16(x, weight, bias, &options),
            DType::BF16 => conv_transpose::conv_transpose1d_bf16(x, weight, bias, &options),
            dtype => panic!("conv_transpose1d: unsupported dtype {:?}", dtype),
        }
    }

    fn conv_transpose2d(
        x: FloatTensor<Flex>,
        weight: FloatTensor<Flex>,
        bias: Option<FloatTensor<Flex>>,
        options: ConvTransposeOptions<2>,
    ) -> FloatTensor<Flex> {
        match x.dtype() {
            DType::F32 => conv_transpose::conv_transpose2d_f32(x, weight, bias, &options),
            DType::F64 => conv_transpose::conv_transpose2d_f64(x, weight, bias, &options),
            DType::F16 => conv_transpose::conv_transpose2d_f16(x, weight, bias, &options),
            DType::BF16 => conv_transpose::conv_transpose2d_bf16(x, weight, bias, &options),
            dtype => panic!("conv_transpose2d: unsupported dtype {:?}", dtype),
        }
    }

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Cast the input to a float dtype before conv_transpose1d: x.cast(DType::F32).
  2. For integer codes, run an embedding lookup (or learned codebook projection) to floats before the transposed conv.
  3. Check .dtype() of input and weight right before the call to pinpoint the mismatch source.
  4. Add a support arm in crates/burn-flex/src/ops/module.rs if a new float dtype must be handled.

Example fix

// before
let out = conv_transpose1d(code_indices_i64, weight, bias, options);
// panic: conv_transpose1d: unsupported dtype I64

// after
let x = embedding.lookup(code_indices_i64); // float output
let out = conv_transpose1d(x, weight, bias, options);
Defensive patterns

Strategy: validation

Validate before calling

let x = match x.dtype() {
    DType::F32 | DType::F64 | DType::F16 | DType::BF16 => x,
    _ => x.cast(DType::F32),
};
let out = conv_transpose1d(x, weight, bias, options);

Type guard

fn is_float(t: &Tensor<Flex>) -> bool {
    matches!(t.dtype(), DType::F32 | DType::F64 | DType::F16 | DType::BF16)
}

Try / catch

let out = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| conv_transpose1d(x.clone(), w.clone(), b.clone(), opts.clone())))
    .unwrap_or_else(|_| conv_transpose1d(x.cast(DType::F32), w, b, opts));

Prevention

When it happens

Trigger: Calling conv_transpose1d with an input/weight tensor whose dtype is not F32/F64/F16/BF16; upsampling integer-encoded 1D sequences (e.g. token or audio codes) directly.

Common situations: Audio/codec decoders (e.g. neural vocoders, EnCodec-style models) where quantized codebook indices feed the transposed-conv decoder without embedding lookup; dtype drift after graph export.

Related errors


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