Commit 9586b8be authored by rusty1s's avatar rusty1s
Browse files

from_edge_index

parent 2e3155cc
...@@ -30,6 +30,15 @@ class SparseTensor(object): ...@@ -30,6 +30,15 @@ class SparseTensor(object):
self.storage = storage self.storage = storage
return self return self
@classmethod
def from_edge_index(self, edge_index: torch.Tensor,
edge_attr: Optional[torch.Tensor] = None,
sparse_sizes: Optional[Tuple[int, int]] = None,
is_sorted: bool = False):
return SparseTensor(row=edge_index[0], rowptr=None, col=edge_index[1],
value=edge_attr, sparse_sizes=sparse_sizes,
is_sorted=is_sorted)
@classmethod @classmethod
def from_dense(self, mat: torch.Tensor, has_value: bool = True): def from_dense(self, mat: torch.Tensor, has_value: bool = True):
if mat.dim() > 2: if mat.dim() > 2:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment