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 #include "mlir/Dialect/Func/IR/FuncOps.h"  // from @llvm-project
17 #include "mlir/Dialect/SCF/IR/SCF.h"  // from @llvm-project
18 #include "mlir/Dialect/SCF/Transforms/Transforms.h"  // from @llvm-project
19 #include "tensorflow/compiler/mlir/tools/kernel_gen/transforms/passes.h"
20 
21 namespace mlir {
22 namespace kernel_gen {
23 namespace transforms {
24 namespace {
25 
26 #define GEN_PASS_CLASSES
27 #include "tensorflow/compiler/mlir/tools/kernel_gen/transforms/kernel_gen_passes.h.inc"
28 
29 struct FuseInnerParallelLoopsPass
30     : FuseInnerParallelLoopsPassBase<FuseInnerParallelLoopsPass> {
runOnOperationmlir::kernel_gen::transforms::__anon4153b9cf0111::FuseInnerParallelLoopsPass31   void runOnOperation() override {
32     getOperation().walk([](mlir::scf::ParallelOp op) {
33       mlir::scf::naivelyFuseParallelOps(op.getRegion());
34     });
35   }
36 };
37 
38 }  // namespace
39 
40 std::unique_ptr<mlir::OperationPass<mlir::func::FuncOp>>
CreateFuseInnerParallelLoopsPass()41 CreateFuseInnerParallelLoopsPass() {
42   return std::make_unique<FuseInnerParallelLoopsPass>();
43 }
44 
45 }  // namespace transforms
46 }  // namespace kernel_gen
47 }  // namespace mlir
48