• 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 // LLVM-based compiler backend.
17 #ifndef TENSORFLOW_COMPILER_XLA_SERVICE_GPU_LLVM_GPU_BACKEND_GPU_BACKEND_LIB_H_
18 #define TENSORFLOW_COMPILER_XLA_SERVICE_GPU_LLVM_GPU_BACKEND_GPU_BACKEND_LIB_H_
19 
20 #include <string>
21 #include <utility>
22 
23 #include "absl/strings/string_view.h"
24 #include "llvm/IR/Module.h"
25 #include "llvm/Target/TargetMachine.h"
26 #include "tensorflow/compiler/xla/service/gpu/gpu_types.h"
27 #include "tensorflow/compiler/xla/service/hlo_module_config.h"
28 #include "tensorflow/compiler/xla/statusor.h"
29 #include "tensorflow/compiler/xla/types.h"
30 
31 namespace xla {
32 namespace gpu {
33 
34 namespace nvptx {
35 // Compiles the argument module and returns it. libdevice_dir_path is the parent
36 // directory of the libdevice bitcode libraries. The contents of the module may
37 // be changed.
38 //
39 // The Compile.* interfaces each create their own llvm::LLVMContext objects for
40 // thread safety, but note that LLVM's multithreaded support is very
41 // preliminary; multithreaded use is not recommended at this time.
42 StatusOr<string> CompileToPtx(
43     llvm::Module* module, GpuVersion gpu_version,
44     const HloModuleConfig& hlo_module_config, const string& libdevice_dir_path,
45     std::function<void(llvm::TargetMachine*)> configure_target = nullptr);
46 }  // namespace nvptx
47 
48 namespace amdgpu {
49 // Compiles the argument module and returns it with LLVM AMDGPU backend.
50 // rocdl_dir_path is the parent directory of ROCm-Device-Libs bitcode libraries.
51 // The contents of the module may be changed.
52 StatusOr<std::vector<uint8>> CompileToHsaco(
53     llvm::Module* module, GpuVersion gpu_version,
54     const HloModuleConfig& hlo_module_config, const string& rocdl_dir_path);
55 }  // namespace amdgpu
56 
57 }  // namespace gpu
58 }  // namespace xla
59 
60 #endif  // TENSORFLOW_COMPILER_XLA_SERVICE_GPU_LLVM_GPU_BACKEND_GPU_BACKEND_LIB_H_
61