You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by an...@apache.org on 2018/08/17 19:45:07 UTC

[incubator-mxnet] branch master updated: Add test to check that binded is not set when exception thrown (#12167)

This is an automated email from the ASF dual-hosted git repository.

anirudh2290 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new f737cac  Add test to check that binded is not set when exception thrown (#12167)
f737cac is described below

commit f737cace17991d0505e891110f67a9d945acccb2
Author: Alexander Zai <az...@gmail.com>
AuthorDate: Fri Aug 17 15:44:56 2018 -0400

    Add test to check that binded is not set when exception thrown (#12167)
    
    * add test to check binded is not when exception thrown
    
    * add error to assertion
    
    * fix typo by adding asserts
    
    * retrigger
---
 tests/python/unittest/test_module.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tests/python/unittest/test_module.py b/tests/python/unittest/test_module.py
index 5e60989..39fcd81 100644
--- a/tests/python/unittest/test_module.py
+++ b/tests/python/unittest/test_module.py
@@ -44,6 +44,18 @@ def test_module_dtype():
       assert x.dtype == dtype
 
 
+def test_module_bind():
+    sym = mx.sym.Variable('data')
+    sym = mx.sym.Activation(data=sym, act_type='relu', __layout__='TNC')
+
+    mod = mx.mod.Module(sym, ('data',), None, context=[mx.cpu(0), mx.cpu(1)])
+    assertRaises(TypeError, mod.bind, data_shapes=[('data', mx.nd.array([10,10]))])
+    assert mod.binded == False
+
+    mod.bind(data_shapes=[('data', (10,10))])
+    assert mod.binded == True
+
+
 @with_seed()
 def test_module_input_grads():
     a = mx.sym.Variable('a', __layout__='NC')