tracel-ai/burn · error

int_select: unsupported dtype {:?}

Error message

int_select: unsupported dtype {:?}

What it means

int_select dispatches dtype-based selection along a dimension and panics when the tensor dtype is not one of the eight implemented integer widths. Like gather, select copies fixed-width elements; unsupported dtypes are rejected with a fail-fast panic to avoid undefined behavior.

Source

Thrown at crates/burn-flex/src/ops/int.rs:298

    /// Select ints along `dim` by a 1D index tensor.
    ///
    /// The `indices` tensor may be any supported int width. See
    /// [`int_gather`](Self::int_gather) for the full index-width policy.
    fn int_select(
        tensor: IntTensor<Flex>,
        dim: usize,
        indices: IntTensor<Flex>,
    ) -> IntTensor<Flex> {
        match tensor.dtype() {
            DType::I64 => crate::ops::gather_scatter::select::<i64>(tensor, dim, indices),
            DType::I32 => crate::ops::gather_scatter::select::<i32>(tensor, dim, indices),
            DType::I16 => crate::ops::gather_scatter::select::<i16>(tensor, dim, indices),
            DType::I8 => crate::ops::gather_scatter::select::<i8>(tensor, dim, indices),
            DType::U64 => crate::ops::gather_scatter::select::<u64>(tensor, dim, indices),
            DType::U32 => crate::ops::gather_scatter::select::<u32>(tensor, dim, indices),
            DType::U16 => crate::ops::gather_scatter::select::<u16>(tensor, dim, indices),
            DType::U8 => crate::ops::gather_scatter::select::<u8>(tensor, dim, indices),
            dt => panic!("int_select: unsupported dtype {:?}", dt),
        }
    }

    fn int_select_assign(
        tensor: IntTensor<Flex>,
        dim: usize,
        indices: IntTensor<Flex>,
        value: IntTensor<Flex>,
        update: burn_backend::tensor::IndexingUpdateOp,
    ) -> IntTensor<Flex> {
        match update {
            burn_backend::tensor::IndexingUpdateOp::Assign => {
                debug_assert_eq!(
                    tensor.dtype(),
                    value.dtype(),
                    "int_select_assign: dtype mismatch"
                );
                match tensor.dtype() {

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Cast the tensor to a supported int dtype before select
  2. Fix upstream type flow so bool/float tensors do not reach int selection ops
  3. Use indices of any int width - only the data dtype must be an implemented int type
  4. Add a select match arm for any newly added DType variant

Example fix

// before
let picked = tensor.select(dim, indices); // tensor is DType::Bool
// after
let picked = tensor.cast(DType::I64).select(dim, indices);
Defensive patterns

Strategy: validation

Validate before calling

assert!(is_supported_int_dtype(tensor.dtype()), "select: unsupported dtype {:?}", tensor.dtype());

Type guard

fn is_supported_int_dtype(dt: burn::tensor::DType) -> bool {
    matches!(
        dt,
        burn::tensor::DType::I64 | burn::tensor::DType::I32
            | burn::tensor::DType::I16 | burn::tensor::DType::I8
            | burn::tensor::DType::U64 | burn::tensor::DType::U32
            | burn::tensor::DType::U16 | burn::tensor::DType::U8
    )
}

Prevention

When it happens

Trigger: Calling int_select (select by 1D index tensor along dim) on an IntTensor whose dtype is outside i64/i32/i16/i8/u64/u32/u16/u8, e.g. a bool tensor from a mask computation.

Common situations: Selecting slices of tensors produced by comparison ops, dtype inference yielding float/bool where ints were expected, or new upstream DType variants missing from burn-flex.

Related errors


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