Skip to content

Commit 11a84c1

Browse files
Don't use std::move in WithFields (#10009)
* Don't use std::move in WithFields * lint
1 parent 2426749 commit 11a84c1

File tree

12 files changed

+40
-44
lines changed

12 files changed

+40
-44
lines changed

src/relay/ir/expr_functor.cc

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Expr ExprMutator::VisitExpr_(const VarNode* var_node) {
166166
if (var_node->type_annotation.defined()) {
167167
type_annotation = this->VisitType(var_node->type_annotation);
168168
}
169-
return WithFields(GetRef<Var>(var_node), std::move(var_node->vid), std::move(type_annotation));
169+
return WithFields(GetRef<Var>(var_node), var_node->vid, type_annotation);
170170
}
171171

172172
Expr ExprMutator::VisitExpr_(const ConstantNode* op) { return GetRef<Expr>(op); }
@@ -183,7 +183,7 @@ Expr ExprMutator::VisitExpr_(const TupleNode* tuple_node) {
183183
auto new_field = this->Mutate(field);
184184
fields.push_back(new_field);
185185
}
186-
return WithFields(GetRef<Tuple>(tuple_node), std::move(fields));
186+
return WithFields(GetRef<Tuple>(tuple_node), fields);
187187
}
188188

189189
Expr ExprMutator::VisitExpr_(const FunctionNode* func_node) {
@@ -203,8 +203,7 @@ Expr ExprMutator::VisitExpr_(const FunctionNode* func_node) {
203203
auto ret_type = this->VisitType(func_node->ret_type);
204204
auto body = this->Mutate(func_node->body);
205205

206-
return WithFields(GetRef<Function>(func_node), std::move(params), std::move(body),
207-
std::move(ret_type), std::move(ty_params));
206+
return WithFields(GetRef<Function>(func_node), params, body, ret_type, ty_params);
208207
}
209208

210209
Expr ExprMutator::VisitExpr_(const CallNode* call_node) {
@@ -225,45 +224,44 @@ Expr ExprMutator::VisitExpr_(const CallNode* call_node) {
225224
call_args.push_back(new_arg);
226225
}
227226

228-
return WithFields(GetRef<Call>(call_node), std::move(new_op), std::move(call_args), {},
229-
std::move(ty_args));
227+
return WithFields(GetRef<Call>(call_node), new_op, call_args, {}, ty_args);
230228
}
231229

232230
Expr ExprMutator::VisitExpr_(const LetNode* let_node) {
233231
Var var = Downcast<Var>(this->Mutate(let_node->var));
234232
auto value = this->Mutate(let_node->value);
235233
auto body = this->Mutate(let_node->body);
236234

237-
return WithFields(GetRef<Let>(let_node), std::move(var), std::move(value), std::move(body));
235+
return WithFields(GetRef<Let>(let_node), var, value, body);
238236
}
239237

240238
Expr ExprMutator::VisitExpr_(const IfNode* if_node) {
241239
auto cond = this->Mutate(if_node->cond);
242240
auto true_b = this->Mutate(if_node->true_branch);
243241
auto false_b = this->Mutate(if_node->false_branch);
244242

245-
return WithFields(GetRef<If>(if_node), std::move(cond), std::move(true_b), std::move(false_b));
243+
return WithFields(GetRef<If>(if_node), cond, true_b, false_b);
246244
}
247245

248246
Expr ExprMutator::VisitExpr_(const TupleGetItemNode* get_item) {
249247
Expr tuple = this->Mutate(get_item->tuple);
250-
return WithFields(GetRef<TupleGetItem>(get_item), std::move(tuple));
248+
return WithFields(GetRef<TupleGetItem>(get_item), tuple);
251249
}
252250

253251
Expr ExprMutator::VisitExpr_(const RefCreateNode* ref_create) {
254252
Expr value = this->Mutate(ref_create->value);
255-
return WithFields(GetRef<RefCreate>(ref_create), std::move(value));
253+
return WithFields(GetRef<RefCreate>(ref_create), value);
256254
}
257255

258256
Expr ExprMutator::VisitExpr_(const RefReadNode* ref_read) {
259257
Expr ref = this->Mutate(ref_read->ref);
260-
return WithFields(GetRef<RefRead>(ref_read), std::move(ref));
258+
return WithFields(GetRef<RefRead>(ref_read), ref);
261259
}
262260

263261
Expr ExprMutator::VisitExpr_(const RefWriteNode* ref_write) {
264262
Expr ref = this->Mutate(ref_write->ref);
265263
Expr value = this->Mutate(ref_write->value);
266-
return WithFields(GetRef<RefWrite>(ref_write), std::move(ref), std::move(value));
264+
return WithFields(GetRef<RefWrite>(ref_write), ref, value);
267265
}
268266

269267
Expr ExprMutator::VisitExpr_(const ConstructorNode* c) { return GetRef<Expr>(c); }
@@ -275,13 +273,13 @@ Expr ExprMutator::VisitExpr_(const MatchNode* match_node) {
275273
}
276274
Expr data = Mutate(match_node->data);
277275

278-
return WithFields(GetRef<Match>(match_node), std::move(data), std::move(clauses));
276+
return WithFields(GetRef<Match>(match_node), data, clauses);
279277
}
280278

281279
Clause ExprMutator::VisitClause(const Clause& clause) {
282280
Pattern lhs = VisitPattern(clause->lhs);
283281
Expr rhs = Mutate(clause->rhs);
284-
return WithFields(std::move(clause), std::move(lhs), std::move(rhs));
282+
return WithFields(clause, lhs, rhs);
285283
}
286284

287285
Pattern ExprMutator::VisitPattern(const Pattern& p) { return p; }
@@ -462,7 +460,7 @@ class ExprBinder : public MixedModeMutator, PatternMutator {
462460

463461
Clause VisitClause(const Clause& clause) final {
464462
Pattern lhs = VisitPattern(clause->lhs);
465-
return WithFields(std::move(clause), std::move(lhs), VisitExpr(clause->rhs));
463+
return WithFields(clause, lhs, VisitExpr(clause->rhs));
466464
}
467465

468466
Var VisitVar(const Var& v) final {

src/relay/transforms/annotate_target.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class AnnotateTargetRewriter : public ExprRewriter {
270270
auto tuple = Downcast<Tuple>(post);
271271

272272
auto target_n_args = AnnotateArgs(tuple->fields);
273-
auto new_expr = WithFields(std::move(tuple), std::move(std::get<1>(target_n_args)));
273+
auto new_expr = WithFields(tuple, std::get<1>(target_n_args));
274274
op_expr_to_target_[new_expr] = std::get<0>(target_n_args);
275275
return std::move(new_expr);
276276
}
@@ -378,7 +378,7 @@ class CallOpsTargetRewriter : public AnnotateTargetRewriter {
378378
for (auto f : tuple->fields) {
379379
new_fields.push_back(InsertCompilerEndAndPropogateTarget(f));
380380
}
381-
return WithFields(std::move(tuple), std::move(new_fields));
381+
return WithFields(tuple, new_fields);
382382
}
383383

384384
Expr Rewrite_(const TupleGetItemNode* op, const Expr& post) override {

src/relay/transforms/device_planner.cc

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class RewriteOnDevices : public ExprMutator {
334334
Expr tuple = VisitExpr(tuple_get_item_node->tuple);
335335
OnDeviceProps props = GetOnDeviceProps(tuple);
336336

337-
Expr tuple_get_item = WithFields(GetRef<TupleGetItem>(tuple_get_item_node), std::move(tuple));
337+
Expr tuple_get_item = WithFields(GetRef<TupleGetItem>(tuple_get_item_node), tuple);
338338
if (props.body.defined() && props.is_normal()) {
339339
VLOG(2) << "wrapping tuple get item:" << std::endl
340340
<< PrettyPrint(GetRef<TupleGetItem>(tuple_get_item_node)) << std::endl
@@ -363,8 +363,8 @@ class RewriteOnDevices : public ExprMutator {
363363
}
364364
expr = VisitExpr(expr);
365365
for (auto itr = bindings.rbegin(); itr != bindings.rend(); ++itr) {
366-
expr = WithFields(/*let=*/std::move(std::get<0>(*itr)), /*opt_var=*/{},
367-
/*opt_value=*/std::move(std::get<1>(*itr)), /*opt_body=*/std::move(expr));
366+
expr = WithFields(/*let=*/std::get<0>(*itr), /*opt_var=*/{},
367+
/*opt_value=*/std::get<1>(*itr), /*opt_body=*/expr);
368368
}
369369
return expr;
370370
}
@@ -378,7 +378,7 @@ class RewriteOnDevices : public ExprMutator {
378378
<< "to be fixed to VirtualDevice " << props.virtual_device;
379379
body = MaybeOnDeviceFixed(props.body, props.virtual_device);
380380
}
381-
return WithFields(GetRef<Function>(function_node), function_node->params, std::move(body));
381+
return WithFields(GetRef<Function>(function_node), function_node->params, body);
382382
}
383383

384384
Expr VisitExpr_(const CallNode* call_node) final {
@@ -990,7 +990,7 @@ class DeviceCapturer : public ExprMutator {
990990
for (const auto& field : tuple_node->fields) {
991991
fields.push_back(VisitChild(tuple, field));
992992
}
993-
return WithFields(std::move(tuple), std::move(fields));
993+
return WithFields(tuple, fields);
994994
}
995995

996996
Expr VisitExpr_(const FunctionNode* function_node) final {
@@ -1025,8 +1025,7 @@ class DeviceCapturer : public ExprMutator {
10251025
/*expected_virtual_device=*/result_virtual_device,
10261026
/*child_virtual_device=*/GetVirtualDevice(function_node->body), function_node->body);
10271027

1028-
Function func = WithFields(GetRef<Function>(function_node), std::move(function_node->params),
1029-
std::move(body));
1028+
Function func = WithFields(GetRef<Function>(function_node), function_node->params, body);
10301029
return FunctionOnDevice(func, std::move(param_virtual_devices),
10311030
std::move(result_virtual_device));
10321031
}
@@ -1102,9 +1101,9 @@ class DeviceCapturer : public ExprMutator {
11021101
if (call_node->op == CallLoweredOp()) {
11031102
Call new_call =
11041103
CallLowered(Downcast<GlobalVar>(op), args, /*call_lowered_attrs=*/{}, /*span=*/{});
1105-
return WithFields(call, std::move(new_call->op), std::move(new_call->args));
1104+
return WithFields(call, new_call->op, new_call->args);
11061105
} else {
1107-
return WithFields(call, std::move(op), std::move(args));
1106+
return WithFields(call, op, args);
11081107
}
11091108
}
11101109

@@ -1145,33 +1144,32 @@ class DeviceCapturer : public ExprMutator {
11451144
Expr cond = VisitChild(ife, if_node->cond);
11461145
Expr true_branch = VisitChild(ife, if_node->true_branch);
11471146
Expr false_branch = VisitChild(ife, if_node->false_branch);
1148-
return WithFields(std::move(ife), std::move(cond), std::move(true_branch),
1149-
std::move(false_branch));
1147+
return WithFields(ife, cond, true_branch, false_branch);
11501148
}
11511149

11521150
Expr VisitExpr_(const TupleGetItemNode* tuple_get_item_node) final {
11531151
auto tuple_get_item = GetRef<TupleGetItem>(tuple_get_item_node);
11541152
Expr tuple = VisitChild(tuple_get_item, tuple_get_item_node->tuple);
1155-
return WithFields(std::move(tuple_get_item), std::move(tuple));
1153+
return WithFields(tuple_get_item, tuple);
11561154
}
11571155

11581156
Expr VisitExpr_(const RefCreateNode* ref_create_node) final {
11591157
auto ref_create = GetRef<RefCreate>(ref_create_node);
11601158
Expr value = VisitChild(ref_create, ref_create_node->value);
1161-
return WithFields(std::move(ref_create), std::move(value));
1159+
return WithFields(ref_create, value);
11621160
}
11631161

11641162
Expr VisitExpr_(const RefReadNode* ref_read_node) final {
11651163
auto ref_read = GetRef<RefRead>(ref_read_node);
11661164
Expr ref = VisitChild(ref_read, ref_read_node->ref);
1167-
return WithFields(std::move(ref_read), std::move(ref));
1165+
return WithFields(ref_read, ref);
11681166
}
11691167

11701168
Expr VisitExpr_(const RefWriteNode* ref_write_node) final {
11711169
auto ref_write = GetRef<RefWrite>(ref_write_node);
11721170
Expr ref = VisitChild(ref_write, ref_write_node->ref);
11731171
Expr value = VisitChild(ref_write, ref_write_node->value);
1174-
return WithFields(std::move(ref_write), std::move(ref), std::move(value));
1172+
return WithFields(ref_write, ref, value);
11751173
}
11761174

11771175
Expr VisitExpr_(const MatchNode* match_node) final {
@@ -1184,7 +1182,7 @@ class DeviceCapturer : public ExprMutator {
11841182
Expr rhs = VisitChild(match, clause->rhs);
11851183
clauses.push_back(Clause(lhs, rhs));
11861184
}
1187-
return WithFields(std::move(match), std::move(data), std::move(clauses));
1185+
return WithFields(match, data, clauses);
11881186
}
11891187

11901188
VirtualDevice GetVirtualDevice(const Expr& expr) {

src/relay/transforms/first_order_gradient.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ struct FirstOrderReverseAD : ExprFunctor<ADValue(const Expr&)> {
211211
field_bindings.push_back(f_ad->get<ADTensor>().forward);
212212
}
213213
// reconstruct tuple using let-bound variables to avoid duplication
214-
auto orig = WithFields(GetRef<Tuple>(tuple_node), std::move(field_bindings));
214+
auto orig = WithFields(GetRef<Tuple>(tuple_node), field_bindings);
215215
orig->checked_type_ = tt;
216216
auto ret = std::make_shared<ADTensor>(ll, orig, diag_ctx);
217217
// for orig = tuple(x1, ..., xn), tuple_grad(x1, ..., xn, G) = [pi(G, 1), ..., pi(G, n)]

src/relay/transforms/forward_rewrite.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class ForwardRewriter : private MixedModeMutator {
122122
fields.push_back(this->GetTempExpr(tuple_node->fields[i], post_tuple_node->fields[i]));
123123
}
124124

125-
return WithFields(GetRef<Tuple>(tuple_node), std::move(fields));
125+
return WithFields(GetRef<Tuple>(tuple_node), fields);
126126
}
127127

128128
Expr Rewrite_(const CallNode* call_node, const Expr& post) final {

src/relay/transforms/fuse_ops.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ class FuseMutator : private MixedModeMutator {
905905
}
906906
// This tuple is an intermediate node in the group
907907
Array<Expr> new_fields = GetNewArguments(tuple_node->fields, ret_group);
908-
return WithFields(GetRef<Tuple>(tuple_node), std::move(new_fields));
908+
return WithFields(GetRef<Tuple>(tuple_node), new_fields);
909909
}
910910

911911
Expr Rewrite_(const TupleGetItemNode* tuple_get, const Expr& post) {

src/relay/transforms/memory_alloc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class DialectRewriter : public transform::DeviceAwareExprMutator {
9292
}
9393
new_fields.push_back(new_field);
9494
}
95-
return WithFields(GetRef<Tuple>(tuple_node), std::move(new_fields));
95+
return WithFields(GetRef<Tuple>(tuple_node), new_fields);
9696
}
9797

9898
void PreVisitLetBlock_(const LetNode* let_node) final { scopes_.emplace_back(); }

src/relay/transforms/partition_graph.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ IRModule FlattenTupleOutputs(IRModule module) {
470470

471471
// Return a tuple of compiler_ends in the place of the tuple that was
472472
// annotated with a compiler_end.
473-
return WithFields(GetRef<Tuple>(tuple_node), std::move(new_fields));
473+
return WithFields(GetRef<Tuple>(tuple_node), new_fields);
474474
}
475475
}
476476
return post;

src/relay/transforms/split_args.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ class ArgumentSplitter : public ExprRewriter {
5959
for (int j = 0; j < argsCount; ++j) {
6060
args.push_back(tuple_node->fields[j + startIdx]);
6161
}
62-
Tuple new_tuple = WithFields(GetRef<Tuple>(tuple_node), std::move(args));
62+
Tuple new_tuple = WithFields(GetRef<Tuple>(tuple_node), args);
6363
Expr body = MakeConcatenate(new_tuple, param->axis);
6464
splitted[i] = StopFusion(body);
6565
}
6666
tvm::Array<Expr> tuple_args(splitted);
67-
Tuple new_tuple = WithFields(GetRef<Tuple>(tuple_node), std::move(tuple_args));
67+
Tuple new_tuple = WithFields(GetRef<Tuple>(tuple_node), tuple_args);
6868
return MakeConcatenate(new_tuple, param->axis);
6969
}
7070
return post;

src/relay/transforms/to_a_normal_form.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class Fill : ExprFunctor<Expr(const Expr&, const Var&)>, private transform::Lexi
255255
for (const auto& a : tuple_node->fields) {
256256
fields.push_back(VisitExpr(a));
257257
}
258-
return Compound(e, WithFields(GetRef<Tuple>(tuple_node), std::move(fields)), v);
258+
return Compound(e, WithFields(GetRef<Tuple>(tuple_node), fields), v);
259259
}
260260

261261
Expr VisitExpr_(const TupleGetItemNode* t, const Var& v) final {

0 commit comments

Comments
 (0)