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
5f4f9c55
Commit
5f4f9c55
authored
Aug 16, 2021
by
rusty1s
Browse files
cpu and cuda methods
parent
3dbd2282
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
torch_sparse/tensor.py
torch_sparse/tensor.py
+11
-0
No files found.
torch_sparse/tensor.py
View file @
5f4f9c55
...
@@ -455,6 +455,15 @@ def to(self, *args: Optional[List[Any]],
...
@@ -455,6 +455,15 @@ def to(self, *args: Optional[List[Any]],
return
self
return
self
def
cpu
(
self
)
->
SparseTensor
:
return
self
.
device_as
(
torch
.
tensor
(
0.
,
device
=
'cpu'
))
def
cuda
(
self
,
device
:
Optional
[
Union
[
int
,
str
]]
=
None
,
non_blocking
:
bool
=
False
):
return
self
.
device_as
(
torch
.
tensor
(
0.
,
device
=
device
or
'cuda'
))
def
__getitem__
(
self
:
SparseTensor
,
index
:
Any
)
->
SparseTensor
:
def
__getitem__
(
self
:
SparseTensor
,
index
:
Any
)
->
SparseTensor
:
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...
...
@@ -523,6 +532,8 @@ def __repr__(self: SparseTensor) -> str:
...
@@ -523,6 +532,8 @@ def __repr__(self: SparseTensor) -> str:
SparseTensor
.
share_memory_
=
share_memory_
SparseTensor
.
share_memory_
=
share_memory_
SparseTensor
.
is_shared
=
is_shared
SparseTensor
.
is_shared
=
is_shared
SparseTensor
.
to
=
to
SparseTensor
.
to
=
to
SparseTensor
.
cpu
=
cpu
SparseTensor
.
cuda
=
cuda
SparseTensor
.
__getitem__
=
__getitem__
SparseTensor
.
__getitem__
=
__getitem__
SparseTensor
.
__repr__
=
__repr__
SparseTensor
.
__repr__
=
__repr__
...
...
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