xref: /aosp_15_r20/external/tensorflow/tensorflow/compiler/mlir/lite/experimental/tac/transforms/passes.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
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_LITE_EXPERIMENTAL_TAC_TRANSFORMS_PASSES_H_
17 #define TENSORFLOW_COMPILER_MLIR_LITE_EXPERIMENTAL_TAC_TRANSFORMS_PASSES_H_
18 
19 #include <memory>
20 #include <string>
21 
22 #include "mlir/Dialect/Func/IR/FuncOps.h"  // from @llvm-project
23 #include "mlir/IR/BuiltinOps.h"  // from @llvm-project
24 #include "mlir/Pass/Pass.h"  // from @llvm-project
25 
26 namespace mlir {
27 namespace TFL {
28 namespace tac {
29 class TacModule;
30 
31 // Create an instance of the TargetAnnotationPass.
32 // TODO(b/177376459): Remove in favor of the one below.
33 std::unique_ptr<OperationPass<func::FuncOp>> CreateTargetAnnotationPass(
34     llvm::ArrayRef<std::string> device_specs);
35 
36 // Create and instance of TargetAnnotationPass.
37 std::unique_ptr<OperationPass<func::FuncOp>> CreateTargetAnnotationPass(
38     const TacModule* module);
39 
40 // Create an instance of the RaiseTargetSubgraphsPass.
41 std::unique_ptr<OperationPass<ModuleOp>> CreateRaiseTargetSubgraphsPass();
42 
43 // Create an instance of the AlternativeSubgraphPass.
44 std::unique_ptr<OperationPass<ModuleOp>> CreateAlternativeSubgraphPass(
45     llvm::ArrayRef<std::string> device_specs);
46 
47 // Create an instance of ComputeCostPass.
48 std::unique_ptr<OperationPass<ModuleOp>> CreateComputeCostPass();
49 
50 // Create an instance of PickSubgraphsPass.
51 std::unique_ptr<OperationPass<ModuleOp>> CreatePickSubgraphsPass();
52 
53 // Create an instance of DeviceTransformGPUPass.
54 std::unique_ptr<OperationPass<func::FuncOp>> CreateDeviceTransformGPUPass();
55 
56 // Create an instance of GetOpCostPass.
57 std::unique_ptr<OperationPass<func::FuncOp>> CreateGetOpCostPass();
58 
59 // Create an instance of FoldConstantsToSubgraphPass.
60 std::unique_ptr<OperationPass<ModuleOp>> CreateFoldConstantsToSubgraphPass(
61     bool fold_all_constants);
62 
63 }  // namespace tac
64 }  // namespace TFL
65 }  // namespace mlir
66 
67 #endif  // TENSORFLOW_COMPILER_MLIR_LITE_EXPERIMENTAL_TAC_TRANSFORMS_PASSES_H_
68