@@ -767,8 +767,7 @@ mlir::scf::tileUsingSCFForallOp(RewriterBase &rewriter, TilingInterface op,
767767
768768 // 3. Build the offsets, sizes and steps for the tile and distributed loops.
769769 SmallVector<OpFoldResult> lbs, ubs, steps;
770- for (auto [index, tileSize, loopRange] :
771- llvm::enumerate (tileSizeVector, loopRanges)) {
770+ for (auto [tileSize, loopRange] : llvm::zip (tileSizeVector, loopRanges)) {
772771 if (isConstantIntValue (tileSize, 0 ))
773772 continue ;
774773 lbs.push_back (loopRange.offset );
@@ -781,7 +780,7 @@ mlir::scf::tileUsingSCFForallOp(RewriterBase &rewriter, TilingInterface op,
781780 if (failed (tensor::getOrCreateDestinations (rewriter, loc, op, dest)))
782781 return op->emitOpError (" failed to get destination tensors" );
783782
784- // 5. Build the device mapping attribute;
783+ // 5. Build the device mapping attribute.
785784 std::optional<ArrayAttr> mappingAttr;
786785 if (!options.mappingVector .empty ()) {
787786 mappingAttr = rewriter.getArrayAttr (ArrayRef (options.mappingVector ));
@@ -796,13 +795,10 @@ mlir::scf::tileUsingSCFForallOp(RewriterBase &rewriter, TilingInterface op,
796795 // 7. Get the tile offset and sizes.
797796 rewriter.setInsertionPoint (forallOp.getTerminator ());
798797 SmallVector<OpFoldResult> tiledOffsets, tiledSizes;
799- tiledOffsets.reserve (loopRanges.size ());
800- tiledSizes.reserve (loopRanges.size ());
801798 ValueRange ivs = forallOp.getInductionVars ();
802799 {
803800 int materializedLoopNum = 0 ;
804- for (auto [index, tileSize, loopRange] :
805- llvm::enumerate (tileSizeVector, loopRanges)) {
801+ for (auto [tileSize, loopRange] : llvm::zip (tileSizeVector, loopRanges)) {
806802 if (isConstantIntValue (tileSize, 0 )) {
807803 tiledOffsets.push_back (loopRange.offset );
808804 tiledSizes.push_back (loopRange.size );
@@ -816,15 +812,15 @@ mlir::scf::tileUsingSCFForallOp(RewriterBase &rewriter, TilingInterface op,
816812 }
817813
818814 // 8. Tile the operation. Clone the operation to allow fix up of destination
819- // operands
815+ // operands.
820816 ArrayRef<BlockArgument> destBbArgs = forallOp.getOutputBlockArguments ();
821817 Operation *clonedOp =
822818 cloneOpAndUpdateDestinationArgs (rewriter, op, destBbArgs);
823819 FailureOr<TilingResult> tilingResult =
824820 cast<TilingInterface>(clonedOp).getTiledImplementation (
825821 rewriter, tiledOffsets, tiledSizes);
826822 if (failed (tilingResult))
827- return clonedOp->emitError (" Failed to tile op: " );
823+ return clonedOp->emitError (" failed to tile op: " );
828824 rewriter.eraseOp (clonedOp);
829825
830826 // 9. Parallel insert back into the result tensor.
@@ -836,24 +832,25 @@ mlir::scf::tileUsingSCFForallOp(RewriterBase &rewriter, TilingInterface op,
836832 SmallVector<OpFoldResult> resultOffsets, resultSizes;
837833 if (failed (op.getResultTilePosition (rewriter, index, tiledOffsets,
838834 tiledSizes, resultOffsets,
839- resultSizes)))
835+ resultSizes))) {
840836 return op->emitOpError (" output offsets couldn't be calculated" );
837+ }
838+
841839 SmallVector<OpFoldResult> strides (resultSizes.size (),
842840 rewriter.getIndexAttr (1 ));
843-
844- // 5.b. Parallel insertions are inserted at the end of the combining
841+ // 9.b. Parallel insertions are inserted at the end of the combining
845842 // terminator.
846843 rewriter.setInsertionPointToEnd (forallOp.getTerminator ().getBody ());
847844 rewriter.create <tensor::ParallelInsertSliceOp>(
848845 loc, tiledValue, destBBArg, resultOffsets, resultSizes, strides);
849846 }
850847
851- // 10. Return the tiling result;
848+ // 10. Return the tiling result.
852849 return scf::SCFTilingResult{
853850 tilingResult->tiledOps ,
854851 {forallOp.getOperation ()},
855- llvm::to_vector ( llvm::map_range (forallOp.getResults (),
856- [](auto val) -> Value { return val; }) )};
852+ llvm::map_to_vector (forallOp.getResults (),
853+ [](auto val) -> Value { return val; })};
857854}
858855
859856// ===----------------------------------------------------------------------===//
0 commit comments