• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_EAGER_GRPC_EAGER_SERVICE_H_
17 #define TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_EAGER_GRPC_EAGER_SERVICE_H_
18 
19 #include "grpcpp/impl/codegen/async_stream.h"
20 #include "grpcpp/impl/codegen/async_unary_call.h"
21 #include "grpcpp/impl/codegen/proto_utils.h"
22 #include "grpcpp/impl/codegen/rpc_method.h"
23 #include "grpcpp/impl/codegen/service_type.h"
24 #include "grpcpp/impl/codegen/status.h"
25 #include "grpcpp/impl/codegen/stub_options.h"
26 #include "grpcpp/impl/codegen/sync_stream.h"
27 
28 #include "tensorflow/core/protobuf/eager_service.pb.h"
29 
30 namespace tensorflow {
31 namespace eager {
32 
33 namespace grpc {
34 
35 // GRPC stubs of `tensorflow.eager.EagerService`, based on the
36 // definition in "//tensorflow/core/protobuf/eager_service.proto",
37 // and the gRPC generated stub and service classes.
38 // See that file for the definition of methods and messages.
39 // Similar to the Master/Worker tensorflow GRPC services, this is not gen'ned
40 // via a rule, but included as an implementation directly.
41 class EagerService final {
42  public:
43   class StubInterface {
44    public:
~StubInterface()45     virtual ~StubInterface() {}
46     virtual ::grpc::Status CreateContext(::grpc::ClientContext* context,
47                                          const CreateContextRequest& request,
48                                          CreateContextResponse* response) = 0;
49     virtual ::grpc::Status Enqueue(::grpc::ClientContext* context,
50                                    const EnqueueRequest& request,
51                                    EnqueueResponse* response) = 0;
52     virtual ::grpc::Status WaitQueueDone(::grpc::ClientContext* context,
53                                          const WaitQueueDoneRequest& request,
54                                          WaitQueueDoneResponse* response) = 0;
55     virtual ::grpc::Status KeepAlive(::grpc::ClientContext* context,
56                                      const KeepAliveRequest& request,
57                                      KeepAliveResponse* response) = 0;
58     virtual ::grpc::Status CloseContext(::grpc::ClientContext* context,
59                                         const CloseContextRequest& request,
60                                         CloseContextResponse* response) = 0;
61     virtual ::grpc::Status RegisterFunction(
62         ::grpc::ClientContext* context, const RegisterFunctionRequest& request,
63         RegisterFunctionResponse* response) = 0;
64     virtual ::grpc::Status SendTensor(::grpc::ClientContext* context,
65                                       const SendTensorRequest& request,
66                                       SendTensorResponse* response) = 0;
67   };
68   class Stub final : public StubInterface {
69    public:
70     Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
71     ::grpc::Status CreateContext(::grpc::ClientContext* context,
72                                  const CreateContextRequest& request,
73                                  CreateContextResponse* response) override;
74     ::grpc::Status Enqueue(::grpc::ClientContext* context,
75                            const EnqueueRequest& request,
76                            EnqueueResponse* response) override;
77     ::grpc::Status WaitQueueDone(::grpc::ClientContext* context,
78                                  const WaitQueueDoneRequest& request,
79                                  WaitQueueDoneResponse* response) override;
80     ::grpc::Status KeepAlive(::grpc::ClientContext* context,
81                              const KeepAliveRequest& request,
82                              KeepAliveResponse* response) override;
83     ::grpc::Status CloseContext(::grpc::ClientContext* context,
84                                 const CloseContextRequest& request,
85                                 CloseContextResponse* response) override;
86     ::grpc::Status RegisterFunction(
87         ::grpc::ClientContext* context, const RegisterFunctionRequest& request,
88         RegisterFunctionResponse* response) override;
89     ::grpc::Status SendTensor(::grpc::ClientContext* context,
90                               const SendTensorRequest& request,
91                               SendTensorResponse* response) override;
92 
93    private:
94     std::shared_ptr< ::grpc::ChannelInterface> channel_;
95     const ::grpc::internal::RpcMethod rpcmethod_CreateContext_;
96     const ::grpc::internal::RpcMethod rpcmethod_Enqueue_;
97     const ::grpc::internal::RpcMethod rpcmethod_WaitQueueDone_;
98     const ::grpc::internal::RpcMethod rpcmethod_KeepAlive_;
99     const ::grpc::internal::RpcMethod rpcmethod_CloseContext_;
100     const ::grpc::internal::RpcMethod rpcmethod_RegisterFunction_;
101     const ::grpc::internal::RpcMethod rpcmethod_SendTensor_;
102   };
103   static std::unique_ptr<Stub> NewStub(
104       const std::shared_ptr< ::grpc::ChannelInterface>& channel,
105       const ::grpc::StubOptions& options = ::grpc::StubOptions());
106 
107   class AsyncService : public ::grpc::Service {
108    public:
109     AsyncService();
110     virtual ~AsyncService();
RequestCreateContext(::grpc::ServerContext * context,CreateContextRequest * request,::grpc::ServerAsyncResponseWriter<CreateContextResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)111     void RequestCreateContext(
112         ::grpc::ServerContext* context, CreateContextRequest* request,
113         ::grpc::ServerAsyncResponseWriter<CreateContextResponse>* response,
114         ::grpc::CompletionQueue* new_call_cq,
115         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
116       ::grpc::Service::RequestAsyncUnary(0, context, request, response,
117                                          new_call_cq, notification_cq, tag);
118     }
RequestEnqueue(::grpc::ServerContext * context,EnqueueRequest * request,::grpc::ServerAsyncResponseWriter<EnqueueResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)119     void RequestEnqueue(
120         ::grpc::ServerContext* context, EnqueueRequest* request,
121         ::grpc::ServerAsyncResponseWriter<EnqueueResponse>* response,
122         ::grpc::CompletionQueue* new_call_cq,
123         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
124       ::grpc::Service::RequestAsyncUnary(1, context, request, response,
125                                          new_call_cq, notification_cq, tag);
126     }
RequestWaitQueueDone(::grpc::ServerContext * context,WaitQueueDoneRequest * request,::grpc::ServerAsyncResponseWriter<WaitQueueDoneResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)127     void RequestWaitQueueDone(
128         ::grpc::ServerContext* context, WaitQueueDoneRequest* request,
129         ::grpc::ServerAsyncResponseWriter<WaitQueueDoneResponse>* response,
130         ::grpc::CompletionQueue* new_call_cq,
131         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
132       ::grpc::Service::RequestAsyncUnary(2, context, request, response,
133                                          new_call_cq, notification_cq, tag);
134     }
RequestKeepAlive(::grpc::ServerContext * context,KeepAliveRequest * request,::grpc::ServerAsyncResponseWriter<KeepAliveResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)135     void RequestKeepAlive(
136         ::grpc::ServerContext* context, KeepAliveRequest* request,
137         ::grpc::ServerAsyncResponseWriter<KeepAliveResponse>* response,
138         ::grpc::CompletionQueue* new_call_cq,
139         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
140       ::grpc::Service::RequestAsyncUnary(3, context, request, response,
141                                          new_call_cq, notification_cq, tag);
142     }
RequestCloseContext(::grpc::ServerContext * context,CloseContextRequest * request,::grpc::ServerAsyncResponseWriter<CloseContextResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)143     void RequestCloseContext(
144         ::grpc::ServerContext* context, CloseContextRequest* request,
145         ::grpc::ServerAsyncResponseWriter<CloseContextResponse>* response,
146         ::grpc::CompletionQueue* new_call_cq,
147         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
148       ::grpc::Service::RequestAsyncUnary(4, context, request, response,
149                                          new_call_cq, notification_cq, tag);
150     }
RequestRegisterFunction(::grpc::ServerContext * context,RegisterFunctionRequest * request,::grpc::ServerAsyncResponseWriter<RegisterFunctionResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)151     void RequestRegisterFunction(
152         ::grpc::ServerContext* context, RegisterFunctionRequest* request,
153         ::grpc::ServerAsyncResponseWriter<RegisterFunctionResponse>* response,
154         ::grpc::CompletionQueue* new_call_cq,
155         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
156       ::grpc::Service::RequestAsyncUnary(5, context, request, response,
157                                          new_call_cq, notification_cq, tag);
158     }
RequestSendTensor(::grpc::ServerContext * context,SendTensorRequest * request,::grpc::ServerAsyncResponseWriter<SendTensorResponse> * response,::grpc::CompletionQueue * new_call_cq,::grpc::ServerCompletionQueue * notification_cq,void * tag)159     void RequestSendTensor(
160         ::grpc::ServerContext* context, SendTensorRequest* request,
161         ::grpc::ServerAsyncResponseWriter<SendTensorResponse>* response,
162         ::grpc::CompletionQueue* new_call_cq,
163         ::grpc::ServerCompletionQueue* notification_cq, void* tag) {
164       ::grpc::Service::RequestAsyncUnary(6, context, request, response,
165                                          new_call_cq, notification_cq, tag);
166     }
167   };
168 };
169 
170 }  // namespace grpc
171 
172 }  // namespace eager
173 }  // namespace tensorflow
174 
175 #endif  // TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_EAGER_GRPC_EAGER_SERVICE_H_
176