1 /* Copyright 2020 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_TPU_TPU_EXECUTE_H_ 17 #define TENSORFLOW_CORE_TPU_TPU_EXECUTE_H_ 18 19 #include <string> 20 #include <vector> 21 22 #include "tensorflow/compiler/xla/service/computation_placer.h" 23 #include "tensorflow/compiler/xla/service/executable.h" 24 #include "tensorflow/compiler/xla/service/hlo.pb.h" 25 #include "tensorflow/compiler/xla/statusor.h" 26 #include "tensorflow/core/framework/cancellation.h" 27 #include "tensorflow/core/framework/op_kernel.h" 28 #include "tensorflow/core/tpu/kernels/tpu_executable_info.pb.h" 29 #include "tensorflow/core/tpu/tpu_ops_c_api.h" 30 #include "tensorflow/stream_executor/stream.h" 31 #include "tensorflow/stream_executor/tpu/tpu_node_context.h" 32 33 namespace tensorflow { 34 35 // Runs a TPU executable. `input_allocations` and `output_allocations` are 36 // non-owning pointers to the root buffers of each argument/result tuple. 37 // `output_shape` is the output shape of the XLA computation from which 38 // `program` was derived. If `session_module` is not nullptr, it will be filled 39 // with the input and output literals of the execution. 40 xla::StatusOr<xla::ExecutionOutput> TPUExecute( 41 const TPUExecutableInfoProto& executable, 42 const TPUHostTransferInfoProto& host_transfers, 43 const xla::HloProto& hlo_metadata, 44 std::vector<xla::ExecutionInput> arguments, 45 const std::string& rendezvous_key_base, uint32 rng_seed, 46 tpu::TpuNodeContext* node_context, xla::DeviceAssignment* device_assignment, 47 CancellationManager* cancellation_manager, OpKernelContext* ctx, 48 stream_executor::Stream* stream, 49 stream_executor::Stream* host_to_device_stream, 50 const XLA_TpuProgram* tpu_program); 51 52 } // namespace tensorflow 53 54 #endif // TENSORFLOW_CORE_TPU_TPU_EXECUTE_H_ 55