xref: /aosp_15_r20/external/tensorflow/tensorflow/compiler/mlir/tensorflow/transforms/bridge_pass.cc (revision b6fb3261f9314811a0f4371741dbb8839866f948)
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 #include "mlir/Pass/Pass.h"  // from @llvm-project
17 #include "mlir/Pass/PassManager.h"  // from @llvm-project
18 #include "mlir/Transforms/Passes.h"  // from @llvm-project
19 #include "tensorflow/compiler/mlir/tensorflow/transforms/bridge.h"
20 #include "tensorflow/compiler/mlir/tensorflow/transforms/passes.h"
21 #include "tensorflow/compiler/mlir/tensorflow/utils/error_util.h"
22 
23 namespace mlir {
24 namespace TFTPU {
25 extern void AddGraphExportLoweringPasses(OpPassManager &pm);
26 }  // namespace TFTPU
27 }  // namespace mlir
28 
29 namespace {
30 
31 // Registers a pipeline builder function for TF TPU bridge.
32 mlir::PassPipelineRegistration<> tpu_pipeline(
33     "tf-tpu-bridge",
34     "Run all the passes involved in transforming the graph before execution so "
35     "that it is suitable for targeting TPUs.",
36     mlir::TFTPU::CreateTPUBridgePipeline);
37 
38 // Registers a pipeline builder function for TF TPU V1 bridge.
39 mlir::PassPipelineRegistration<> tpu_pipeline_v1(
40     "tf-tpu-bridge-v1",
41     "Run all the passes involved in transforming a TensorFlow V1 graph before "
42     "execution so that it is suitable for targeting TPUs.",
43     mlir::TFTPU::CreateTPUBridgePipelineV1);
44 
45 // Registers a pipeline builder function for TF Graph export.
46 mlir::PassPipelineRegistration<> tpu_export(
47     "tf-graph-export",
48     "Run passes to prepare for exporting module back to TF Graph.",
49     mlir::TF::AddGraphExportLoweringPasses);
50 
51 }  // anonymous namespace
52