tracel-ai/burn · error

int_scatter_nd is not implemented for this backend

Error message

int_scatter_nd is not implemented for this backend

What it means

`int_scatter_nd` is a default trait method for multi-dimensional scatter on int tensors; the default body panics with `unimplemented!("int_scatter_nd is not implemented for this backend")`. The library throws it because the active backend did not override this optional op.

Source

Thrown at crates/burn-backend/src/backend/ops/int_tensor.rs:209

    fn int_gather(dim: usize, tensor: IntTensor<B>, indices: IntTensor<B>) -> IntTensor<B>;

    /// Scatter elements into a tensor using the specified update operation.
    fn int_scatter(
        dim: usize,
        tensor: IntTensor<B>,
        indices: IntTensor<B>,
        value: IntTensor<B>,
        update: IndexingUpdateOp,
    ) -> IntTensor<B>;

    /// Multi-dimensional scatter for int tensors.
    fn int_scatter_nd(
        _data: IntTensor<B>,
        _indices: IntTensor<B>,
        _values: IntTensor<B>,
        _reduction: crate::tensor::IndexingUpdateOp,
    ) -> IntTensor<B> {
        unimplemented!("int_scatter_nd is not implemented for this backend")
    }

    /// Multi-dimensional gather for int tensors.
    fn int_gather_nd(_data: IntTensor<B>, _indices: IntTensor<B>) -> IntTensor<B> {
        unimplemented!("int_gather_nd is not implemented for this backend")
    }

    /// Select tensor elements along the given dimension corresponding to the given indices.
    ///
    /// # Arguments
    ///
    /// * `tensor` - The tensor.
    /// * `dim` - The dimension to select from.
    /// * `indices` - The indices.
    ///
    /// # Returns
    ///
    /// The tensor with the selected elements.

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Switch to a backend that implements `int_scatter_nd`, or express the op with supported primitives (reshape + index_select/scatter along the last dim).
  2. Implement `int_scatter_nd` in your backend.
  3. Cast to Float and use `float_scatter_nd` if that backend provides it, then cast back.

Example fix

// before
let out = B::int_scatter_nd(data, indices, values, IndexingUpdateOp::Update); // panics

// after
// flatten leading dims, use supported scatter/select primitives instead, e.g.
let flat = data.reshape(Shape::from([-1]));
let out = scatter_via_select(flat, indices, values).reshape(data.shape());
Defensive patterns

Strategy: validation

Validate before calling

// Check backend support via capability/test before relying on scatter_nd on int tensors
// e.g. run a probe in tests: B::int_scatter_nd(data.clone(), idx.clone(), vals.clone(), op);

Try / catch

let out = std::panic::catch_unwind(|| B::int_scatter_nd(d, i, v, op))
    .unwrap_or_else(|_| scatter_via_select_fallback(d, i, v, op));

Prevention

When it happens

Trigger: Calling `int_scatter_nd(data, indices, values, reduction)` (e.g. via tensor scatter-nd operations on Int tensors) on a backend lacking the override.

Common situations: Porting models that use TF/ONNX-style `ScatterNd` on integer tensors; running inference/training on a minimal or fused backend that only implements core int ops.

Related errors


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