Skip to content

Commit

Permalink
Make RPC message constructor actually move (pytorch#33440)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#33440

The constructors make a copy without `std::move` in the initializer list.

Test Plan:
Confirmed manually that without this change, the `data()` pointer of
the vector changes. With this change it does not, as intended.

Reviewed By: mrshenli

Differential Revision: D19948685

fbshipit-source-id: ee4f22e29894b858ad86068722dc2f4651987517
  • Loading branch information
pietern authored and facebook-github-bot committed Feb 19, 2020
1 parent d50305e commit e9ac92a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions torch/csrc/distributed/rpc/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ Message::Message(
std::vector<char>&& payload,
std::vector<torch::Tensor>&& tensors,
MessageType type)
: payload_(payload), tensors_(tensors), type_(type) {}
: payload_(std::move(payload)), tensors_(std::move(tensors)), type_(type) {}

Message::Message(
std::vector<char>&& payload,
std::vector<torch::Tensor>&& tensors,
MessageType type,
int64_t id)
: payload_(payload), tensors_(tensors), type_(type), id_(id) {}
: payload_(std::move(payload)),
tensors_(std::move(tensors)),
type_(type),
id_(id) {}

Message::Message(const Message& other) = default;

Expand Down

0 comments on commit e9ac92a

Please sign in to comment.