1 /* Copyright 2021 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_MLIR_TFRT_TRANSLATE_IMPORT_MODEL_H_ 17 #define TENSORFLOW_COMPILER_MLIR_TFRT_TRANSLATE_IMPORT_MODEL_H_ 18 19 #include "mlir/Dialect/Func/IR/FuncOps.h" // from @llvm-project 20 #include "mlir/IR/BuiltinOps.h" // from @llvm-project 21 #include "mlir/Support/LLVM.h" // from @llvm-project 22 #include "tensorflow/compiler/mlir/tfrt/function/function.h" 23 #include "tensorflow/compiler/mlir/tfrt/translate/tfrt_compile_options.h" 24 #include "tensorflow/core/framework/function.h" 25 #include "tensorflow/core/platform/status.h" 26 #include "tfrt/bef/bef_buffer.h" // from @tf_runtime 27 28 namespace tensorflow { 29 30 struct FunctionBody; 31 32 // Converts FunctionDef to TFRT's Binary Executable Format. This is the entry 33 // point of tf.function to TFRT. function_name and device_name are given from 34 // the Python context. The lowered BEF will be stored in an external buffer 35 // pointed by bef_buffer. 36 Status ConvertFunctionToBef( 37 mlir::StringRef function_name, const tensorflow::FunctionBody* fbody, 38 const FunctionLibraryDefinition& flib_def, 39 tfrt::ArrayRef<tfrt::string_view> devices, 40 const tensorflow::TfrtFunctionCompileOptions& options, 41 tfrt::BefBuffer* bef_buffer); 42 43 // Converts an MLIR `module` in TF dialect to TFRT's Binary Executable Format. 44 Status ConvertTfMlirToBef(const TfrtCompileOptions& options, 45 mlir::ModuleOp module, tfrt::BefBuffer* bef_buffer); 46 47 } // namespace tensorflow 48 49 #endif // TENSORFLOW_COMPILER_MLIR_TFRT_TRANSLATE_IMPORT_MODEL_H_ 50