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 <memory> 17 18 #include "mlir/IR/PatternMatch.h" // from @llvm-project 19 #include "mlir/Pass/Pass.h" // from @llvm-project 20 #include "mlir/Transforms/GreedyPatternRewriteDriver.h" // from @llvm-project 21 #include "tensorflow/compiler/mlir/tensorflow/transforms/passes_detail.h" 22 #include "tensorflow/compiler/mlir/tensorflow/transforms/tf_data_optimization.h" 23 24 namespace mlir { 25 namespace TF { 26 namespace { 27 28 // Perform tf.data optimizations. 29 struct TFDataOptimization 30 : public TFDataOptimizationPassBase<TFDataOptimization> { runOnOperationmlir::TF::__anoncdaad7fb0111::TFDataOptimization31 void runOnOperation() override { 32 RewritePatternSet patterns(&getContext()); 33 mlir::TF::PopulateTFDataOptimizationPatterns(&getContext(), &patterns); 34 35 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); 36 } 37 }; 38 39 } // namespace 40 CreateTFDataOptimizationPass()41std::unique_ptr<OperationPass<func::FuncOp>> CreateTFDataOptimizationPass() { 42 return std::make_unique<TFDataOptimization>(); 43 } 44 45 } // namespace TF 46 } // namespace mlir 47