Commit 6613b175 authored by rusty1s's avatar rusty1s
Browse files

faster rowptr/colptr

parent a2528a02
...@@ -195,7 +195,9 @@ class SparseStorage(object): ...@@ -195,7 +195,9 @@ class SparseStorage(object):
@cached_property @cached_property
def rowptr(self): def rowptr(self):
rowcount = self.rowcount rowcount = self.rowcount
return torch.cat([rowcount.new_zeros(1), rowcount.cumsum(0)], dim=0) rowptr = rowcount.new_zeros(rowcount.numel() + 1)
torch.cumsum(rowcount, dim=0, out=rowptr[1:])
return rowptr
@cached_property @cached_property
def colcount(self): def colcount(self):
...@@ -205,7 +207,9 @@ class SparseStorage(object): ...@@ -205,7 +207,9 @@ class SparseStorage(object):
@cached_property @cached_property
def colptr(self): def colptr(self):
colcount = self.colcount colcount = self.colcount
return torch.cat([colcount.new_zeros(1), colcount.cumsum(0)], dim=0) colptr = colcount.new_zeros(colcount.numel() + 1)
torch.cumsum(colcount, dim=0, out=colptr[1:])
return colptr
@cached_property @cached_property
def csr2csc(self): def csr2csc(self):
......
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