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
6cd7c313
Unverified
Commit
6cd7c313
authored
Apr 23, 2020
by
Minjie Wang
Committed by
GitHub
Apr 23, 2020
Browse files
[Bugfix] Fix corrupted memory when using multi-processing (#1453)
* fix * fix mapping array for empty node set
parent
5efd1c4a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
python/dgl/transform.py
python/dgl/transform.py
+6
-4
No files found.
python/dgl/transform.py
View file @
6cd7c313
...
...
@@ -898,8 +898,6 @@ def to_block(g, dst_nodes=None, include_dst_in_src=True):
new_graph_index
,
src_nodes_nd
,
induced_edges_nd
=
_CAPI_DGLToBlock
(
g
.
_graph
,
dst_nodes_nd
,
include_dst_in_src
)
src_nodes
=
[
F
.
zerocopy_from_dgl_ndarray
(
nodes_nd
.
data
)
for
nodes_nd
in
src_nodes_nd
]
dst_nodes
=
[
F
.
zerocopy_from_dgl_ndarray
(
nodes_nd
)
for
nodes_nd
in
dst_nodes_nd
]
# The new graph duplicates the original node types to SRC and DST sets.
new_ntypes
=
([
ntype
for
ntype
in
g
.
ntypes
],
[
ntype
for
ntype
in
g
.
ntypes
])
...
...
@@ -907,8 +905,12 @@ def to_block(g, dst_nodes=None, include_dst_in_src=True):
assert
new_graph
.
is_unibipartite
# sanity check
for
i
,
ntype
in
enumerate
(
g
.
ntypes
):
new_graph
.
srcnodes
[
ntype
].
data
[
NID
]
=
src_nodes
[
i
]
new_graph
.
dstnodes
[
ntype
].
data
[
NID
]
=
dst_nodes
[
i
]
new_graph
.
srcnodes
[
ntype
].
data
[
NID
]
=
F
.
zerocopy_from_dgl_ndarray
(
src_nodes_nd
[
i
].
data
)
if
ntype
in
dst_nodes
:
new_graph
.
dstnodes
[
ntype
].
data
[
NID
]
=
dst_nodes
[
ntype
]
else
:
# For empty dst node sets, still create empty mapping arrays.
new_graph
.
dstnodes
[
ntype
].
data
[
NID
]
=
F
.
tensor
([],
dtype
=
F
.
int64
)
for
i
,
canonical_etype
in
enumerate
(
g
.
canonical_etypes
):
induced_edges
=
F
.
zerocopy_from_dgl_ndarray
(
induced_edges_nd
[
i
].
data
)
...
...
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