Junru Shao created MXNET-790:
--------------------------------

             Summary: Correct misusage of `CutSubgraph` in 3 control flow 
operations
                 Key: MXNET-790
                 URL: https://issues.apache.org/jira/browse/MXNET-790
             Project: Apache MXNet
          Issue Type: Improvement
            Reporter: Junru Shao


This PR corrects the usage of `CutSubgraph`.

`CutSubgraph` consumes a Symbol `s`, and
1) Assumes the attribute `__subgraph_name__` of `s->outputs[0].node` is the 
name of the subgraph
2) Assumes the boundary of this subgraph be nodes who has at least one 
immediate predecessor whose attribute `__subgraph_name__` is not the name of 
the subgraph
3) Duplicates and puts these immediate predecessors into this subgraph

Calling `CutSubgraph` without very special care will cause disastrous 
consequences, often when `s->outputa[0].node` has an improper name. For 
example, in control flow operators, if we write a function `lambda: x` which 
captures an outside symbol `x` (so the attribute of `x` is not desirable), and 
an operator passes `x` into `CutGraph` as the first output of subgraph, the 
entire procedure breaks. Without copying and manually correcting such symbols, 
this will happen anywhere and be very hard to debug. An example that causes 
this bug could be https://github.com/dmlc/gluon-nlp/pull/233 in which the 
`pred` I pass to `cond` is calculated outside the subgraph.

This bug affects all three control flow operators, `foreach`, `while_loop` and 
`cond`.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to