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
cf5c1930
Unverified
Commit
cf5c1930
authored
Jul 26, 2023
by
Quan (Andy) Gan
Committed by
GitHub
Jul 27, 2023
Browse files
[Bugfix] Fix 5873 (#5884)
Co-authored-by:
Hongzhi (Steve), Chen
<
chenhongzhi.nkcs@gmail.com
>
parent
c334662b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
6 deletions
+38
-6
python/dgl/heterograph.py
python/dgl/heterograph.py
+6
-6
tests/python/common/test_heterograph-update-all.py
tests/python/common/test_heterograph-update-all.py
+32
-0
No files found.
python/dgl/heterograph.py
View file @
cf5c1930
...
@@ -5263,12 +5263,12 @@ class DGLGraph(object):
...
@@ -5263,12 +5263,12 @@ class DGLGraph(object):
out
=
reduce_dict_data
(
frames
,
cross_reducer
,
merge_order
[
dtid
])
out
=
reduce_dict_data
(
frames
,
cross_reducer
,
merge_order
[
dtid
])
# Replace infinity with zero for isolated nodes when reducer is min/max
# Replace infinity with zero for isolated nodes when reducer is min/max
if
core
.
is_builtin
(
rfunc
)
and
rfunc
.
name
in
[
"min"
,
"max"
]:
if
core
.
is_builtin
(
rfunc
)
and
rfunc
.
name
in
[
"min"
,
"max"
]:
key
=
list
(
out
.
keys
()
)[
0
]
for
key
in
out
.
keys
()
:
out
[
key
]
=
(
out
[
key
]
=
(
F
.
replace_inf_with_zero
(
out
[
key
])
F
.
replace_inf_with_zero
(
out
[
key
])
if
out
[
key
]
is
not
None
if
out
[
key
]
is
not
None
else
None
else
None
)
)
self
.
_node_frames
[
dtid
].
update
(
out
)
self
.
_node_frames
[
dtid
].
update
(
out
)
# apply
# apply
if
apply_node_func
is
not
None
:
if
apply_node_func
is
not
None
:
...
...
tests/python/common/test_heterograph-update-all.py
View file @
cf5c1930
...
@@ -334,6 +334,38 @@ def test_binary_op(idtype):
...
@@ -334,6 +334,38 @@ def test_binary_op(idtype):
_test
(
lhs
,
rhs
,
binary_op
,
reducer
)
_test
(
lhs
,
rhs
,
binary_op
,
reducer
)
# Issue #5873
def
test_multi_update_all_minmax_reduce_with_isolated_nodes
():
g
=
dgl
.
heterograph
(
{
(
"A"
,
"AB"
,
"B"
):
([
0
,
1
,
2
,
3
],
[
0
,
0
,
1
,
1
]),
(
"C"
,
"CB"
,
"B"
):
([
0
,
1
,
2
,
3
],
[
2
,
2
,
3
,
3
]),
},
device
=
F
.
ctx
(),
)
g
.
nodes
[
"A"
].
data
[
"x"
]
=
F
.
randn
((
4
,
16
))
g
.
nodes
[
"C"
].
data
[
"x"
]
=
F
.
randn
((
4
,
16
))
g
.
multi_update_all
(
{
"AB"
:
(
dgl
.
function
.
copy_u
(
"x"
,
"m"
),
dgl
.
function
.
min
(
"m"
,
"a1"
)),
"CB"
:
(
dgl
.
function
.
copy_u
(
"x"
,
"m"
),
dgl
.
function
.
min
(
"m"
,
"a2"
)),
},
cross_reducer
=
"min"
,
)
assert
not
np
.
isinf
(
F
.
asnumpy
(
g
.
nodes
[
"B"
].
data
[
"a1"
])).
any
()
assert
not
np
.
isinf
(
F
.
asnumpy
(
g
.
nodes
[
"B"
].
data
[
"a2"
])).
any
()
g
.
multi_update_all
(
{
"AB"
:
(
dgl
.
function
.
copy_u
(
"x"
,
"m"
),
dgl
.
function
.
max
(
"m"
,
"a1"
)),
"CB"
:
(
dgl
.
function
.
copy_u
(
"x"
,
"m"
),
dgl
.
function
.
max
(
"m"
,
"a2"
)),
},
cross_reducer
=
"max"
,
)
assert
not
np
.
isinf
(
F
.
asnumpy
(
g
.
nodes
[
"B"
].
data
[
"a1"
])).
any
()
assert
not
np
.
isinf
(
F
.
asnumpy
(
g
.
nodes
[
"B"
].
data
[
"a2"
])).
any
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_unary_copy_u
()
test_unary_copy_u
()
test_unary_copy_e
()
test_unary_copy_e
()
...
...
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