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
dgl
Commits
25a8e3f1
Unverified
Commit
25a8e3f1
authored
Sep 24, 2020
by
Mingjian Wen
Committed by
GitHub
Sep 24, 2020
Browse files
Fix segment_reduce() ignoring tailing 0 segments (#2228)
Co-authored-by:
Quan (Andy) Gan
<
coin2028@hotmail.com
>
parent
40caf1ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
python/dgl/ops/segment.py
python/dgl/ops/segment.py
+2
-1
No files found.
python/dgl/ops/segment.py
View file @
25a8e3f1
...
@@ -50,7 +50,8 @@ def segment_reduce(seglen, value, reducer='sum'):
...
@@ -50,7 +50,8 @@ def segment_reduce(seglen, value, reducer='sum'):
if
len
(
u
)
!=
len
(
v
):
if
len
(
u
)
!=
len
(
v
):
raise
DGLError
(
"Invalid seglen array:"
,
seglen
,
raise
DGLError
(
"Invalid seglen array:"
,
seglen
,
". Its summation must be equal to value.shape[0]."
)
". Its summation must be equal to value.shape[0]."
)
g
=
convert
.
heterograph
({(
'_U'
,
'_E'
,
'_V'
):
(
u
,
v
)})
num_nodes
=
{
'_U'
:
len
(
u
),
'_V'
:
len
(
seglen
)}
g
=
convert
.
heterograph
({(
'_U'
,
'_E'
,
'_V'
):
(
u
,
v
)},
num_nodes_dict
=
num_nodes
)
g
.
srcdata
[
'h'
]
=
value
g
.
srcdata
[
'h'
]
=
value
g
.
update_all
(
fn
.
copy_u
(
'h'
,
'm'
),
getattr
(
fn
,
reducer
)(
'm'
,
'h'
))
g
.
update_all
(
fn
.
copy_u
(
'h'
,
'm'
),
getattr
(
fn
,
reducer
)(
'm'
,
'h'
))
return
g
.
dstdata
[
'h'
]
return
g
.
dstdata
[
'h'
]
...
...
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