1 /* Copyright 2022 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_IR_IMPORTEXPORT_GRAPHDEF_IMPORT_H_ 17 #define TENSORFLOW_CORE_IR_IMPORTEXPORT_GRAPHDEF_IMPORT_H_ 18 19 #include "mlir/IR/BuiltinOps.h" // from @llvm-project 20 #include "mlir/IR/MLIRContext.h" // from @llvm-project 21 #include "mlir/IR/OwningOpRef.h" // from @llvm-project 22 #include "tensorflow/core/framework/function.h" 23 #include "tensorflow/core/framework/graph.pb.h" 24 #include "tensorflow/core/graph/graph.h" 25 #include "tensorflow/core/platform/statusor.h" 26 #include "tensorflow/core/protobuf/graph_debug_info.pb.h" 27 28 namespace mlir { 29 namespace tfg { 30 31 // Convert a GraphDef directly to TFG. 32 tensorflow::StatusOr<OwningOpRef<ModuleOp>> ImportGraphDef( 33 MLIRContext *context, const tensorflow::GraphDebugInfo &debug_info, 34 const tensorflow::GraphDef &graph_def); 35 36 // Converts a graph and function library to a TFG module. 37 tensorflow::StatusOr<OwningOpRef<ModuleOp>> ImportGraphAndFunctionsToMlir( 38 MLIRContext *context, const tensorflow::GraphDebugInfo &debug_info, 39 const tensorflow::Graph &graph, 40 const tensorflow::FunctionLibraryDefinition &flib_def); 41 42 } // namespace tfg 43 } // namespace mlir 44 45 #endif // TENSORFLOW_CORE_IR_IMPORTEXPORT_GRAPHDEF_IMPORT_H_ 46