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 #ifndef TENSORFLOW_COMPILER_MLIR_LITE_EXPERIMENTAL_TAC_TAC_IMPORTER_EXPORTER_H_ 16 #define TENSORFLOW_COMPILER_MLIR_LITE_EXPERIMENTAL_TAC_TAC_IMPORTER_EXPORTER_H_ 17 18 #include "absl/status/statusor.h" 19 #include "mlir/Dialect/Func/IR/FuncOps.h" // from @llvm-project 20 #include "mlir/IR/BuiltinOps.h" // from @llvm-project 21 22 namespace mlir { 23 namespace TFL { 24 namespace tac { 25 26 // Interface for Importing program to TAC (Target Aware Conversion) Module. 27 // This class is an interface for importing program in TAC. 28 // See TacModule in how to register it with the module and use it. 29 class TacImporter { 30 public: ~TacImporter()31 virtual ~TacImporter() {} 32 33 // Imports and returns the Module for the imported program. 34 virtual absl::StatusOr<mlir::OwningOpRef<mlir::ModuleOp>> Import() = 0; 35 }; 36 37 // Interface for exporting a module. 38 // Users should implement the interface for exporting the result from TAC 39 // in their preferred way. 40 // See TacModule in how to register it with the module and use it. 41 class TacExporter { 42 public: ~TacExporter()43 virtual ~TacExporter() {} 44 45 // Imports and returns the Module for the imported program. 46 virtual absl::Status Export(mlir::ModuleOp module) = 0; 47 }; 48 } // namespace tac 49 } // namespace TFL 50 } // namespace mlir 51 52 #endif // TENSORFLOW_COMPILER_MLIR_LITE_EXPERIMENTAL_TAC_TAC_IMPORTER_EXPORTER_H_ 53