diff --git a/mlir/include/mlir/Interfaces/LoopLikeInterface.td b/mlir/include/mlir/Interfaces/LoopLikeInterface.td index cc79d026c8d4ed..bace8f8384d449 100644 --- a/mlir/include/mlir/Interfaces/LoopLikeInterface.td +++ b/mlir/include/mlir/Interfaces/LoopLikeInterface.td @@ -95,7 +95,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> { InterfaceMethod<[{ Return all induction variables. }], - /*retTy=*/"::mlir::ValueRange", + /*retTy=*/"::llvm::SmallVector<::mlir::Value>", /*methodName=*/"getInductionVars", /*args=*/(ins), /*methodBody=*/"", diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp index d3f034a0660bab..5467c602426641 100644 --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -2454,7 +2454,9 @@ bool AffineForOp::matchingBoundOperandList() { SmallVector AffineForOp::getLoopRegions() { return {&getRegion()}; } -ValueRange AffineForOp::getInductionVars() { return {getInductionVar()}; } +SmallVector AffineForOp::getInductionVars() { + return {getInductionVar()}; +} std::optional> AffineForOp::getLowerBounds() { if (!hasConstantLowerBound()) diff --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp index b0a4de2da1e869..8b0e04fb61b1bd 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp @@ -184,8 +184,7 @@ static void replaceIndexOpsByInductionVariables(RewriterBase &rewriter, for (Operation *loopOp : loopOps) { llvm::TypeSwitch(loopOp) .Case([&](scf::ParallelOp parallelOp) { - allIvs.append(parallelOp.getInductionVars().begin(), - parallelOp.getInductionVars().end()); + allIvs.append(parallelOp.getInductionVars()); }) .Case([&](scf::ForOp forOp) { allIvs.push_back(forOp.getInductionVar()); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index fd314ef9f81347..4eacaa8d1e327c 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -243,7 +243,7 @@ static void calculateTileOffsetsAndSizes( OpBuilder::InsertionGuard g(b); b.setInsertionPointToStart(forallOp.getBody(0)); - ValueRange threadIds = forallOp.getInductionVars(); + auto threadIds = forallOp.getInductionVars(); SmallVector nonZeroNumThreads = llvm::to_vector(llvm::make_filter_range(numThreads, [](OpFoldResult ofr) { return !isConstantIntValue(ofr, 0); @@ -746,7 +746,7 @@ FailureOr linalg::tileReductionUsingForall( b.getIndexAttr(0)); SmallVector sizes = tiledSizes; sizes[reductionDim] = b.getIndexAttr(1); - outOffsets[reductionDim] = forallOp.getInductionVars().front(); + outOffsets[reductionDim] = forallOp.getInductionVars()[0]; // TODO: use SubsetExtractOpInterface once it is available. tiledDpsInitOperands.push_back(b.create( loc, cast(initOperand.getType()), @@ -814,7 +814,7 @@ FailureOr linalg::tileReductionUsingForall( int64_t sizeIdx = 0; for (int64_t i = 0, e = numThreads.size(); i < e; ++i) { if (i == reductionDim) { - resultOffsetsRank.push_back(forallOp.getInductionVars().front()); + resultOffsetsRank.push_back(forallOp.getInductionVars()[0]); resultSizesRank.push_back(b.getIndexAttr(1)); continue; } diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp index 281d73afee4a8e..0ce10ebdad3e25 100644 --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -378,7 +378,7 @@ LogicalResult ForOp::verifyRegions() { return success(); } -ValueRange ForOp::getInductionVars() { return {getInductionVar()}; } +SmallVector ForOp::getInductionVars() { return {getInductionVar()}; } std::optional> ForOp::getLowerBounds() { return SmallVector{OpFoldResult(getLowerBound())}; @@ -1426,8 +1426,8 @@ SmallVector ForallOp::getCombiningOps(BlockArgument bbArg) { return storeOps; } -ValueRange ForallOp::getInductionVars() { - return getBody()->getArguments().take_front(getRank()); +SmallVector ForallOp::getInductionVars() { + return SmallVector(getBody()->getArguments().take_front(getRank())); } // Get lower bounds as OpFoldResult. @@ -3004,7 +3004,9 @@ void ParallelOp::print(OpAsmPrinter &p) { SmallVector ParallelOp::getLoopRegions() { return {&getRegion()}; } -ValueRange ParallelOp::getInductionVars() { return getBody()->getArguments(); } +SmallVector ParallelOp::getInductionVars() { + return SmallVector(getBody()->getArguments()); +} std::optional> ParallelOp::getLowerBounds() { return getLowerBound();