• 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_TOOLS_KERNEL_GEN_TRANSFORMS_REWRITERS_H_
17 #define TENSORFLOW_COMPILER_MLIR_TOOLS_KERNEL_GEN_TRANSFORMS_REWRITERS_H_
18 
19 #include "mlir/IR/MLIRContext.h"  // from @llvm-project
20 
21 namespace mlir {
22 
23 class BufferizeTypeConverter;
24 class LLVMTypeConverter;
25 class MLIRContext;
26 class RewritePatternSet;
27 class TypeConverter;
28 
29 namespace kernel_gen {
30 namespace tf_framework {
31 
32 /// Collects a set of patterns to convert from the TF Framework dialect to LLVM.
33 void PopulateTFFrameworkToLLVMConversionPatterns(LLVMTypeConverter *converter,
34                                                  RewritePatternSet *patterns);
35 
36 /// Collects a set of patterns to rewrite functions for use with TF framework
37 /// and also replace `alloc`, `dealloc` and `assert`.
38 void PopulateEmbedTFFrameworkPatterns(RewritePatternSet *patterns);
39 void PopulateEmbedTFFrameworkAssertPattern(RewritePatternSet *patterns);
40 
41 }  // namespace tf_framework
42 
43 namespace transforms {
44 
45 /// Collects a set of patterns that bufferize operations from the standard and
46 /// other dialects.
47 void populateExtraBufferizePatterns(MLIRContext *context,
48                                     BufferizeTypeConverter *converter,
49                                     RewritePatternSet *patterns);
50 
51 /// Populate patterns to rewrite TF operations to TF framework JIT invocations.
52 void PopulateTFToJITInvocationPatterns(MLIRContext *ctx,
53                                        RewritePatternSet *patterns,
54                                        llvm::ArrayRef<StringRef> architectures,
55                                        llvm::ArrayRef<int64_t> tile_sizes,
56                                        llvm::ArrayRef<int64_t> unroll_factors,
57                                        int64_t max_supported_rank,
58                                        bool enable_ftz, bool cpu_codegen);
59 
60 }  // namespace transforms
61 }  // namespace kernel_gen
62 }  // namespace mlir
63 
64 #endif  // TENSORFLOW_COMPILER_MLIR_TOOLS_KERNEL_GEN_TRANSFORMS_REWRITERS_H_
65