tf_1.8_xla_doc
compile_only_service.h
Go to the documentation of this file.
1 
3 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7  http://www.apache.org/licenses/LICENSE-2.0
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
13 ==============================================================================*/
14 #ifndef TENSORFLOW_COMPILER_XLA_SERVICE_COMPILE_ONLY_SERVICE_H_
15 #define TENSORFLOW_COMPILER_XLA_SERVICE_COMPILE_ONLY_SERVICE_H_
16 #include "tensorflow/compiler/xla/service/backend.h"
19 #include "tensorflow/compiler/xla/statusor.h"
20 #include "tensorflow/compiler/xla/xla_data.pb.h"
21 #include "tensorflow/core/platform/stream_executor_no_cuda.h"
22 namespace xla {
29 class CompileOnlyService : public Service {
30  public:
31  // Factory for creating a CompileOnlyService. The parameter platform is the
32  // platform that the service should target. If platform is null then the
33  // default platform is used.
34  static StatusOr<std::unique_ptr<CompileOnlyService>> NewService(
35  perftools::gputools::Platform* platform);
36  static StatusOr<std::unique_ptr<CompileOnlyService>> NewService(
37  const ServiceOptions& options);
41  ComputationHandle computation;
42  std::vector<const Shape*> argument_layouts;
43  const Shape* result_layout = nullptr;
44  };
45  // Compiles a list of computations for ahead-of-time execution. This is
46  // intended for use in static compilation. See
47  // |CompileOnlyClient::CompileAheadOfTime| for additional details.
48  StatusOr<std::vector<std::unique_ptr<AotCompilationResult>>>
50  const tensorflow::gtl::ArraySlice<AotComputationInstance> computations,
51  const AotCompilationOptions& Options);
52  // Override Service methods that require or imply the existence of an
53  // execute backend. Note that this does not include TransferToClient, as
54  // computing constants produces global data that we may wish to transfer.
55  tensorflow::Status Execute(const ExecuteRequest* arg,
56  ExecuteResponse* result) override {
57  return Unimplemented("CompileOnlyService does not support execution.");
58  }
59  tensorflow::Status ExecuteParallel(const ExecuteParallelRequest* arg,
60  ExecuteParallelResponse* result) override {
61  return Unimplemented("CompileOnlyService does not support execution.");
62  }
63  tensorflow::Status GetDeviceHandles(
64  const GetDeviceHandlesRequest* arg,
65  GetDeviceHandlesResponse* result) override {
66  return Unimplemented("CompileOnlyService does not support devices.");
67  }
68  tensorflow::Status ExecuteAsync(const ExecuteAsyncRequest* arg,
69  ExecuteAsyncResponse* result) override {
70  return Unimplemented("CompileOnlyService does not support execution.");
71  }
72  tensorflow::Status WaitForExecution(
73  const WaitForExecutionRequest* arg,
74  WaitForExecutionResponse* result) override {
75  return Unimplemented("CompileOnlyService does not support execution.");
76  }
77  tensorflow::Status TransferToServer(
78  const TransferToServerRequest* arg,
79  TransferToServerResponse* result) override {
80  return Unimplemented(
81  "CompileOnlyService does not support device data transfers.");
82  }
83  tensorflow::Status TransferToInfeed(
84  const TransferToInfeedRequest* arg,
85  TransferToInfeedResponse* result) override {
86  return Unimplemented(
87  "CompileOnlyService does not support device data transfers.");
88  }
89  tensorflow::Status TransferFromOutfeed(
90  const TransferFromOutfeedRequest* arg,
91  TransferFromOutfeedResponse* result) override {
92  return Unimplemented(
93  "CompileOnlyService does not support device data transfers.");
94  }
95  tensorflow::Status ResetDevice(const ResetDeviceRequest* arg,
96  ResetDeviceResponse* result) override {
97  return Unimplemented("CompileOnlyService does not support devices.");
98  }
99  private:
100  explicit CompileOnlyService(const ServiceOptions& options,
101  Compiler* compiler);
102  CompileOnlyService(const CompileOnlyService&) = delete;
103  void operator=(const CompileOnlyService&) = delete;
104  // The compiler for the target platform. This is included in place of
105  // the Service::execute_backend_'s compiler, since execute_backend_ is a
106  // nullptr in CompileOnlyService.
107  Compiler* compiler_;
108 };
109 } // namespace xla
110 #endif // TENSORFLOW_COMPILER_XLA_SERVICE_COMPILE_ONLY_SERVICE_H_
111 
Definition: service.h:74
Definition: compile_only_service.h:29
A description of a computation to compile using CompileAheadOfTime.
Definition: compile_only_service.h:40
StatusOr< std::vector< std::unique_ptr< AotCompilationResult > > > CompileAheadOfTime(const tensorflow::gtl::ArraySlice< AotComputationInstance > computations, const AotCompilationOptions &Options)
Definition: compile_only_service.cc:71
namespace for xla
Definition: client_library.cc:26