1 /* Copyright 2019 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_LITE_TF_TFL_PASSES_H_ 17 #define TENSORFLOW_COMPILER_MLIR_LITE_TF_TFL_PASSES_H_ 18 19 #include "llvm/ADT/Optional.h" 20 #include "mlir/IR/BuiltinOps.h" // from @llvm-project 21 #include "mlir/Pass/PassManager.h" // from @llvm-project 22 #include "tensorflow/compiler/mlir/lite/common/tfl_pass_config.h" 23 #include "tensorflow/core/public/session.h" 24 #include "tensorflow/lite/toco/model_flags.pb.h" 25 #include "tensorflow/lite/toco/toco_flags.pb.h" 26 27 namespace tensorflow { 28 29 // Add the TF to TFLite passes, specified in the pass_config, into a 30 // pass_manager. The session object will be provided when the TF MLIR is 31 // imported from saved model version one and utilized for capturing resource 32 // variables. 33 void AddTFToTFLConversionPasses(const toco::ModelFlags& model_flags, 34 const toco::TocoFlags& toco_flags, 35 const mlir::TFL::PassConfig& pass_config, 36 mlir::OpPassManager* pass_manager, 37 llvm::Optional<tensorflow::Session*> session); 38 39 void AddTFToTFLConversionPasses(const mlir::TFL::PassConfig& pass_config, 40 mlir::OpPassManager* pass_manager, 41 llvm::Optional<tensorflow::Session*> session); 42 43 // Add the Quantization passes, specified in the quant_specs, into a pass 44 // manager. 45 void AddQuantizationPasses(const mlir::TFL::QuantizationSpecs& quant_specs, 46 mlir::OpPassManager* pass_manager); 47 48 } // namespace tensorflow 49 50 #endif // TENSORFLOW_COMPILER_MLIR_LITE_TF_TFL_PASSES_H_ 51