diff --git a/src/relay/transforms/merge_composite.cc b/src/relay/transforms/merge_composite.cc index b9eef746591b..596e2a1a29eb 100644 --- a/src/relay/transforms/merge_composite.cc +++ b/src/relay/transforms/merge_composite.cc @@ -121,7 +121,7 @@ class MergeCompositeWrapper : public ExprMutator { Array new_args; for (const auto& arg : pattern->args) { Expr new_arg; - if (arg->IsInstance()) { + if (arg->IsInstance() && root->args[i]->IsInstance()) { new_arg = ExtractPattern(Downcast(arg), Downcast(root->args[i]), var_map, call_map); // if we've already processed this call node, return the previous result