You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/12/22 20:20:40 UTC
[GitHub] eric-haibin-lin closed pull request #13514: Rearrange tests written
only for update_on_kvstore = True
eric-haibin-lin closed pull request #13514: Rearrange tests written only for update_on_kvstore = True
URL: https://github.com/apache/incubator-mxnet/pull/13514
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/tests/python/unittest/test_gluon_trainer.py b/tests/python/unittest/test_gluon_trainer.py
index 72c01acb265..b4bfe4c47f0 100644
--- a/tests/python/unittest/test_gluon_trainer.py
+++ b/tests/python/unittest/test_gluon_trainer.py
@@ -74,12 +74,13 @@ def dict_equ(a, b):
if trainer._update_on_kvstore:
dict_equ(trainer._kvstore._updater.states, states)
assert trainer._optimizer == trainer._kvstore._updater.optimizer
+ # invalid usage of update and allreduce_grads if update_on_kvstore
+ assert_raises(AssertionError, trainer.update, 1)
+ assert_raises(AssertionError, trainer.allreduce_grads)
else:
for updater in trainer._updaters:
dict_equ(updater.states, states)
assert trainer._optimizer == trainer._updaters[0].optimizer
- assert_raises(AssertionError, trainer.update, 1)
- assert_raises(AssertionError, trainer.allreduce_grads)
x = gluon.Parameter('x', shape=(10,))
x.initialize(ctx=[mx.cpu(0), mx.cpu(1)], init='zeros')
@@ -193,8 +194,10 @@ def check_trainer_reset_kv(kv):
# load would reset kvstore
mx.nd.waitall()
params.load('test_trainer_reset_kv.params')
- assert trainer._kvstore is None
- assert trainer._kv_initialized is False
+ if trainer._update_on_kvstore:
+ # drop kvstore state if new parameters are loaded
+ assert trainer._kvstore is None
+ assert trainer._kv_initialized is False
with mx.autograd.record():
for w in x.list_data():
y = w + 1
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services