mirror of
https://github.com/intel/llvm.git
synced 2026-01-28 00:33:43 +08:00
[mlir] Toy tutorial: avoid erasing and then re-creating loop terminators
The lower-to-affine-loops pass in chapters 5-7 of the Toy tutorial has
been creating affine loops, erasing their terminator and creating it
anew using a PatternRewriter instance to work around the fact that
implicit terminators were created without notifying the rewriter. Now
that has been fixed in 3ccf4a5bd1, remove the code erasing and
re-creating the terminators and rely on the default ones.
This commit is contained in:
@@ -72,14 +72,9 @@ static void lowerOpToLoops(Operation *op, ArrayRef<Value> operands,
|
||||
SmallVector<Value, 4> loopIvs;
|
||||
for (auto dim : tensorType.getShape()) {
|
||||
auto loop = rewriter.create<AffineForOp>(loc, /*lb=*/0, dim, /*step=*/1);
|
||||
for (Operation &nested : *loop.getBody())
|
||||
rewriter.eraseOp(&nested);
|
||||
loopIvs.push_back(loop.getInductionVar());
|
||||
|
||||
// Terminate the loop body and update the rewriter insertion point to the
|
||||
// beginning of the loop.
|
||||
rewriter.setInsertionPointToStart(loop.getBody());
|
||||
rewriter.create<AffineTerminatorOp>(loc);
|
||||
// Update the rewriter insertion point to the beginning of the loop.
|
||||
rewriter.setInsertionPointToStart(loop.getBody());
|
||||
}
|
||||
|
||||
|
||||
@@ -72,14 +72,9 @@ static void lowerOpToLoops(Operation *op, ArrayRef<Value> operands,
|
||||
SmallVector<Value, 4> loopIvs;
|
||||
for (auto dim : tensorType.getShape()) {
|
||||
auto loop = rewriter.create<AffineForOp>(loc, /*lb=*/0, dim, /*step=*/1);
|
||||
for (Operation &nested : *loop.getBody())
|
||||
rewriter.eraseOp(&nested);
|
||||
loopIvs.push_back(loop.getInductionVar());
|
||||
|
||||
// Terminate the loop body and update the rewriter insertion point to the
|
||||
// beginning of the loop.
|
||||
rewriter.setInsertionPointToStart(loop.getBody());
|
||||
rewriter.create<AffineTerminatorOp>(loc);
|
||||
// Update the rewriter insertion point to the beginning of the loop.
|
||||
rewriter.setInsertionPointToStart(loop.getBody());
|
||||
}
|
||||
|
||||
|
||||
@@ -72,14 +72,9 @@ static void lowerOpToLoops(Operation *op, ArrayRef<Value> operands,
|
||||
SmallVector<Value, 4> loopIvs;
|
||||
for (auto dim : tensorType.getShape()) {
|
||||
auto loop = rewriter.create<AffineForOp>(loc, /*lb=*/0, dim, /*step=*/1);
|
||||
for (Operation &nested : *loop.getBody())
|
||||
rewriter.eraseOp(&nested);
|
||||
loopIvs.push_back(loop.getInductionVar());
|
||||
|
||||
// Terminate the loop body and update the rewriter insertion point to the
|
||||
// beginning of the loop.
|
||||
rewriter.setInsertionPointToStart(loop.getBody());
|
||||
rewriter.create<AffineTerminatorOp>(loc);
|
||||
// Update the rewriter insertion point to the beginning of the loop.
|
||||
rewriter.setInsertionPointToStart(loop.getBody());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user