[SOLVED] Can Relax fuse same OPs that appear at the start of multiple branches?

Will operator fusion in Relax perform the following fusion? Let me illustrate it with a diagram.

Merge different branch with same starting op.

          |---> B --> D ...
    A --->
          |---> C --> E ...

    The B and C have same call.op, call.args, call.attr, can be merged as:

                 |---> D ...
    A ---> B --->
                 |---> E ...

I think this is a very classic fusion pattern, yet it wasn’t fused in my subgraph, which puzzles me. Or perhaps this fusion is handled in a specific pass that I didn’t invoke?

seems right now it is not supported but something that can be added i think through pattern detect rewrite

Sorry, I overlooked this—I was only focusing on our internal pass pipeline. It turns out the pass relax.transform.EliminateCommonSubexpr handles this fusion case.

2 Likes