• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef TENSORFLOW_COMPILER_MLIR_TFRT_TRANSFORMS_TPU_PASSES_H_
17 #define TENSORFLOW_COMPILER_MLIR_TFRT_TRANSFORMS_TPU_PASSES_H_
18 
19 // This file contains stub implementations for Google internal TPU APIs.
20 
21 #include "mlir/IR/BuiltinOps.h"
22 #include "mlir/IR/MLIRContext.h"
23 #include "mlir/Pass/Pass.h"
24 #include "mlir/Support/LogicalResult.h"
25 #include "mlir/Transforms/DialectConversion.h"
26 
27 namespace tensorflow {
28 
29 class CoreRTConverter;
30 
31 struct TfrtTpuExecuteOpConversionOptions {
32   bool use_core_selector;
33   bool use_bundled_transfer;
34   bool transfer_result_to_host;
35 };
36 
37 // Registers a set of dialects used in TFRT TPU lowering.
RegisterTPUDialects(mlir::DialectRegistry * registry)38 inline void RegisterTPUDialects(mlir::DialectRegistry *registry) {}
39 
40 // Adds a target dialect and a set of rewrite patterns for TFRT TPU lowering.
AddTPUTargetDialectAndPatterns(mlir::ConversionTarget * target,mlir::OwningRewritePatternList * patterns,mlir::MLIRContext * context,CoreRTConverter * corert_converter,const TfrtTpuExecuteOpConversionOptions & tpu_exec_conv_opts,bool tpu_lower_to_fallback)41 inline void AddTPUTargetDialectAndPatterns(
42     mlir::ConversionTarget *target, mlir::OwningRewritePatternList *patterns,
43     mlir::MLIRContext *context, CoreRTConverter *corert_converter,
44     const TfrtTpuExecuteOpConversionOptions &tpu_exec_conv_opts,
45     bool tpu_lower_to_fallback) {}
46 
47 // Rewrites specific TF TPU ops to equivalent TF ops in a module.
RunTPUBackwardCompatConversion(mlir::ModuleOp module)48 inline mlir::LogicalResult RunTPUBackwardCompatConversion(
49     mlir::ModuleOp module) {
50   return mlir::failure();
51 }
52 
53 }  // namespace tensorflow
54 
55 #endif  // TENSORFLOW_COMPILER_MLIR_TFRT_TRANSFORMS_TPU_PASSES_H_
56