Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-sparse
Commits
c5d606bf
Commit
c5d606bf
authored
Mar 05, 2021
by
rusty1s
Browse files
support PyTorch 1.8.0
parent
a3cd60c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
21 deletions
+23
-21
torch_sparse/storage.py
torch_sparse/storage.py
+6
-10
torch_sparse/tensor.py
torch_sparse/tensor.py
+17
-11
No files found.
torch_sparse/storage.py
View file @
c5d606bf
...
...
@@ -141,16 +141,12 @@ class SparseStorage(object):
@
classmethod
def
empty
(
self
):
self
=
SparseStorage
.
__new__
(
SparseStorage
)
self
.
_row
=
None
self
.
_rowptr
=
None
self
.
_value
=
None
self
.
_rowcount
=
None
self
.
_colptr
=
None
self
.
_colcount
=
None
self
.
_csr2csc
=
None
self
.
_csc2csr
=
None
return
self
row
=
torch
.
tensor
([],
dtype
=
torch
.
long
)
col
=
torch
.
tensor
([],
dtype
=
torch
.
long
)
return
SparseStorage
(
row
=
row
,
rowptr
=
None
,
col
=
col
,
value
=
None
,
sparse_sizes
=
(
0
,
0
),
rowcount
=
None
,
colptr
=
None
,
colcount
=
None
,
csr2csc
=
None
,
csc2csr
=
None
,
is_sorted
=
True
)
def
has_row
(
self
)
->
bool
:
return
self
.
_row
is
not
None
...
...
torch_sparse/tensor.py
View file @
c5d606bf
...
...
@@ -26,9 +26,15 @@ class SparseTensor(object):
@
classmethod
def
from_storage
(
self
,
storage
:
SparseStorage
):
self
=
SparseTensor
.
__new__
(
SparseTensor
)
self
.
storage
=
storage
return
self
out
=
SparseTensor
(
row
=
storage
.
_row
,
rowptr
=
storage
.
_rowptr
,
col
=
storage
.
_col
,
value
=
storage
.
_value
,
sparse_sizes
=
storage
.
_sparse_sizes
,
is_sorted
=
True
)
out
.
storage
.
_rowcount
=
storage
.
_rowcount
out
.
storage
.
_colptr
=
storage
.
_colptr
out
.
storage
.
_colcount
=
storage
.
_colcount
out
.
storage
.
_csr2csc
=
storage
.
_csr2csc
out
.
storage
.
_csc2csr
=
storage
.
_csc2csr
return
out
@
classmethod
def
from_edge_index
(
self
,
edge_index
:
torch
.
Tensor
,
...
...
@@ -109,14 +115,14 @@ class SparseTensor(object):
colcount
[
M
:]
=
0
csr2csc
=
csc2csr
=
row
storage
:
SparseStorage
=
SparseStorage
(
row
=
row
,
rowptr
=
rowptr
,
col
=
col
,
value
=
value
,
sparse_sizes
=
(
M
,
N
),
rowcount
=
rowcount
,
colptr
=
colptr
,
colcount
=
col
count
,
csr2csc
=
csr2csc
,
csc2csr
=
csc2csr
,
is_sorted
=
True
)
self
=
SparseTensor
.
__new__
(
SparseTensor
)
self
.
storage
=
storage
return
self
out
=
SparseTensor
(
row
=
row
,
rowptr
=
rowptr
,
col
=
col
,
value
=
value
,
sparse_sizes
=
(
M
,
N
),
is_sorted
=
True
)
out
.
storage
.
_rowcount
=
row
count
out
.
storage
.
_colptr
=
colptr
out
.
storage
.
_colcount
=
colcount
out
.
storage
.
_csr2csc
=
csr2csc
out
.
storage
.
_csc2csr
=
csc2csr
return
out
def
copy
(
self
):
return
self
.
from_storage
(
self
.
storage
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment