[Mlir-commits] [mlir] 4a72a4e - [NFC][mlir][sparse] remove redundant parameter. (#75551)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Dec 15 09:29:27 PST 2023
Author: Peiming Liu
Date: 2023-12-15T09:29:22-08:00
New Revision: 4a72a4ef12ace2e96f31cc280928a984c59f80bb
URL: https://github.com/llvm/llvm-project/commit/4a72a4ef12ace2e96f31cc280928a984c59f80bb
DIFF: https://github.com/llvm/llvm-project/commit/4a72a4ef12ace2e96f31cc280928a984c59f80bb.diff
LOG: [NFC][mlir][sparse] remove redundant parameter. (#75551)
Added:
Modified:
mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h
mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
index 477ff2e1c9237e..30ab2a1f18e3f7 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
@@ -476,7 +476,7 @@ static Value genFirstPosOrCrds(OpBuilder &builder, Location loc, Value a,
if (format == CuSparseFormat::kCOO) {
// Library uses SoA COO, direct IR uses AoS COO.
if (enableRT)
- return genToCoordinates(builder, loc, a, 0, /*cooStart=*/0);
+ return genToCoordinates(builder, loc, a, 0);
return genToCoordinatesBuffer(builder, loc, a);
}
// Formats CSR/CSC and BSR use positions at 1.
@@ -490,7 +490,7 @@ static Value genSecondCrds(OpBuilder &builder, Location loc, Value a,
if (isCOO && !enableRT)
return Value(); // nothing needed
// Formats CSR/CSC and BSR use coordinates at 1.
- return genToCoordinates(builder, loc, a, 1, /*cooStart=*/isCOO ? 0 : 2);
+ return genToCoordinates(builder, loc, a, 1);
}
/// Generates the sparse matrix handle.
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
index 33d449aac5a355..75a43891491879 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
@@ -564,10 +564,11 @@ Value sparse_tensor::genToPositions(OpBuilder &builder, Location loc,
}
Value sparse_tensor::genToCoordinates(OpBuilder &builder, Location loc,
- Value tensor, Level lvl, Level cooStart) {
+ Value tensor, Level lvl) {
const auto srcTp = getSparseTensorType(tensor);
const Type crdTp = srcTp.getCrdType();
- const Type memTp = get1DMemRefType(crdTp, /*withLayout=*/lvl >= cooStart);
+ const Type memTp =
+ get1DMemRefType(crdTp, /*withLayout=*/lvl >= srcTp.getCOOStart());
return builder.create<ToCoordinatesOp>(loc, memTp, tensor,
builder.getIndexAttr(lvl));
}
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h
index 8dc57e1b5479bf..8d54b5959d8712 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h
@@ -289,7 +289,7 @@ Value genToPositions(OpBuilder &builder, Location loc, Value tensor, Level lvl);
/// stride and offset. Otherwise, the result type is a memref without
/// any specified layout.
Value genToCoordinates(OpBuilder &builder, Location loc, Value tensor,
- Level lvl, Level cooStart);
+ Level lvl);
/// Infers the result type and generates `ToCoordinatesBufferOp`.
Value genToCoordinatesBuffer(OpBuilder &builder, Location loc, Value tensor);
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
index 08d37b6a9656fe..784c793c9bd119 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
@@ -437,7 +437,6 @@ void LoopEmitter::initializeLoopEmit(
auto stt = getSparseTensorType(tensor);
const Level lvlRank = stt.getLvlRank();
const auto shape = rtp.getShape();
- const Level cooStart = stt.getCOOStart();
SmallVector<Value> lvlSzs;
for (Level l = 0; l < stt.getLvlRank(); l++) {
@@ -457,12 +456,10 @@ void LoopEmitter::initializeLoopEmit(
if (isCompressedLT(lvlTp) || isLooseCompressedLT(lvlTp)) {
// Generate sparse primitives to obtain positions and coordinates.
positionsBuffers[t][l] = genToPositions(builder, loc, tensor, l);
- coordinatesBuffers[t][l] =
- genToCoordinates(builder, loc, tensor, l, cooStart);
+ coordinatesBuffers[t][l] = genToCoordinates(builder, loc, tensor, l);
} else if (isSingletonLT(lvlTp) || is2OutOf4LT(lvlTp)) {
// Singleton level, fetch coordinates.
- coordinatesBuffers[t][l] =
- genToCoordinates(builder, loc, tensor, l, cooStart);
+ coordinatesBuffers[t][l] = genToCoordinates(builder, loc, tensor, l);
} else {
// Dense level, nothing to fetch.
assert(isDenseLT(lvlTp));
More information about the Mlir-commits
mailing list