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-hlo/Dialect/mhlo/IR/hlo_ops.h" 17 #include "mlir-hlo/Dialect/mhlo/transforms/PassDetail.h" 18 #include "mlir-hlo/Dialect/mhlo/transforms/rewriters.h" 19 #include "mlir/Dialect/MemRef/IR/MemRef.h" 20 #include "mlir/Dialect/StandardOps/IR/Ops.h" 21 #include "mlir/IR/Dialect.h" 22 #include "mlir/IR/MLIRContext.h" 23 #include "mlir/IR/Operation.h" 24 #include "mlir/Pass/Pass.h" 25 #include "mlir/Transforms/DialectConversion.h" 26 #include "mlir/Transforms/GreedyPatternRewriteDriver.h" 27 28 namespace mlir { 29 namespace mhlo { 30 31 namespace { 32 33 struct TestUnfuseBatchNormPass 34 : public TestUnfuseBatchNormPassBase<TestUnfuseBatchNormPass> { getDependentDialectsmlir::mhlo::__anon85b3a2840111::TestUnfuseBatchNormPass35 void getDependentDialects(DialectRegistry& registry) const override { 36 registry.insert<memref::MemRefDialect>(); 37 } runOnOperationmlir::mhlo::__anon85b3a2840111::TestUnfuseBatchNormPass38 void runOnOperation() override { 39 OwningRewritePatternList patterns(&getContext()); 40 PopulateUnfuseBatchNormPatterns(&getContext(), &patterns); 41 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); 42 } 43 }; 44 45 } // namespace 46 createTestUnfuseBatchNormPass()47std::unique_ptr<::mlir::Pass> createTestUnfuseBatchNormPass() { 48 return std::make_unique<TestUnfuseBatchNormPass>(); 49 } 50 51 } // namespace mhlo 52 } // namespace mlir 53