#pragma once #include #include #include #include #include #include namespace torch::distributed::rpc { // RequestCallback implementation with no Python dependencies. class TORCH_API RequestCallbackNoPython : public RequestCallback { public: c10::intrusive_ptr processMessage( Message& request, std::vector streams) const override; protected: virtual std::unique_ptr deserializePythonRpcCommand( std::unique_ptr rpc, const MessageType& messageType) const; virtual c10::intrusive_ptr processScriptCall( RpcCommandBase& rpc, const std::vector& streams) const; virtual c10::intrusive_ptr processPythonCall( RpcCommandBase& rpc, const std::vector& streams) const; c10::intrusive_ptr assignOwnerRRef( const RRefId& rrefId, const RRefId& forkId, const c10::intrusive_ptr& valueFuture) const; virtual c10::intrusive_ptr processScriptRemoteCall( RpcCommandBase& rpc, const std::vector& streams) const; virtual c10::intrusive_ptr processPythonRemoteCall( RpcCommandBase& rpc, const std::vector& streams) const; c10::intrusive_ptr retrieveOwnerRRef(const RRefId& rrefId) const; c10::intrusive_ptr processScriptRRefFetchCall( RpcCommandBase& rpc) const; virtual c10::intrusive_ptr processPythonRRefFetchCall( RpcCommandBase& rpc) const; c10::intrusive_ptr processRRefUserDelete( RpcCommandBase& rpc) const; c10::intrusive_ptr processRRefChildAccept( RpcCommandBase& rpc) const; c10::intrusive_ptr processRRefForkRequest( RpcCommandBase& rpc) const; c10::intrusive_ptr processForwardAutogradReq( RpcCommandBase& rpc, const std::vector& streams) const; c10::intrusive_ptr processBackwardAutogradReq( RpcCommandBase& rpc, const std::vector& streams) const; c10::intrusive_ptr processCleanupAutogradContextReq( RpcCommandBase& rpc) const; c10::intrusive_ptr processRunWithProfilingReq( RpcCommandBase& rpc) const; virtual void handleRRefDelete(c10::intrusive_ptr& rref) const; c10::intrusive_ptr processRpc( RpcCommandBase& rpc, const MessageType& messageType, const std::vector& streams) const; virtual c10::intrusive_ptr processRpcWithErrors( RpcCommandBase& rpc, const MessageType& messageType, const std::vector& streams) const; c10::intrusive_ptr handleError( const std::exception& e, const MessageType messageType, int64_t messageId) const; virtual bool cudaAvailable() const; virtual c10::intrusive_ptr processRRefBackward( RpcCommandBase& rpc) const; // Helpers to run user-defined functions, operators and other computations. c10::intrusive_ptr runJitOperator( const jit::Operator& op, std::vector& stack, const std::vector& streams) const; // Helpers to convert various kinds of objects into already-completed futures. c10::intrusive_ptr asFuture(IValue value, TypePtr type) const; c10::intrusive_ptr asFuture( c10::intrusive_ptr message) const; c10::intrusive_ptr asFuture(std::exception_ptr err) const; }; } // namespace torch::distributed::rpc