trevor-m commented on a change in pull request #5106: [Relay][MergeComposite]
Support TupleGetItem in body of pattern
URL: https://github.com/apache/incubator-tvm/pull/5106#discussion_r398106710
##########
File path: src/relay/transforms/merge_composite.cc
##########
@@ -66,6 +66,31 @@ class MergeCompositeWrapper : public ExprMutator {
return root;
}
+ Expr ExtractPattern(const TupleGetItem& pattern, const Expr& root,
+ Map<std::string, Array<Expr>>* var_map, Map<Expr, Expr>* call_map) {
+ if (!root->IsInstance<TupleGetItemNode>()) {
+ return Expr();
+ }
+ auto root_node = Downcast<TupleGetItem>(root);
+ if (pattern->index != root_node->index) {
+ return Expr();
+ }
+ if (pattern->tuple->IsInstance<CallNode>() &&
+ root_node->tuple->IsInstance<CallNode>()) {
+ Expr new_arg;
+ if (call_map->find(pattern->tuple) != call_map->end()) {
+ new_arg = (*call_map)[pattern->tuple];
+ } else {
+ new_arg = ExtractPattern(Downcast<Call>(pattern->tuple),
+ Downcast<Call>(root_node->tuple),
+ var_map, call_map);
+ call_map->Set(pattern->tuple, new_arg);
Review comment:
Call map is still only used for call nodes with this PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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