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
f9b00093
Commit
f9b00093
authored
Jan 29, 2020
by
rusty1s
Browse files
typing
parent
34b25b3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
torch_sparse/tensor.py
torch_sparse/tensor.py
+6
-5
No files found.
torch_sparse/tensor.py
View file @
f9b00093
from
textwrap
import
indent
from
textwrap
import
indent
from
typing
import
Optional
,
List
,
Tuple
,
Union
from
typing
import
Optional
,
List
,
Tuple
,
Dict
,
Union
,
Any
import
torch
import
torch
import
scipy.sparse
import
scipy.sparse
...
@@ -404,7 +404,9 @@ def is_shared(self: SparseTensor) -> bool:
...
@@ -404,7 +404,9 @@ def is_shared(self: SparseTensor) -> bool:
@
torch
.
jit
.
ignore
@
torch
.
jit
.
ignore
def
to
(
self
,
*
args
,
**
kwargs
):
def
to
(
self
,
*
args
:
Optional
[
List
[
Any
]],
**
kwargs
:
Optional
[
Dict
[
str
,
Any
]])
->
SparseTensor
:
dtype
:
Dtype
=
getattr
(
kwargs
,
'dtype'
,
None
)
dtype
:
Dtype
=
getattr
(
kwargs
,
'dtype'
,
None
)
device
:
Device
=
getattr
(
kwargs
,
'device'
,
None
)
device
:
Device
=
getattr
(
kwargs
,
'device'
,
None
)
non_blocking
:
bool
=
getattr
(
kwargs
,
'non_blocking'
,
False
)
non_blocking
:
bool
=
getattr
(
kwargs
,
'non_blocking'
,
False
)
...
@@ -424,8 +426,7 @@ def to(self, *args, **kwargs):
...
@@ -424,8 +426,7 @@ def to(self, *args, **kwargs):
@
torch
.
jit
.
ignore
@
torch
.
jit
.
ignore
def
__getitem__
(
self
,
index
):
def
__getitem__
(
self
:
SparseTensor
,
index
:
Any
)
->
SparseTensor
:
raise
NotImplementedError
index
=
list
(
index
)
if
isinstance
(
index
,
tuple
)
else
[
index
]
index
=
list
(
index
)
if
isinstance
(
index
,
tuple
)
else
[
index
]
# More than one `Ellipsis` is not allowed...
# More than one `Ellipsis` is not allowed...
if
len
([
i
for
i
in
index
if
not
torch
.
is_tensor
(
i
)
and
i
==
...])
>
1
:
if
len
([
i
for
i
in
index
if
not
torch
.
is_tensor
(
i
)
and
i
==
...])
>
1
:
...
@@ -468,7 +469,7 @@ def __getitem__(self, index):
...
@@ -468,7 +469,7 @@ def __getitem__(self, index):
@
torch
.
jit
.
ignore
@
torch
.
jit
.
ignore
def
__repr__
(
self
)
:
def
__repr__
(
self
:
SparseTensor
)
->
str
:
i
=
' '
*
6
i
=
' '
*
6
row
,
col
,
value
=
self
.
coo
()
row
,
col
,
value
=
self
.
coo
()
infos
=
[]
infos
=
[]
...
...
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