[BYOC][MergeComposite] if root->args[i] isn't a CallNode, then Donwcast<Call> will...
authorwindclarion <windclarion@gmail.com>
Wed, 20 May 2020 01:10:50 +0000 (09:10 +0800)
committerGitHub <noreply@github.com>
Wed, 20 May 2020 01:10:50 +0000 (10:10 +0900)
we needn't execute L131 "call_map->Set(arg, new_arg)", because when arg
is CallNode and root->args[i] is not CallNode, new_arg will be a null
pointer. There is no point in caching null pointer.

Signed-off-by: windclarion <windclarion@gmail.com>
src/relay/transforms/merge_composite.cc

index b9eef74..596e2a1 100644 (file)
@@ -121,7 +121,7 @@ class MergeCompositeWrapper : public ExprMutator {
     Array<Expr> new_args;
     for (const auto& arg : pattern->args) {
       Expr new_arg;
-      if (arg->IsInstance<CallNode>()) {
+      if (arg->IsInstance<CallNode>() && root->args[i]->IsInstance<CallNode>()) {
         new_arg =
             ExtractPattern(Downcast<Call>(arg), Downcast<Call>(root->args[i]), var_map, call_map);
         // if we've already processed this call node, return the previous result