Skip to content

Commit c2d03e4

Browse files
committed
[MLIR] Change return type of ParallelOp::getInductionVars to ValueRange.
The current return type sometimes leads to code like to_vector<2>(ValueRange(loop.getInductionIvs())). It would be nice to shorten it. Users who need access to Block::BlockArgListType (if there are any), can always call getBody()->getArguments(); if needed. Also remove getNumInductionVars(), since there is getNumLoops(). Differential Revision: https://reviews.llvm.org/D77526
1 parent 6000478 commit c2d03e4

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

mlir/include/mlir/Dialect/LoopOps/LoopOps.td

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,7 @@ def ParallelOp : Loop_Op<"parallel",
312312

313313
let extraClassDeclaration = [{
314314
Block *getBody() { return &region().front(); }
315-
unsigned getNumInductionVars() {
316-
return getBody()->getNumArguments();
317-
}
318-
Block::BlockArgListType getInductionVars() {
315+
ValueRange getInductionVars() {
319316
return getBody()->getArguments();
320317
}
321318
unsigned getNumLoops() { return step().size(); }

mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ static void mapParallelOp(ParallelOp parallelOp,
130130
MLIRContext *ctx = parallelOp.getContext();
131131
Builder b(ctx);
132132
SmallVector<ParallelLoopDimMapping, 4> attrs;
133-
attrs.reserve(parallelOp.getNumInductionVars());
134-
for (int i = 0, e = parallelOp.getNumInductionVars(); i < e; ++i) {
133+
attrs.reserve(parallelOp.getNumLoops());
134+
for (int i = 0, e = parallelOp.getNumLoops(); i < e; ++i) {
135135
attrs.push_back(getParallelLoopDimMappingAttr(
136136
getHardwareIdForMapping(mappingLevel, i), b.getDimIdentityMap(),
137137
b.getDimIdentityMap()));

0 commit comments

Comments
 (0)