[Mlir-commits] [mlir] c4f1af2 - [mlir][sparse] avoid single small vector, set exact number 3

Aart Bik llvmlistbot at llvm.org
Tue Nov 15 21:04:53 PST 2022


Author: Aart Bik
Date: 2022-11-15T21:04:43-08:00
New Revision: c4f1af2bdfbf0c616b82efa954aecbfa47bb561d

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

LOG: [mlir][sparse] avoid single small vector, set exact number 3

Reviewed By: wrengr

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

Added: 
    

Modified: 
    mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp
    mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp
index 75fa3e8b347c..b5e9826b703d 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp
@@ -490,8 +490,8 @@ static void createPartitionFunc(OpBuilder &builder, ModuleOp module,
 
   Value i = lo;
   Value j = builder.create<arith::SubIOp>(loc, hi, c1);
-  SmallVector<Value> operands{i, j, p};
-  SmallVector<Type> types{i.getType(), j.getType(), p.getType()};
+  SmallVector<Value, 3> operands{i, j, p};  // exactly three
+  SmallVector<Type, 3> types{i.getType(), j.getType(), p.getType()};
   scf::WhileOp whileOp = builder.create<scf::WhileOp>(loc, types, operands);
 
   // The before-region of the WhileOp.

diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
index 77b3e5bf6af9..c97556c8205e 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
@@ -543,8 +543,8 @@ static void genEndInsert(OpBuilder &builder, Location loc, RankedTensorType rtp,
         Value hi = genLoad(builder, loc, fields[memSizesIdx], mz);
         Value zero = constantIndex(builder, loc, 0);
         Value one = constantIndex(builder, loc, 1);
-        SmallVector<Value, 1> inits;  // only one
-        inits.push_back(genLoad(builder, loc, fields[field], zero));
+        // Vector of only one, but needed by createFor's prototype.
+        SmallVector<Value, 1> inits{genLoad(builder, loc, fields[field], zero)};
         scf::ForOp loop = createFor(builder, loc, hi, inits, one);
         Value i = loop.getInductionVar();
         Value oldv = loop.getRegionIterArg(0);


        


More information about the Mlir-commits mailing list