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
16ec2a8b
"docs/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "41e4779d988ead99e7acd78dc8e752de88777d0f"
Unverified
Commit
16ec2a8b
authored
Jun 11, 2019
by
Da Zheng
Committed by
GitHub
Jun 11, 2019
Browse files
we need to sync for mxnet. (#648)
parent
d7062980
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
0 deletions
+28
-0
python/dgl/backend/backend.py
python/dgl/backend/backend.py
+9
-0
python/dgl/backend/mxnet/tensor.py
python/dgl/backend/mxnet/tensor.py
+9
-0
python/dgl/backend/pytorch/tensor.py
python/dgl/backend/pytorch/tensor.py
+4
-0
python/dgl/contrib/graph_store.py
python/dgl/contrib/graph_store.py
+6
-0
No files found.
python/dgl/backend/backend.py
View file @
16ec2a8b
...
...
@@ -937,3 +937,12 @@ def copy_reduce(reducer, graph, target, in_data, out_size, in_map, out_map):
# ----------------
# These are not related to tensors. Some of them are temporary workarounds that
# should be included in DGL in the future.
def
sync
():
"""Synchronize computation.
In DL frameworks such as MXNet and TensorFlow, the computation in operators
are done asynchronously. This is to synchronize computation and makes sure
that all computation is complete after this function call.
"""
pass
python/dgl/backend/mxnet/tensor.py
View file @
16ec2a8b
...
...
@@ -393,3 +393,12 @@ def _reduce_grad(grad, shape):
reduce_idx
+=
1
# skip batch dim
grad
=
grad
.
sum
(
axis
=
tuple
(
reduce_idx
),
keepdims
=
True
)
return
grad
.
reshape
(
shape
)
def
sync
():
"""Synchronize computation.
In DL frameworks such as MXNet and TensorFlow, the computation in operators
are done asynchronously. This is to synchronize computation and makes sure
that all computation is complete after this function call.
"""
mx
.
nd
.
waitall
()
python/dgl/backend/pytorch/tensor.py
View file @
16ec2a8b
...
...
@@ -308,3 +308,7 @@ def _reduce_grad(grad, shape):
reduce_idx
+=
1
# skip batch dim
grad
=
grad
.
sum
(
dim
=
tuple
(
reduce_idx
),
keepdim
=
True
)
return
grad
.
view
(
shape
)
def
sync
():
# Pytorch performs computation synchronously, so no need for synchronization.
pass
python/dgl/contrib/graph_store.py
View file @
16ec2a8b
...
...
@@ -363,6 +363,7 @@ class SharedMemoryStoreServer(object):
init
=
self
.
_init_manager
.
deserialize
(
init
)
data
=
init
(
shape
,
dtype
,
_get_ndata_path
(
graph_name
,
ndata_name
))
self
.
_graph
.
ndata
[
ndata_name
]
=
data
F
.
sync
()
return
0
# RPC command: initialize edge embedding in the server.
...
...
@@ -375,6 +376,7 @@ class SharedMemoryStoreServer(object):
assert
self
.
_graph
.
number_of_edges
()
==
shape
[
0
]
init
=
self
.
_init_manager
.
deserialize
(
init
)
data
=
init
(
shape
,
dtype
,
_get_edata_path
(
graph_name
,
edata_name
))
F
.
sync
()
self
.
_graph
.
edata
[
edata_name
]
=
data
return
0
...
...
@@ -636,6 +638,10 @@ class SharedMemoryDGLGraph(BaseGraphStore):
timeout: int
time out in seconds.
"""
# Before entering the barrier, we need to make sure all computation in the local
# process has completed.
F
.
sync
()
# Here I manually implement multi-processing barrier with RPC.
# It uses busy wait with RPC. Whenever, all_enter is called, there is
# a context switch, so it doesn't burn CPUs so badly.
...
...
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