tracel-ai/burn · error

float_gather_nd is not implemented for this backend

Error message

float_gather_nd is not implemented for this backend

What it means

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

Source

Thrown at crates/burn-backend/src/backend/ops/tensor.rs:526

        _indices: IntTensor<B>,
        _values: FloatTensor<B>,
        _reduction: crate::tensor::IndexingUpdateOp,
    ) -> FloatTensor<B> {
        unimplemented!("float_scatter_nd is not implemented for this backend")
    }

    /// Multi-dimensional gather: collect slices from `data` at locations specified by `indices`.
    ///
    /// # Arguments
    ///
    /// * `data` - The tensor to gather from.
    /// * `indices` - An M-dimensional integer tensor whose last dimension indexes into `data`.
    ///
    /// # Returns
    ///
    /// The gathered tensor.
    fn float_gather_nd(_data: FloatTensor<B>, _indices: IntTensor<B>) -> FloatTensor<B> {
        unimplemented!("float_gather_nd is not implemented for this backend")
    }

    /// Select tensor elements along the given dimension corresponding for the given indices.
    ///
    /// # Arguments
    ///
    /// * `tensor` - The tensor to select from.
    /// * `dim` - The dimension to select from.
    /// * `indices` - The indices to select.
    ///
    /// # Returns
    ///
    /// The selected elements.
    fn float_select(tensor: FloatTensor<B>, dim: usize, indices: IntTensor<B>) -> FloatTensor<B>;

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

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Switch to a backend that implements `float_gather_nd`.
  2. Implement `float_gather_nd` in your backend (compute flat indices, then use `float_select`).
  3. Rewrite the gather using supported select/gather primitives with manual index math.

Example fix

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

// after
let flat_idx = compute_flat_indices(indices, data.shape());
let out = B::float_select(data.reshape(Shape::from([-1])), flat_idx);
Defensive patterns

Strategy: fallback

Validate before calling

// Check backend support for gather_nd before graph execution

Try / catch

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

Prevention

When it happens

Trigger: Calling `float_gather_nd(data, indices)` (GatherNd on Float tensors) on a backend lacking the override.

Common situations: ONNX `GatherNd` on weights/activations; attention or lookup-table patterns ported to a minimal backend.

Related errors


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