Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Remove in-place broadcast API
Browse files Browse the repository at this point in the history
  • Loading branch information
apeforest committed Mar 9, 2020
1 parent 33f9a68 commit 3fad1de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
19 changes: 6 additions & 13 deletions python/mxnet/kvstore/horovod.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ def broadcast(self, key, value, out=None, priority=0):
Examples
--------
>>> # broadcast a value in-place
>>> shape = (2,3)
>>> kv = mx.kv.create('horovod')
>>> a = mx.nd.ones(shape)
>>> kv.broadcast('1', value=a)
>>> print(a.asnumpy())
[[ 1. 1. 1.]
[ 1. 1. 1.]]
>>> a = mx.nd.ones(shape)
>>> b = mx.nd.zeros(shape)
>>> kv.broadcast('2', value=a, out=b)
Expand All @@ -74,10 +65,12 @@ def broadcast(self, key, value, out=None, priority=0):
"""
import horovod.mxnet as hvd

if out is None:
hvd.broadcast_(tensor=value, root_rank=0, name=key, priority=priority)
else:
out[:] = hvd.broadcast(tensor=value, root_rank=0, name=key, priority=priority)
out = out if isinstance(out, list) else [out]

# TODO (lnyuan): need to copy data to each device memory
for o in out:
o[:] = hvd.broadcast(tensor=value, root_rank=0, name=str(key),
priority=priority)

def pushpull(self, key, value, out=None, priority=0):
""" Performs allreduce on a single tensor or a list of tensor objects
Expand Down
4 changes: 2 additions & 2 deletions tools/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def dmlc_opts(opts):
try:
from dmlc_tracker import opts
except ImportError:
print("Can't load dmlc_tracker package. Perhaps you need to run")
print(" git submodule update --init --recursive")
logging.info("Can't load dmlc_tracker package. Perhaps you need to run")
logging.info(" git submodule update --init --recursive")
raise
dmlc_opts = opts.get_opts(args)
return dmlc_opts
Expand Down

0 comments on commit 3fad1de

Please sign in to comment.