summaryrefslogtreecommitdiff
path: root/mlir/lib/Conversion/VectorToGPU
diff options
context:
space:
mode:
authorMatthias Springer <me@m-sp.org>2023-09-18 09:13:43 +0200
committerGitHub <noreply@github.com>2023-09-18 09:13:43 +0200
commit5cf714bb2f75552b10e1eb62fd07aec4b6033881 (patch)
treed7788825e993d1aafe09f655d75f498aba2cc26c /mlir/lib/Conversion/VectorToGPU
parent87143ff9f2f4ec897f41a40c4e410c412cca697e (diff)
[mlir][SCF] scf.for: Consistent API around `initArgs` (#66512)
* Always use the auto-generated `getInitArgs` function. Remove the hand-written `getInitOperands` duplicate. * Remove `hasIterOperands` and `getNumIterOperands`. The names were inconsistent because the "arg" is called `initArgs` in TableGen. Use `getInitArgs().size()` instead. * Fix verification around ops with no results.
Diffstat (limited to 'mlir/lib/Conversion/VectorToGPU')
-rw-r--r--mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp b/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
index 3089e917d0ee..c8871c945cbe 100644
--- a/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
+++ b/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
@@ -1106,14 +1106,14 @@ convertBroadcastOp(RewriterBase &rewriter, vector::BroadcastOp op,
// updated and needs to be updated separatly for the loop to be correct.
static scf::ForOp replaceForOpWithNewSignature(RewriterBase &rewriter,
scf::ForOp loop,
- ValueRange newIterOperands) {
+ ValueRange newInitArgs) {
OpBuilder::InsertionGuard g(rewriter);
rewriter.setInsertionPoint(loop);
// Create a new loop before the existing one, with the extra operands.
rewriter.setInsertionPoint(loop);
- auto operands = llvm::to_vector<4>(loop.getIterOperands());
- operands.append(newIterOperands.begin(), newIterOperands.end());
+ auto operands = llvm::to_vector<4>(loop.getInitArgs());
+ llvm::append_range(operands, newInitArgs);
scf::ForOp newLoop = rewriter.create<scf::ForOp>(
loop.getLoc(), loop.getLowerBound(), loop.getUpperBound(), loop.getStep(),
operands);
@@ -1122,7 +1122,7 @@ static scf::ForOp replaceForOpWithNewSignature(RewriterBase &rewriter,
newLoop.getLoopBody().getBlocks().splice(
newLoop.getLoopBody().getBlocks().begin(),
loop.getLoopBody().getBlocks());
- for (Value operand : newIterOperands)
+ for (Value operand : newInitArgs)
newLoop.getBody()->addArgument(operand.getType(), operand.getLoc());
for (auto it : llvm::zip(loop.getResults(), newLoop.getResults().take_front(
@@ -1144,14 +1144,14 @@ static LogicalResult convertForOp(RewriterBase &rewriter, scf::ForOp op,
SmallVector<Value> newOperands;
SmallVector<std::pair<size_t, size_t>> argMapping;
- for (const auto &operand : llvm::enumerate(op.getIterOperands())) {
+ for (const auto &operand : llvm::enumerate(op.getInitArgs())) {
auto it = valueMapping.find(operand.value());
if (it == valueMapping.end()) {
LLVM_DEBUG(DBGS() << "no value mapping for: " << operand.value() << "\n");
continue;
}
argMapping.push_back(std::make_pair(
- operand.index(), op.getNumIterOperands() + newOperands.size()));
+ operand.index(), op.getInitArgs().size() + newOperands.size()));
newOperands.push_back(it->second);
}
@@ -1183,7 +1183,7 @@ convertYieldOp(RewriterBase &rewriter, scf::YieldOp op,
continue;
// Replace the yield of old value with the for op argument to make it easier
// to remove the dead code.
- yieldOperands[operand.index()] = loop.getIterOperands()[operand.index()];
+ yieldOperands[operand.index()] = loop.getInitArgs()[operand.index()];
yieldOperands.push_back(it->second);
}
rewriter.create<scf::YieldOp>(op.getLoc(), yieldOperands);