dgl.graphbolt.indptr_edge_ids๏ƒ

dgl.graphbolt.indptr_edge_ids(indptr, dtype=None, offset=None, output_size=None)[source]๏ƒ

Converts a given indptr offset tensor to a COO format tensor for the edge ids. For a given indptr [0, 2, 5, 7] and offset tensor [0, 100, 200], the output will be [0, 1, 100, 101, 102, 201, 202]. If offset was not provided, the output would be [0, 1, 0, 1, 2, 0, 1].

Parameters:
  • indptr (torch.Tensor) โ€“ A 1D tensor represents the csc_indptr tensor.

  • dtype (Optional[torch.dtype]) โ€“ The dtype of the returned output tensor.

  • offset (Optional[torch.Tensor]) โ€“ A 1D tensor represents the offsets that the returned tensor will be populated with.

  • output_size (Optional[int]) โ€“ The size of the output tensor. Should be equal to indptr[-1]. Using this argument avoids a stream synchronization to calculate the output shape.

Returns:

The converted COO edge ids tensor.

Return type:

torch.Tensor