Skip to content

Commit

Permalink
Followup from apache#9312 (Introduce call_lowered op) (apache#9491)
Browse files Browse the repository at this point in the history
* followups from apache#9312

* remove unneeded moves
  • Loading branch information
electriclilies authored and mehrdadh committed Dec 1, 2021
1 parent 7896a4d commit 087870a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/relay/backend/te_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -607,15 +607,15 @@ class LowerTensorExprMutator : public DeviceAwareExprMutator {
}

// Similarly transform arguments.
Array<Expr> args;
Array<Expr> visited_args;
for (const auto& arg : call_node->args) {
args.push_back(VisitExpr(arg));
visited_args.push_back(VisitExpr(arg));
}

// Already lowered by other means so we don't need to mutate
// the call but we do need to mutate the arguments
if (prim_func->IsInstance<tir::PrimFuncNode>()) {
return Call(call_node->op, args, call_node->attrs);
return Call(call_node->op, visited_args, call_node->attrs);
}

// Find the desired target device.
Expand All @@ -630,10 +630,7 @@ class LowerTensorExprMutator : public DeviceAwareExprMutator {
target = se_scope->target;
ICHECK(target.defined());
}
Array<Expr> visited_args;
for (const auto& arg : call_node->args) {
visited_args.push_back(VisitExpr(arg));
}

// Lower the primitive function for that target.
Function func = Downcast<Function>(prim_func);
return MakeLoweredCall(func, visited_args, call_node->type_args, call_node->span, target);
Expand Down
3 changes: 1 addition & 2 deletions src/relay/op/call/call.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ CallLoweredProps GetCallLoweredProps(const CallNode* call_node) {
const auto* attrs = call_node->attrs.as<CallLoweredAttrs>();
ICHECK(attrs) << "Expected call_lowered op to have CallLoweredAttrs, but found "
<< call_node->attrs->GetTypeKey();
return CallLoweredProps{std::move(GetRef<GlobalVar>(function)), std::move(tuple_args->fields),
std::move(*attrs)};
return CallLoweredProps{GetRef<GlobalVar>(function), tuple_args->fields, *attrs};
}

} // namespace relay
Expand Down

0 comments on commit 087870a

Please sign in to comment.