• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 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_COMPILER_XLA_SERVICE_INTERFACE_H_
17 #define TENSORFLOW_COMPILER_XLA_SERVICE_INTERFACE_H_
18 
19 #include "tensorflow/compiler/xla/status.h"
20 #include "tensorflow/compiler/xla/xla.pb.h"
21 #include "tensorflow/compiler/xla/xla_data.pb.h"
22 
23 namespace xla {
24 
25 // Defines the interface for an XLA service on the client side. This service
26 // helps abstract around the actual implementation of a service - the service
27 // can be local (running in the same process), or remote - in which case an RPC
28 // stub is used as the implementation.
29 class ServiceInterface {
30  public:
ServiceInterface()31   ServiceInterface() {}
32   virtual ~ServiceInterface() = default;
33 
34   // TODO(b/31824348): Convert to use StatusOr.
35   virtual Status TransferToClient(const TransferToClientRequest* arg,
36                                   TransferToClientResponse* result) = 0;
37 
38   virtual Status TransferToServer(const TransferToServerRequest* arg,
39                                   TransferToServerResponse* result) = 0;
40 
41   virtual Status TransferToInfeed(const TransferToInfeedRequest* arg,
42                                   TransferToInfeedResponse* result) = 0;
43 
44   virtual Status TransferFromOutfeed(const TransferFromOutfeedRequest* arg,
45                                      TransferFromOutfeedResponse* result) = 0;
46 
47   virtual Status ResetDevice(const ResetDeviceRequest* arg,
48                              ResetDeviceResponse* result) = 0;
49 
50   virtual Status Compile(const CompileRequest* arg,
51                          CompileResponse* result) = 0;
52 
53   virtual Status Execute(const ExecuteRequest* arg,
54                          ExecuteResponse* result) = 0;
55 
56   virtual Status ExecuteGraphParallel(const ExecuteGraphParallelRequest* arg,
57                                       ExecuteParallelResponse* result) = 0;
58 
59   virtual Status WaitForExecution(const WaitForExecutionRequest* arg,
60                                   WaitForExecutionResponse* result) = 0;
61 
62   virtual Status DeconstructTuple(const DeconstructTupleRequest* arg,
63                                   DeconstructTupleResponse* result) = 0;
64 
65   virtual Status GetComputationGraphStats(
66       const ComputationGraphStatsRequest* arg,
67       ComputationStatsResponse* result) = 0;
68 
69   virtual Status GetShape(const GetShapeRequest* arg,
70                           GetShapeResponse* result) = 0;
71 
72   virtual Status CreateChannelHandle(const CreateChannelHandleRequest* arg,
73                                      CreateChannelHandleResponse* result) = 0;
74 
75   virtual Status GetDeviceHandles(const GetDeviceHandlesRequest* arg,
76                                   GetDeviceHandlesResponse* result) = 0;
77 
78   virtual Status ComputeConstantGraph(const ComputeConstantGraphRequest* arg,
79                                       ComputeConstantResponse* result) = 0;
80 
81   // Methods used by GlobalData.
82   virtual Status Unregister(const UnregisterRequest* arg,
83                             UnregisterResponse* result) = 0;
84 };
85 
86 }  // namespace xla
87 
88 #endif  // TENSORFLOW_COMPILER_XLA_SERVICE_INTERFACE_H_
89