1 //===- TestAllReduceLowering.cpp - Test gpu.all_reduce lowering -----------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file contains test passes for lowering the gpu.all_reduce op. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "mlir/Dialect/GPU/Passes.h" 14 #include "mlir/Dialect/MemRef/IR/MemRef.h" 15 #include "mlir/Dialect/StandardOps/IR/Ops.h" 16 #include "mlir/Pass/Pass.h" 17 #include "mlir/Transforms/GreedyPatternRewriteDriver.h" 18 19 using namespace mlir; 20 21 namespace { 22 struct TestGpuRewritePass 23 : public PassWrapper<TestGpuRewritePass, OperationPass<ModuleOp>> { 24 void getDependentDialects(DialectRegistry ®istry) const override { 25 registry.insert<StandardOpsDialect, memref::MemRefDialect>(); 26 } 27 void runOnOperation() override { 28 RewritePatternSet patterns(&getContext()); 29 populateGpuRewritePatterns(patterns); 30 (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); 31 } 32 }; 33 } // namespace 34 35 namespace mlir { 36 void registerTestAllReduceLoweringPass() { 37 PassRegistration<TestGpuRewritePass> pass( 38 "test-gpu-rewrite", 39 "Applies all rewrite patterns within the GPU dialect."); 40 } 41 } // namespace mlir 42