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_EAGER_EAGER_CLIENT_H_ 17 #define TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_EAGER_EAGER_CLIENT_H_ 18 19 #include "tensorflow/core/lib/core/status.h" 20 #include "tensorflow/core/platform/env.h" 21 #include "tensorflow/core/protobuf/eager_service.pb.h" 22 23 namespace tensorflow { 24 namespace eager { 25 26 // This is a base class that can be implemented by a variety of 27 // transports (e.g. gRPC which for each of the client methods makes an RPC). 28 class EagerClient { 29 public: ~EagerClient()30 virtual ~EagerClient() {} 31 #define CLIENT_METHOD(method) \ 32 virtual void method##Async(const method##Request* request, \ 33 method##Response* response, \ 34 StatusCallback done) = 0; 35 36 CLIENT_METHOD(CreateContext); 37 CLIENT_METHOD(Enqueue); 38 CLIENT_METHOD(WaitQueueDone); 39 CLIENT_METHOD(KeepAlive); 40 CLIENT_METHOD(CloseContext); 41 CLIENT_METHOD(RegisterFunction); 42 CLIENT_METHOD(SendTensor); 43 44 #undef CLIENT_METHOD 45 }; 46 47 // Simple wrapper class that can be used to retrieve EagerClients. 48 class EagerClientCache { 49 public: ~EagerClientCache()50 virtual ~EagerClientCache() {} 51 virtual EagerClient* GetClient(const string& target) = 0; 52 }; 53 54 } // namespace eager 55 } // namespace tensorflow 56 57 #endif // TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_EAGER_EAGER_CLIENT_H_ 58