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_GPU_AMDGPU_COMPILER_H_ 17 #define TENSORFLOW_COMPILER_XLA_SERVICE_GPU_AMDGPU_COMPILER_H_ 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 #include "tensorflow/compiler/xla/service/gpu/gpu_compiler.h" 24 #include "tensorflow/compiler/xla/service/hlo_module.h" 25 #include "tensorflow/compiler/xla/statusor.h" 26 27 namespace xla { 28 namespace gpu { 29 30 // AMDGPUCompiler generates efficient GPU executables for AMDGPU target. 31 class AMDGPUCompiler : public GpuCompiler { 32 public: 33 AMDGPUCompiler(); ~AMDGPUCompiler()34 ~AMDGPUCompiler() override {} 35 36 Status OptimizeHloConvolutionCanonicalization( 37 HloModule* hlo_module, se::StreamExecutor* stream_exec, 38 se::DeviceMemoryAllocator* device_allocator) override; 39 40 Status OptimizeHloPostLayoutAssignment( 41 HloModule* hlo_module, se::StreamExecutor* stream_exec, 42 se::DeviceMemoryAllocator* device_allocator) override; 43 44 GpuVersion GetGpuVersion(se::StreamExecutor* stream_exec) override; 45 46 StatusOr<std::pair<std::string, std::vector<uint8_t>>> CompileTargetBinary( 47 const HloModuleConfig& module_config, llvm::Module* llvm_module, 48 GpuVersion gpu_version, se::StreamExecutor* stream_exec, bool relocatable, 49 const HloModule* debug_module) override; 50 51 private: 52 // The parent directory of ROCm-Device-Libs IR libraries. 53 std::string rocdl_dir_; 54 55 AMDGPUCompiler(const AMDGPUCompiler&) = delete; 56 AMDGPUCompiler& operator=(const AMDGPUCompiler&) = delete; 57 }; 58 59 } // namespace gpu 60 } // namespace xla 61 62 #endif // TENSORFLOW_COMPILER_XLA_SERVICE_GPU_AMDGPU_COMPILER_H_ 63