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_TENSORFLOW_TRANSFORMS_TF_GRAPH_OPTIMIZATION_PASS_H_ 17 #define TENSORFLOW_COMPILER_MLIR_TENSORFLOW_TRANSFORMS_TF_GRAPH_OPTIMIZATION_PASS_H_ 18 19 #include "mlir/IR/BuiltinOps.h" // from @llvm-project 20 #include "mlir/Pass/Pass.h" // from @llvm-project 21 #include "tensorflow/core/common_runtime/optimization_registry.h" 22 23 namespace tensorflow { 24 25 // Create a module pass that will execute the given TF GraphOptimization passes 26 // in sequence. 27 // Pass requires that the module ran on is convertible to TF Graph. 28 std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>> 29 CreateTensorFlowGraphOptimizationPass( 30 std::vector<tensorflow::GraphOptimizationPass*> tf_passes); 31 32 // Same as above but pass names instead of the passes provided. The registered 33 // passes are queried, if a TF graph optimization pass is not found in registry 34 // then the pass fails. 35 // Pass requires that the module ran on is convertible to TF Graph. 36 std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>> 37 CreateTensorFlowGraphOptimizationPass( 38 const std::vector<std::string>& pass_names); 39 40 // Register the pass for command line testing. 41 void RegisterGraphOptimizationPasses(); 42 43 } // namespace tensorflow 44 45 #endif // TENSORFLOW_COMPILER_MLIR_TENSORFLOW_TRANSFORMS_TF_GRAPH_OPTIMIZATION_PASS_H_ 46