zheng-da commented on a change in pull request #12106: [MXNET-795] Fix a bug 
that CutSubgraph works only when each subgraph has its distinct name
URL: https://github.com/apache/incubator-mxnet/pull/12106#discussion_r209438332
 
 

 ##########
 File path: tests/python/unittest/test_contrib_control_flow.py
 ##########
 @@ -1765,6 +1767,45 @@ def hybrid_forward(self, F, data):
     assert_almost_equal(res1.asnumpy(), res2.asnumpy(), rtol=0.001, 
atol=0.0001)
 
 
+def test_scope():
+    class TestBlock1(gluon.HybridBlock):
+        def __init__(self, prefix=None, params=None):
+            super(TestBlock1, self).__init__(prefix=prefix, params=params)
+        def hybrid_forward(self, F, data):
+            (new_data, ) = F.contrib.cond(
+                data > 0.5,
+                then_func=lambda: data * 2,
+                else_func=lambda: data * 3,
+                name="my_cond",
+            )
+            return new_data
+    class TestBlock2(gluon.HybridBlock):
+        def __init__(self, prefix=None, params=None):
+            super(TestBlock2, self).__init__(prefix=prefix, params=params)
+        def hybrid_forward(self, F, data):
+            (new_data, ) = F.contrib.cond(
+                data > 0.5,
+                then_func=lambda: data * 2,
+                else_func=lambda: data * 3,
+                name="my_cond",
+            )
+            return new_data
+    AttrScope._subgraph_names = defaultdict(int)
 
 Review comment:
   good point.

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