1 | #pragma once |
---|---|
2 | |
3 | #include <torch/csrc/distributed/rpc/message.h> |
4 | #include <torch/csrc/distributed/rpc/types.h> |
5 | |
6 | namespace torch { |
7 | namespace distributed { |
8 | namespace rpc { |
9 | |
10 | // Base class for all RPC request and responses. |
11 | class RpcCommandBase { |
12 | public: |
13 | // Need to override this to serialize the RPC. This should destructively |
14 | // create a message for the RPC (Hence the &&). |
15 | c10::intrusive_ptr<Message> toMessage() && { |
16 | JitRRefPickleGuard jitPickleGuard; |
17 | return std::move(*this).toMessageImpl(); |
18 | } |
19 | virtual c10::intrusive_ptr<Message> toMessageImpl() && = 0; |
20 | virtual ~RpcCommandBase() = 0; |
21 | }; |
22 | |
23 | inline RpcCommandBase::~RpcCommandBase() = default; |
24 | |
25 | } // namespace rpc |
26 | } // namespace distributed |
27 | } // namespace torch |
28 |