[Mlir-commits] [mlir] c2d03e4 - [MLIR] Change return type of ParallelOp::getInductionVars to ValueRange.

Alexander Belyaev llvmlistbot at llvm.org
Mon Apr 6 01:11:50 PDT 2020


Author: Alexander Belyaev
Date: 2020-04-06T10:11:02+02:00
New Revision: c2d03e4ef1412e434ba62fd071f76b65e9f0e666

URL: https://github.com/llvm/llvm-project/commit/c2d03e4ef1412e434ba62fd071f76b65e9f0e666
DIFF: https://github.com/llvm/llvm-project/commit/c2d03e4ef1412e434ba62fd071f76b65e9f0e666.diff

LOG: [MLIR] Change return type of ParallelOp::getInductionVars to ValueRange.

The current return type sometimes leads to code like
to_vector<2>(ValueRange(loop.getInductionIvs())). It would be nice to
shorten it. Users who need access to Block::BlockArgListType (if there
are any), can always call getBody()->getArguments(); if needed.

Also remove getNumInductionVars(), since there is getNumLoops().

Differential Revision: https://reviews.llvm.org/D77526

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/LoopOps/LoopOps.td
    mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td
index 1e446efa9758..436a376a6f4f 100644
--- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td
+++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td
@@ -312,10 +312,7 @@ def ParallelOp : Loop_Op<"parallel",
 
   let extraClassDeclaration = [{
     Block *getBody() { return &region().front(); }
-    unsigned getNumInductionVars() {
-      return getBody()->getNumArguments();
-    }
-    Block::BlockArgListType getInductionVars() {
+    ValueRange getInductionVars() {
       return getBody()->getArguments();
     }
     unsigned getNumLoops() { return step().size(); }

diff  --git a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
index 9697688ac850..177fdf0d668f 100644
--- a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
@@ -130,8 +130,8 @@ static void mapParallelOp(ParallelOp parallelOp,
   MLIRContext *ctx = parallelOp.getContext();
   Builder b(ctx);
   SmallVector<ParallelLoopDimMapping, 4> attrs;
-  attrs.reserve(parallelOp.getNumInductionVars());
-  for (int i = 0, e = parallelOp.getNumInductionVars(); i < e; ++i) {
+  attrs.reserve(parallelOp.getNumLoops());
+  for (int i = 0, e = parallelOp.getNumLoops(); i < e; ++i) {
     attrs.push_back(getParallelLoopDimMappingAttr(
         getHardwareIdForMapping(mappingLevel, i), b.getDimIdentityMap(),
         b.getDimIdentityMap()));


        


More information about the Mlir-commits mailing list