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