xnn.common.models.ops.gather_rows#

xnn.common.models.ops.gather_rows(src, index)[source]#

Rows src[index] (dim 0), with the faster kernels of the device.

The node -> edge gather of message passing, the counterpart of scatter_sum(). On CUDA, from small_gather_elements() output elements, it is a torch.Tensor.gather() over an expanded index, faster than indexing in both directions (its backward is the scatter of scatter_sum()); below that and on CPUs it uses torch.index_select(), whose backward is an index_add. The values are the same.

Parameters:
  • src (torch.Tensor) – Tensor of shape (N, *feature_dims) (e.g. per-node features).

  • index (torch.Tensor) – 1-D integer tensor of length E, the row of src for each output row.

Returns:

Tensor of shape (E, *feature_dims).

Return type:

torch.Tensor

Notes

Compatible with torch.jit.script().