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 //===- kernel_creator.h -----------------------------------------*- C++ -*-===// 17 // 18 // This file declares the function to compile a TF kernel function to gpu 19 // binary (hsaco for AMD, cubin for NVIDIA) or to a gpu binary with host side. 20 // 21 //===----------------------------------------------------------------------===// 22 #ifndef TENSORFLOW_COMPILER_MLIR_TOOLS_KERNEL_GEN_KERNEL_CREATOR_H_ 23 #define TENSORFLOW_COMPILER_MLIR_TOOLS_KERNEL_GEN_KERNEL_CREATOR_H_ 24 25 #include <utility> 26 27 #include "llvm/ADT/ArrayRef.h" 28 #include "llvm/ADT/StringRef.h" 29 #include "mlir/Dialect/Func/IR/FuncOps.h" // from @llvm-project 30 #include "mlir/IR/BuiltinOps.h" // from @llvm-project 31 #include "mlir/IR/MLIRContext.h" // from @llvm-project 32 #include "tensorflow/core/platform/statusor.h" 33 34 namespace tensorflow { 35 namespace kernel_gen { 36 37 // Parses tf_code to create a module. An MLIRContext is taken in case any 38 // unexpected dialects are needed. 39 StatusOr<mlir::OwningOpRef<mlir::ModuleOp>> SetupContextAndParseModule( 40 mlir::MLIRContext& context, llvm::StringRef tf_code); 41 42 // Converts TF code to LLVM with or without GPU support. 43 StatusOr<mlir::OwningOpRef<mlir::ModuleOp>> GenerateKernelForTfCode( 44 mlir::MLIRContext& context, llvm::StringRef tf_code, 45 llvm::ArrayRef<std::string> architectures, 46 llvm::ArrayRef<int64_t> tile_sizes, llvm::ArrayRef<int64_t> unroll_factors, 47 int64_t max_supported_rank, bool embed_memref_prints, bool print_ptx, 48 bool print_llvmir, bool enable_ftz, bool index_64bit, bool jit_compile, 49 bool jit_i64_indexed_for_large_tensors, bool apply_cl_options); 50 51 } // namespace kernel_gen 52 } // namespace tensorflow 53 54 #endif // TENSORFLOW_COMPILER_MLIR_TOOLS_KERNEL_GEN_KERNEL_CREATOR_H_ 55