tracel-ai/burn · error

int_gather_nd is not implemented for this backend

Error message

int_gather_nd is not implemented for this backend

What it means

`int_gather_nd` is a default trait method for multi-dimensional gather on int tensors; its default body panics with `unimplemented!("int_gather_nd is not implemented for this backend")`. The backend in use has not overridden this op.

Source

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

        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.
    fn int_select(tensor: IntTensor<B>, dim: usize, indices: IntTensor<B>) -> IntTensor<B>;

    /// Assign selected elements along a dimension using the specified update operation.
    fn int_select_assign(
        tensor: IntTensor<B>,

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Switch to a backend that implements `int_gather_nd`.
  2. Implement `int_gather_nd` in your backend (e.g. compute flat indices and use `int_select`).
  3. Rewrite the gather using supported select/gather primitives via index math (last-dim size factorization).

Example fix

// before
let out = B::int_gather_nd(data, indices); // panics

// after
// compute flat indices then use supported select:
let flat_idx = compute_flat_indices(indices, data.shape());
let out = B::int_select(flat_data, flat_idx);
Defensive patterns

Strategy: fallback

Validate before calling

// Probe gather_nd support or restrict model export to ops the target backend supports

Try / catch

let out = std::panic::catch_unwind(|| B::int_gather_nd(d, i))
    .unwrap_or_else(|_| gather_nd_via_flat_select(d, i));

Prevention

When it happens

Trigger: Calling `int_gather_nd(data, indices)` (GatherNd-style indexing on Int tensors) on a backend lacking the override.

Common situations: ONNX `GatherNd` on integer tensors; embedding/index lookups ported from other frameworks to a minimal backend.

Related errors


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