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-scatter
Commits
670e9f99
"test/vscode:/vscode.git/clone" did not exist on "877e35d7754cd1fa60b3f1226929dbc84146ea70"
Commit
670e9f99
authored
Jun 24, 2019
by
rusty1s
Browse files
pass out tensor to internal scatters (if present)
parent
0961269f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
test/test_std.py
test/test_std.py
+5
-4
torch_scatter/std.py
torch_scatter/std.py
+6
-2
No files found.
test/test_std.py
View file @
670e9f99
...
@@ -22,8 +22,9 @@ def test_std(dtype, device, bias):
...
@@ -22,8 +22,9 @@ def test_std(dtype, device, bias):
@
pytest
.
mark
.
parametrize
(
'dtype,device'
,
product
(
dtypes
,
devices
))
@
pytest
.
mark
.
parametrize
(
'dtype,device'
,
product
(
dtypes
,
devices
))
def
test_empty_std
(
dtype
,
device
):
def
test_empty_std
(
dtype
,
device
):
src
=
tensor
([],
dtype
,
device
)
out
=
torch
.
zeros
(
1
,
5
,
dtype
=
dtype
,
device
=
device
)
index
=
tensor
([],
torch
.
long
,
device
)
src
=
tensor
([],
dtype
,
device
).
view
(
0
,
5
)
index
=
tensor
([],
torch
.
long
,
device
).
view
(
0
,
5
)
out
=
scatter_std
(
src
,
index
,
dim
=
-
1
)
out
=
scatter_std
(
src
,
index
,
dim
=
0
,
out
=
out
)
assert
out
.
tolist
()
==
[]
assert
out
.
tolist
()
==
[
[
0
,
0
,
0
,
0
,
0
]
]
torch_scatter/std.py
View file @
670e9f99
...
@@ -48,8 +48,12 @@ def scatter_std(src, index, dim=-1, out=None, dim_size=None, unbiased=True):
...
@@ -48,8 +48,12 @@ def scatter_std(src, index, dim=-1, out=None, dim_size=None, unbiased=True):
"""
"""
src
,
out
,
index
,
dim
=
gen
(
src
,
index
,
dim
,
out
,
dim_size
,
fill_value
=
0
)
src
,
out
,
index
,
dim
=
gen
(
src
,
index
,
dim
,
out
,
dim_size
,
fill_value
=
0
)
tmp
=
scatter_add
(
src
,
index
,
dim
,
None
,
dim_size
)
tmp
=
None
if
out
is
None
else
out
.
clone
().
fill_
(
0
)
count
=
scatter_add
(
torch
.
ones_like
(
src
),
index
,
dim
,
None
,
dim_size
)
tmp
=
scatter_add
(
src
,
index
,
dim
,
tmp
,
dim_size
)
count
=
None
if
out
is
None
else
out
.
clone
().
fill_
(
0
)
count
=
scatter_add
(
torch
.
ones_like
(
src
),
index
,
dim
,
count
,
dim_size
)
mean
=
tmp
/
count
.
clamp
(
min
=
1
)
mean
=
tmp
/
count
.
clamp
(
min
=
1
)
var
=
(
src
-
mean
.
gather
(
dim
,
index
))
var
=
(
src
-
mean
.
gather
(
dim
,
index
))
...
...
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