tracel-ai/burn · error

int_scatter with {other:?} update is not implemented

Error message

int_scatter with {other:?} update is not implemented

What it means

burn-flex's `int_scatter` supports integer/uint dtypes (I32/I64/U8/...) for the update tensor, but a non-int update dtype (e.g. float) reaches the `other` arm and panics with `unimplemented!("int_scatter with {other:?} update is not implemented")`.

Source

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

                    DType::I8 => {
                        crate::ops::gather_scatter::scatter_mul::<i8>(tensor, dim, indices, value)
                    }
                    DType::U64 => {
                        crate::ops::gather_scatter::scatter_mul::<u64>(tensor, dim, indices, value)
                    }
                    DType::U32 => {
                        crate::ops::gather_scatter::scatter_mul::<u32>(tensor, dim, indices, value)
                    }
                    DType::U16 => {
                        crate::ops::gather_scatter::scatter_mul::<u16>(tensor, dim, indices, value)
                    }
                    DType::U8 => {
                        crate::ops::gather_scatter::scatter_mul::<u8>(tensor, dim, indices, value)
                    }
                    dt => panic!("int_scatter: unsupported dtype {:?}", dt),
                }
            }
            other => unimplemented!("int_scatter with {other:?} update is not implemented"),
        }
    }

    fn int_scatter_nd(
        data: IntTensor<Flex>,
        indices: IntTensor<Flex>,
        values: IntTensor<Flex>,
        reduction: burn_backend::tensor::IndexingUpdateOp,
    ) -> IntTensor<Flex> {
        match data.dtype() {
            DType::I64 => {
                crate::ops::gather_scatter::scatter_nd::<i64>(data, indices, values, reduction)
            }
            DType::I32 => {
                crate::ops::gather_scatter::scatter_nd::<i32>(data, indices, values, reduction)
            }
            DType::I16 => {
                crate::ops::gather_scatter::scatter_nd::<i16>(data, indices, values, reduction)

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Cast the update tensor to the int dtype of the data tensor: `values.cast(DType::I32)` or `.int()`
  2. If float values are truly needed, use a float tensor for the data as well
  3. Inspect `values.dtype` before scattering and branch accordingly
  4. Round/convert float payloads to ints explicitly if counts are intended

Example fix

// before
let updated = counts.scatter(dim, indices, sums_f32);
// after
let updated = counts.scatter(dim, indices, sums_f32.cast(DType::I32));
Defensive patterns

Strategy: type-guard

Validate before calling

assert!(values.dtype().is_int() || values.dtype().is_uint(), "int_scatter requires an int/uint update tensor");

Type guard

fn is_int_dtype(d: DType) -> bool {
    d.is_int() || d.is_uint()
}

Try / catch

// validate before calling; panic cannot be caught
if !is_int_dtype(values.dtype()) {
    values = values.cast(DType::I64);
}
let out = counts.scatter(dim, indices, values);

Prevention

When it happens

Trigger: Calling `int_scatter` / scatter on an integer tensor with a float `values` update tensor.

Common situations: Scattering float values (e.g. averages, weights) into an int histogram/count tensor; dtype drift after changing tensor construction to `.float()` defaults.

Related errors


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