larroy commented on a change in pull request #11641: [WIP] make CachedOp a 
normal operator
URL: https://github.com/apache/incubator-mxnet/pull/11641#discussion_r201625843
 
 

 ##########
 File path: tests/python/unittest/test_operator.py
 ##########
 @@ -6968,6 +6968,39 @@ def test_roi_align_autograd(sampling_ratio=0):
     test_roi_align_autograd()
 
 
+def test_make_subgraph():
+    a = mx.symbol.Variable(name='a')
+    b = mx.symbol.Variable(name='b')
+    c = a + b
+    d = c * 2
+
+    a1 = mx.symbol.Variable(name='a1')
+    b1 = mx.symbol.Variable(name='b1')
+    y = mx.symbol.contrib.make_subgraph(c, a1, b1)
+    y = y * 2
+
+    a_arr = mx.nd.random.uniform(-1, 1, shape=(10, 10), ctx=default_context())
+    b_arr = mx.nd.random.uniform(-1, 1, shape=(10, 10), ctx=default_context())
+    e1 = d.bind(ctx=default_context(), args={'a': a_arr, 'b': b_arr},
+            args_grad={'a': mx.nd.empty(shape=(10, 10)),
+                       'b': mx.nd.empty(shape=(10, 10))})
+    e2 = y.bind(ctx=default_context(), args={'a1': a_arr, 'b1': b_arr},
+            args_grad={'a': mx.nd.empty(shape=(10, 10)),
+                       'b': mx.nd.empty(shape=(10, 10))})
+    e1.forward()
+    e2.forward()
+    assert_almost_equal(e1.outputs[0].asnumpy(), e2.outputs[0].asnumpy(),
 
 Review comment:
   Why almost equal and not equal?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to