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, fromsmall_gather_elements()output elements, it is atorch.Tensor.gather()over an expanded index, faster than indexing in both directions (its backward is the scatter ofscatter_sum()); below that and on CPUs it usestorch.index_select(), whose backward is anindex_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 ofsrcfor each output row.
- Returns:
Tensor of shape
(E, *feature_dims).- Return type:
Notes
Compatible with
torch.jit.script().