Skip to content

Commit f2f4030

Browse files
Michael Liufacebook-github-bot
authored andcommitted
Use move to avoid copying (pytorch#17188)
Summary: Pull Request resolved: pytorch#17188 Using flag "-Wreturn-std-move", compiler can identify the cases where a copy operation is performed when a move operation would have been available. Wrapped return statement with std::move to fix. For some reason, these files are not automatically modded. With D14115372 we should be able to turn on the compile flag Reviewed By: soumith Differential Revision: D14115786 fbshipit-source-id: e763b92eecbe4468027fc141d029618d1e9f280b
1 parent 57617ee commit f2f4030

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torch/csrc/autograd/VariableTypeManual.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ Tensor VariableType::detach(const Tensor & self) const {
341341
if (jit::tracer::isTracing()) {
342342
jit::tracer::addOutput(node, result);
343343
}
344-
return result;
344+
return std::move(result);
345345
}
346346

347347
Tensor & VariableType::detach_(Tensor & self) const {

0 commit comments

Comments
 (0)