reminisce closed pull request #11767: [WIP] Fix subgraph duplicate entry bugs
URL: https://github.com/apache/incubator-mxnet/pull/11767
 
 
   

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/src/operator/subgraph/partition_graph.cc 
b/src/operator/subgraph/partition_graph.cc
index 11af49ac663..c935c8f4d70 100644
--- a/src/operator/subgraph/partition_graph.cc
+++ b/src/operator/subgraph/partition_graph.cc
@@ -622,6 +622,10 @@ void TopSortEntries(const Graph& g,
     if (visited.count(node) == 0U) {
       s.emplace(node, 0U, &e);
       visited.insert(node);
+    } else {
+      // The entry's source node has been visited before.
+      // Marking the order for it.
+      entry_top_order_map->emplace(&e, entry_top_order_map->size());
     }
     while (!s.empty()) {
       auto& top = s.top();
@@ -641,7 +645,7 @@ void TopSortEntries(const Graph& g,
           visited.insert(input_node);
         } else {
           // The entry's source node has been visited before.
-          // Marking order for it.
+          // Marking the order for it.
           entry_top_order_map->emplace(&entry, entry_top_order_map->size());
         }
       }
diff --git a/tests/python/unittest/test_subgraph_op.py 
b/tests/python/unittest/test_subgraph_op.py
index f08c42c3063..0e5c1e05c6c 100644
--- a/tests/python/unittest/test_subgraph_op.py
+++ b/tests/python/unittest/test_subgraph_op.py
@@ -124,10 +124,18 @@ def test_network_structure_4():
         check_input_order(ret, ['exp', 'BatchNorm'])
         check_input_order(ret, ['BatchNorm'])
 
+    def test_network_structure_5():
+        # the last op has multiple duplicate outputs
+        data = mx.sym.var('data')
+        ret = mx.sym.exp(data)
+        ret = mx.sym.Group([ret, ret, ret])
+        check_input_order(ret, ['exp'])
+
     test_network_structure_1()
     test_network_structure_2()
     test_network_structure_3()
     test_network_structure_4()
+    test_network_structure_5()
 
 
 if __name__ == '__main__':


 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to