[Mlir-commits] [mlir] [NFC][mlir][sparse] remove redundant parameter. (PR #75551)
Peiming Liu
llvmlistbot at llvm.org
Thu Dec 14 16:48:28 PST 2023
https://github.com/PeimingLiu created https://github.com/llvm/llvm-project/pull/75551
None
>From 0446f797a8c1d950810484e5ea7d103c789c9260 Mon Sep 17 00:00:00 2001
From: Peiming Liu <peiming at google.com>
Date: Fri, 15 Dec 2023 00:46:47 +0000
Subject: [PATCH] [NFC][mlir][sparse] remove redundant parameter.
---
.../Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp | 4 ++--
.../Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp | 5 +++--
.../Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h | 2 +-
.../Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp | 6 ++----
4 files changed, 8 insertions(+), 9 deletions(-)
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..8c0060a85bca2e 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
@@ -457,12 +457,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