[PATCH] D72129: [mlir] Add in-dialect lowering of gpu.all_reduce.
Christian Sigg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 7 05:04:41 PST 2020
csigg updated this revision to Diff 236553.
csigg added a comment.
Addressing rriddle's review comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72129/new/
https://reviews.llvm.org/D72129
Files:
mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
Index: mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
===================================================================
--- mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
+++ mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
@@ -157,10 +157,12 @@
/// Returns an accumulator factory using either the op attribute or the body
/// region.
AccumulatorFactory getFactory() {
- if (!reduceOp.body().empty())
- return getFactory(reduceOp.body());
- if (reduceOp.op())
- return getFactory(*reduceOp.op());
+ auto body = reduceOp.body();
+ if (!body.empty())
+ return getFactory(body);
+ auto opAttr = reduceOp.op();
+ if (opAttr)
+ return getFactory(*opAttr);
return AccumulatorFactory();
}
@@ -186,7 +188,7 @@
// Replace all gpu.yield ops with branch out of body.
for (; block != split; block = block->getNextNode()) {
Operation *terminator = block->getTerminator();
- if (!llvm::isa<gpu::YieldOp>(terminator))
+ if (!isa<gpu::YieldOp>(terminator))
continue;
rewriter.setInsertionPointToEnd(block);
rewriter.replaceOpWithNewOp<BranchOp>(
@@ -297,13 +299,13 @@
createIf(
shuffleOp.getResult(1),
[&] {
- return llvm::SmallVector<Value , 1>{
+ return SmallVector<Value , 1>{
accumFactory(value, shuffleOp.getResult(0))};
},
[&] { return llvm::makeArrayRef(value); });
value = rewriter.getInsertionBlock()->getArgument(0);
}
- return llvm::SmallVector<Value , 1>{value};
+ return SmallVector<Value , 1>{value};
},
// Generate a reduction over the entire subgroup. This is a specialization
// of the above reduction with unconditional accumulation.
@@ -315,7 +317,7 @@
offset, subgroupSize, xorAttr);
value = accumFactory(value, shuffleOp.getResult(0));
}
- return llvm::SmallVector<Value , 1>{value};
+ return SmallVector<Value , 1>{value};
});
return rewriter.getInsertionBlock()->getArgument(0);
}
@@ -344,7 +346,7 @@
PatternMatchResult matchAndRewrite(Operation *op,
PatternRewriter &rewriter) const override {
- auto funcOp = llvm::cast<gpu::GPUFuncOp>(op);
+ auto funcOp = cast<gpu::GPUFuncOp>(op);
auto callback = [&](gpu::AllReduceOp reduceOp) {
GpuAllReduceRewriter(funcOp, reduceOp, rewriter).rewrite();
return WalkResult::interrupt();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72129.236553.patch
Type: text/x-patch
Size: 2664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200107/75853477/attachment.bin>
More information about the llvm-commits
mailing list