diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp @@ -189,7 +189,7 @@ params.push_back(constantI64(rewriter, loc, secInd)); params.push_back(constantI64(rewriter, loc, primary)); // User action and pointer. - Type pTp = LLVM::LLVMPointerType::get(IntegerType::get(op->getContext(), 8)); + Type pTp = LLVM::LLVMPointerType::get(rewriter.getI8Type()); if (!ptr) ptr = rewriter.create(loc, pTp); params.push_back(constantI32(rewriter, loc, action)); @@ -226,9 +226,8 @@ /// if (tensor[ivs]!=0) { /// ind = ivs static Value genIndexAndValueForDense(ConversionPatternRewriter &rewriter, - Operation *op, Value tensor, Value ind, + Location loc, Value tensor, Value ind, ValueRange ivs) { - Location loc = op->getLoc(); Value val = rewriter.create(loc, tensor, ivs); Value cond = genIsNonzero(rewriter, loc, val); scf::IfOp ifOp = rewriter.create(loc, cond, /*else*/ false); @@ -270,7 +269,7 @@ params.push_back(val); params.push_back(ind); params.push_back(perm); - Type pTp = LLVM::LLVMPointerType::get(IntegerType::get(op->getContext(), 8)); + Type pTp = LLVM::LLVMPointerType::get(rewriter.getI8Type()); rewriter.create( loc, pTp, getFunc(op, name, pTp, params, /*emitCInterface=*/true), params); @@ -279,11 +278,10 @@ /// If the tensor is a sparse constant, generates and returns the pair of /// the constants for the indices and the values. static Optional> -genSplitSparseConstant(ConversionPatternRewriter &rewriter, ConvertOp op, +genSplitSparseConstant(ConversionPatternRewriter &rewriter, Location loc, Value tensor) { if (auto constOp = tensor.getDefiningOp()) { if (auto attr = constOp.value().dyn_cast()) { - Location loc = op->getLoc(); DenseElementsAttr indicesAttr = attr.getIndices(); Value indices = rewriter.create(loc, indicesAttr); DenseElementsAttr valuesAttr = attr.getValues(); @@ -297,10 +295,9 @@ /// Generates the code to copy the index at indices[ivs] to ind, and return /// the value at value[ivs]. static Value genIndexAndValueForSparse(ConversionPatternRewriter &rewriter, - Operation *op, Value indices, + Location loc, Value indices, Value values, Value ind, ValueRange ivs, unsigned rank) { - Location loc = op->getLoc(); for (unsigned i = 0; i < rank; i++) { Value idx = constantIndex(rewriter, loc, i); Value val = rewriter.create(loc, indices, @@ -449,7 +446,7 @@ SmallVector st; Value zero = constantIndex(rewriter, loc, 0); Value one = constantIndex(rewriter, loc, 1); - auto indicesValues = genSplitSparseConstant(rewriter, op, src); + auto indicesValues = genSplitSparseConstant(rewriter, loc, src); bool isCOOConstant = indicesValues.hasValue(); Value indices; Value values; @@ -474,10 +471,10 @@ ValueRange args) -> scf::ValueVector { Value val; if (isCOOConstant) - val = genIndexAndValueForSparse(rewriter, op, indices, values, ind, + val = genIndexAndValueForSparse(rewriter, loc, indices, values, ind, ivs, rank); else - val = genIndexAndValueForDense(rewriter, op, src, ind, ivs); + val = genIndexAndValueForDense(rewriter, loc, src, ind, ivs); genAddEltCall(rewriter, op, eltType, ptr, val, ind, perm); return {}; });