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/11/29 00:26:13 UTC

[GitHub] anirudh2290 commented on a change in pull request #12411: MKLDNN fallback when not recording gradients and calling backwards

anirudh2290 commented on a change in pull request #12411: MKLDNN fallback when not recording gradients and calling backwards
URL: https://github.com/apache/incubator-mxnet/pull/12411#discussion_r237313802
 
 

 ##########
 File path: tests/python/unittest/test_gluon.py
 ##########
 @@ -1221,27 +1221,29 @@ def check_hybrid_static_memory(**kwargs):
     net1(x)
     net2(x)
 
-    def test(net, x):
-        with mx.autograd.record():
+    def test(net, x, record=True):
+        with mx.autograd.record(record):
             y = net(x) + net(x)
             y.backward()
 
         grads = {k: v.grad() for k, v in net.collect_params().items() if v.grad_req != 'null'}
 
         return y, grads
 
-    y1, grads1 = test(net1, x)
-    y2, grads2 = test(net2, x)
+    for record in train_modes:
+        y1, grads1 = test(net1, x, record)
+        y2, grads2 = test(net2, x, record)
 
-    assert_almost_equal(y1.asnumpy(), y2.asnumpy(), rtol=1e-3, atol=1e-5)
-    for key in grads1:
-        assert_almost_equal(grads1[key].asnumpy(), grads2[key].asnumpy(), rtol=1e-3, atol=1e-5)
+        assert_almost_equal(y1.asnumpy(), y2.asnumpy(), rtol=1e-3, atol=1e-5)
+        for key in grads1:
+            assert_almost_equal(grads1[key].asnumpy(), grads2[key].asnumpy(), rtol=1e-3, atol=1e-5)
 
 @with_seed()
 def test_hybrid_static_memory():
-    check_hybrid_static_memory()
-    check_hybrid_static_memory(static_alloc=True)
-    check_hybrid_static_memory(static_alloc=True, static_shape=True)
+    check_hybrid_static_memory(train_mode=[True, False])
 
 Review comment:
   shouldnt it be train_modes ?

----------------------------------------------------------------
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