Skip to content

Commit 1babe68

Browse files
committed
change return type of getInductionVars to SmallVector<Value>
1 parent a5fa3b3 commit 1babe68

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

mlir/include/mlir/Interfaces/LoopLikeInterface.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
9595
InterfaceMethod<[{
9696
Return all induction variables.
9797
}],
98-
/*retTy=*/"::mlir::ValueRange",
98+
/*retTy=*/"::llvm::SmallVector<::mlir::Value>",
9999
/*methodName=*/"getInductionVars",
100100
/*args=*/(ins),
101101
/*methodBody=*/"",

mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2454,7 +2454,9 @@ bool AffineForOp::matchingBoundOperandList() {
24542454

24552455
SmallVector<Region *> AffineForOp::getLoopRegions() { return {&getRegion()}; }
24562456

2457-
ValueRange AffineForOp::getInductionVars() { return {getInductionVar()}; }
2457+
SmallVector<Value> AffineForOp::getInductionVars() {
2458+
return {getInductionVar()};
2459+
}
24582460

24592461
std::optional<SmallVector<OpFoldResult>> AffineForOp::getLowerBounds() {
24602462
if (!hasConstantLowerBound())

mlir/lib/Dialect/Linalg/Transforms/Loops.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ static void replaceIndexOpsByInductionVariables(RewriterBase &rewriter,
184184
for (Operation *loopOp : loopOps) {
185185
llvm::TypeSwitch<Operation *>(loopOp)
186186
.Case([&](scf::ParallelOp parallelOp) {
187-
allIvs.append(parallelOp.getInductionVars().begin(),
188-
parallelOp.getInductionVars().end());
187+
allIvs.append(parallelOp.getInductionVars());
189188
})
190189
.Case([&](scf::ForOp forOp) {
191190
allIvs.push_back(forOp.getInductionVar());

mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static void calculateTileOffsetsAndSizes(
243243
OpBuilder::InsertionGuard g(b);
244244
b.setInsertionPointToStart(forallOp.getBody(0));
245245

246-
ValueRange threadIds = forallOp.getInductionVars();
246+
auto threadIds = forallOp.getInductionVars();
247247
SmallVector<OpFoldResult> nonZeroNumThreads =
248248
llvm::to_vector(llvm::make_filter_range(numThreads, [](OpFoldResult ofr) {
249249
return !isConstantIntValue(ofr, 0);
@@ -746,7 +746,7 @@ FailureOr<linalg::ForallReductionTilingResult> linalg::tileReductionUsingForall(
746746
b.getIndexAttr(0));
747747
SmallVector<OpFoldResult> sizes = tiledSizes;
748748
sizes[reductionDim] = b.getIndexAttr(1);
749-
outOffsets[reductionDim] = forallOp.getInductionVars().front();
749+
outOffsets[reductionDim] = forallOp.getInductionVars()[0];
750750
// TODO: use SubsetExtractOpInterface once it is available.
751751
tiledDpsInitOperands.push_back(b.create<tensor::ExtractSliceOp>(
752752
loc, cast<RankedTensorType>(initOperand.getType()),
@@ -814,7 +814,7 @@ FailureOr<linalg::ForallReductionTilingResult> linalg::tileReductionUsingForall(
814814
int64_t sizeIdx = 0;
815815
for (int64_t i = 0, e = numThreads.size(); i < e; ++i) {
816816
if (i == reductionDim) {
817-
resultOffsetsRank.push_back(forallOp.getInductionVars().front());
817+
resultOffsetsRank.push_back(forallOp.getInductionVars()[0]);
818818
resultSizesRank.push_back(b.getIndexAttr(1));
819819
continue;
820820
}

mlir/lib/Dialect/SCF/IR/SCF.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ LogicalResult ForOp::verifyRegions() {
378378
return success();
379379
}
380380

381-
ValueRange ForOp::getInductionVars() { return {getInductionVar()}; }
381+
SmallVector<Value> ForOp::getInductionVars() { return {getInductionVar()}; }
382382

383383
std::optional<SmallVector<OpFoldResult>> ForOp::getLowerBounds() {
384384
return SmallVector<OpFoldResult, 1>{OpFoldResult(getLowerBound())};
@@ -1426,8 +1426,8 @@ SmallVector<Operation *> ForallOp::getCombiningOps(BlockArgument bbArg) {
14261426
return storeOps;
14271427
}
14281428

1429-
ValueRange ForallOp::getInductionVars() {
1430-
return getBody()->getArguments().take_front(getRank());
1429+
SmallVector<Value> ForallOp::getInductionVars() {
1430+
return SmallVector<Value>(getBody()->getArguments().take_front(getRank()));
14311431
}
14321432

14331433
// Get lower bounds as OpFoldResult.
@@ -3004,7 +3004,9 @@ void ParallelOp::print(OpAsmPrinter &p) {
30043004

30053005
SmallVector<Region *> ParallelOp::getLoopRegions() { return {&getRegion()}; }
30063006

3007-
ValueRange ParallelOp::getInductionVars() { return getBody()->getArguments(); }
3007+
SmallVector<Value> ParallelOp::getInductionVars() {
3008+
return SmallVector<Value>(getBody()->getArguments());
3009+
}
30083010

30093011
std::optional<SmallVector<OpFoldResult>> ParallelOp::getLowerBounds() {
30103012
return getLowerBound();

0 commit comments

Comments
 (0)