The pattern matcher assumes by default that it is safe to run functional passes on the replacement graph. The ones it runs are DCE and remove_noop_ops. We should try to change it to be more automatic and determine if those passes are safe to run (or add invariants if this is too hard, see also https://github.com/pytorch/pytorch/issues/133250).
This is non-trivial:
For DCE we can check if there are any mutable ops. If there are, then it's probably a bad idea to DCE
For remove_noop_ops -- this is trickier. We cannot remove intermediate clones if they end up changing the alias relationship between the outputs and the inputs of the replacement graph.
The pattern matcher assumes by default that it is safe to run functional passes on the replacement graph. The ones it runs are DCE and remove_noop_ops. We should try to change it to be more automatic and determine if those passes are safe to run (or add invariants if this is too hard, see also https://github.com/pytorch/pytorch/issues/133250).
This is non-trivial:
cc @ezyang @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire