[RFC][External Codegen] Extending MergeComposite to pattern match other node types

Thank you to Matt and the community for the work on the MergeComposite pass. RFC here: [RFC][External Codegen] Defining 'Composite' Relay operators

I would like to use the MergeComposite pass to fuse relay.vision.get_valid_counts and relay.vision.non_max_suppression for my TensorRT integration using Bring Your Own Codegen, however the op pattern contains two TupleGetItem nodes. The current implementation can only pattern match with Call nodes.

Therefore, I plan to extend MergeComposite to support pattern matching with TupleGetItemNode and TupleNode for now. Any thoughts? The change looks fairly straightforward to me.

@mbaret @masahi @jonso @comaniac

I think the reason that we only support call node for now is because we assume most 3rd party backend developers only care about call nodes, but it definitely can be supported as long as there is a motivation.

Also cc @zhiics.

Sorry for the delay, I’ve been on holiday :slight_smile: There’s no fundamental reason to limit it to call nodes, so if you can contribute a patch to extend it that’d be great. I anticipate much of the pattern matching in merge composite will be obsoleted when the pattern matching mechanism in Relay is introduced, but until then we can continue adding support.