tracel-ai/burn · error

float_scatter with {other:?} update is not implemented

Error message

float_scatter with {other:?} update is not implemented

What it means

`float_scatter` in burn-tch dispatches on the IndexingUpdateOp (Set/Add/Mul); any other update op hits the `other` arm and panics via `unimplemented!()`. The backend only supports scatter with set, add, and multiply updates for float tensors.

Source

Thrown at crates/burn-tch/src/ops/tensor.rs:214

    fn float_scatter(
        dim: usize,
        tensor: TchTensor,
        indices: TchTensor,
        value: TchTensor,
        update: burn_backend::tensor::IndexingUpdateOp,
    ) -> TchTensor {
        match update {
            burn_backend::tensor::IndexingUpdateOp::Assign => {
                TchOps::scatter_assign(dim, tensor, indices, value)
            }
            burn_backend::tensor::IndexingUpdateOp::Add => {
                TchOps::scatter(dim, tensor, indices, value)
            }
            burn_backend::tensor::IndexingUpdateOp::Mul => {
                TchOps::scatter_mul(dim, tensor, indices, value)
            }
            other => unimplemented!("float_scatter with {other:?} update is not implemented"),
        }
    }

    fn float_scatter_nd(
        data: TchTensor,
        indices: TchTensor,
        values: TchTensor,
        reduction: burn_backend::tensor::IndexingUpdateOp,
    ) -> TchTensor {
        TchOps::scatter_nd(data, indices, values, reduction)
    }

    fn float_gather_nd(data: TchTensor, indices: TchTensor) -> TchTensor {
        TchOps::gather_nd(data, indices)
    }

    fn float_select(tensor: TchTensor, dim: usize, indices: TchTensor) -> TchTensor {
        TchOps::index_select_dim(tensor, dim, indices)

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Express the update using a supported op (Set/Add/Mul), e.g. scatter with Add of the negated values for Sub
  2. Restructure so the update happens as element-wise math after a supported scatter
  3. Upgrade burn-tch in case the variant is now supported
  4. Add an explicit match/guard on supported ops before calling scatter

Example fix

// before
tensor.scatter(0, &indices, value, IndexingUpdateOp::Sub);
// panics
// after
tensor.scatter(0, &indices, -value, IndexingUpdateOp::Add);
Defensive patterns

Strategy: validation

Validate before calling

assert!(is_supported_update(&op));

Type guard

fn is_supported_update(op: &IndexingUpdateOp) -> bool {
    matches!(op, IndexingUpdateOp::Set | IndexingUpdateOp::Add | IndexingUpdateOp::Mul)
}

Prevention

When it happens

Trigger: Calling `tensor.scatter(dim, indices, value, op)` — or an API lowering to it — with an IndexingUpdateOp other than Set, Add, or Mul (e.g. Sub, Div, Min, Max) on a tch float tensor.

Common situations: Using newly added IndexingUpdateOp variants with the libtorch backend before support lands; generic code parameterized over update ops run against tch; version skew where burn-core gained an op variant burn-tch hasn't implemented.

Related errors


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