-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mlir][sparse] remove deprecated toCOO from sparse runtime support lib #85319
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aartbik
requested review from
PeimingLiu,
yinying-lisa-li and
matthias-springer
as code owners
March 14, 2024 21:49
@llvm/pr-subscribers-mlir-execution-engine @llvm/pr-subscribers-mlir Author: Aart Bik (aartbik) ChangesFull diff: https://github.com/llvm/llvm-project/pull/85319.diff 1 Files Affected:
diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h b/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
index 468782ebef4e34..b207fc1ee104d3 100644
--- a/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
+++ b/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
@@ -197,7 +197,7 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
const uint64_t *lvl2dim)
: SparseTensorStorageBase(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes,
dim2lvl, lvl2dim),
- positions(lvlRank), coordinates(lvlRank), lvlCursor(lvlRank), coo() {}
+ positions(lvlRank), coordinates(lvlRank), lvlCursor(lvlRank) {}
public:
/// Constructs a sparse tensor with the given encoding, and allocates
@@ -337,16 +337,6 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
}
}
- /// Allocates a new COO object and initializes it with the contents.
- /// Callers must make sure to delete the COO when they're done with it.
- SparseTensorCOO<V> *toCOO() {
- std::vector<uint64_t> dimCoords(getDimRank());
- coo = new SparseTensorCOO<V>(getDimSizes(), values.size());
- toCOO(0, 0, dimCoords);
- assert(coo->getElements().size() == values.size());
- return coo;
- }
-
/// Sort the unordered tensor in place, the method assumes that it is
/// an unordered COO tensor.
void sortInPlace() {
@@ -556,58 +546,10 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
return -1u;
}
- // Performs forall on level entries and inserts into dim COO.
- void toCOO(uint64_t parentPos, uint64_t l, std::vector<uint64_t> &dimCoords) {
- if (l == getLvlRank()) {
- map.pushbackward(lvlCursor.data(), dimCoords.data());
- assert(coo);
- assert(parentPos < values.size());
- coo->add(dimCoords, values[parentPos]);
- return;
- }
- if (isCompressedLvl(l)) {
- const std::vector<P> &positionsL = positions[l];
- assert(parentPos + 1 < positionsL.size());
- const uint64_t pstart = static_cast<uint64_t>(positionsL[parentPos]);
- const uint64_t pstop = static_cast<uint64_t>(positionsL[parentPos + 1]);
- const std::vector<C> &coordinatesL = coordinates[l];
- assert(pstop <= coordinatesL.size());
- for (uint64_t pos = pstart; pos < pstop; pos++) {
- lvlCursor[l] = static_cast<uint64_t>(coordinatesL[pos]);
- toCOO(pos, l + 1, dimCoords);
- }
- } else if (isLooseCompressedLvl(l)) {
- const std::vector<P> &positionsL = positions[l];
- assert(2 * parentPos + 1 < positionsL.size());
- const uint64_t pstart = static_cast<uint64_t>(positionsL[2 * parentPos]);
- const uint64_t pstop =
- static_cast<uint64_t>(positionsL[2 * parentPos + 1]);
- const std::vector<C> &coordinatesL = coordinates[l];
- assert(pstop <= coordinatesL.size());
- for (uint64_t pos = pstart; pos < pstop; pos++) {
- lvlCursor[l] = static_cast<uint64_t>(coordinatesL[pos]);
- toCOO(pos, l + 1, dimCoords);
- }
- } else if (isSingletonLvl(l) || isNOutOfMLvl(l)) {
- assert(parentPos < coordinates[l].size());
- lvlCursor[l] = static_cast<uint64_t>(coordinates[l][parentPos]);
- toCOO(parentPos, l + 1, dimCoords);
- } else { // Dense level.
- assert(isDenseLvl(l));
- const uint64_t sz = getLvlSizes()[l];
- const uint64_t pstart = parentPos * sz;
- for (uint64_t c = 0; c < sz; c++) {
- lvlCursor[l] = c;
- toCOO(pstart + c, l + 1, dimCoords);
- }
- }
- }
-
std::vector<std::vector<P>> positions;
std::vector<std::vector<C>> coordinates;
std::vector<V> values;
std::vector<uint64_t> lvlCursor;
- SparseTensorCOO<V> *coo;
};
//===----------------------------------------------------------------------===//
@@ -661,7 +603,6 @@ SparseTensorStorage<P, C, V>::SparseTensorStorage(
: SparseTensorStorage(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes,
dim2lvl, lvl2dim) {
assert(!lvlCOO || lvlRank == lvlCOO->getRank());
- coo = lvlCOO;
// Provide hints on capacity of positions and coordinates.
// TODO: needs much fine-tuning based on actual sparsity; currently
// we reserve position/coordinate space based on all previous dense
|
@llvm/pr-subscribers-mlir-sparse Author: Aart Bik (aartbik) ChangesFull diff: https://github.com/llvm/llvm-project/pull/85319.diff 1 Files Affected:
diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h b/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
index 468782ebef4e34..b207fc1ee104d3 100644
--- a/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
+++ b/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
@@ -197,7 +197,7 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
const uint64_t *lvl2dim)
: SparseTensorStorageBase(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes,
dim2lvl, lvl2dim),
- positions(lvlRank), coordinates(lvlRank), lvlCursor(lvlRank), coo() {}
+ positions(lvlRank), coordinates(lvlRank), lvlCursor(lvlRank) {}
public:
/// Constructs a sparse tensor with the given encoding, and allocates
@@ -337,16 +337,6 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
}
}
- /// Allocates a new COO object and initializes it with the contents.
- /// Callers must make sure to delete the COO when they're done with it.
- SparseTensorCOO<V> *toCOO() {
- std::vector<uint64_t> dimCoords(getDimRank());
- coo = new SparseTensorCOO<V>(getDimSizes(), values.size());
- toCOO(0, 0, dimCoords);
- assert(coo->getElements().size() == values.size());
- return coo;
- }
-
/// Sort the unordered tensor in place, the method assumes that it is
/// an unordered COO tensor.
void sortInPlace() {
@@ -556,58 +546,10 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
return -1u;
}
- // Performs forall on level entries and inserts into dim COO.
- void toCOO(uint64_t parentPos, uint64_t l, std::vector<uint64_t> &dimCoords) {
- if (l == getLvlRank()) {
- map.pushbackward(lvlCursor.data(), dimCoords.data());
- assert(coo);
- assert(parentPos < values.size());
- coo->add(dimCoords, values[parentPos]);
- return;
- }
- if (isCompressedLvl(l)) {
- const std::vector<P> &positionsL = positions[l];
- assert(parentPos + 1 < positionsL.size());
- const uint64_t pstart = static_cast<uint64_t>(positionsL[parentPos]);
- const uint64_t pstop = static_cast<uint64_t>(positionsL[parentPos + 1]);
- const std::vector<C> &coordinatesL = coordinates[l];
- assert(pstop <= coordinatesL.size());
- for (uint64_t pos = pstart; pos < pstop; pos++) {
- lvlCursor[l] = static_cast<uint64_t>(coordinatesL[pos]);
- toCOO(pos, l + 1, dimCoords);
- }
- } else if (isLooseCompressedLvl(l)) {
- const std::vector<P> &positionsL = positions[l];
- assert(2 * parentPos + 1 < positionsL.size());
- const uint64_t pstart = static_cast<uint64_t>(positionsL[2 * parentPos]);
- const uint64_t pstop =
- static_cast<uint64_t>(positionsL[2 * parentPos + 1]);
- const std::vector<C> &coordinatesL = coordinates[l];
- assert(pstop <= coordinatesL.size());
- for (uint64_t pos = pstart; pos < pstop; pos++) {
- lvlCursor[l] = static_cast<uint64_t>(coordinatesL[pos]);
- toCOO(pos, l + 1, dimCoords);
- }
- } else if (isSingletonLvl(l) || isNOutOfMLvl(l)) {
- assert(parentPos < coordinates[l].size());
- lvlCursor[l] = static_cast<uint64_t>(coordinates[l][parentPos]);
- toCOO(parentPos, l + 1, dimCoords);
- } else { // Dense level.
- assert(isDenseLvl(l));
- const uint64_t sz = getLvlSizes()[l];
- const uint64_t pstart = parentPos * sz;
- for (uint64_t c = 0; c < sz; c++) {
- lvlCursor[l] = c;
- toCOO(pstart + c, l + 1, dimCoords);
- }
- }
- }
-
std::vector<std::vector<P>> positions;
std::vector<std::vector<C>> coordinates;
std::vector<V> values;
std::vector<uint64_t> lvlCursor;
- SparseTensorCOO<V> *coo;
};
//===----------------------------------------------------------------------===//
@@ -661,7 +603,6 @@ SparseTensorStorage<P, C, V>::SparseTensorStorage(
: SparseTensorStorage(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes,
dim2lvl, lvl2dim) {
assert(!lvlCOO || lvlRank == lvlCOO->getRank());
- coo = lvlCOO;
// Provide hints on capacity of positions and coordinates.
// TODO: needs much fine-tuning based on actual sparsity; currently
// we reserve position/coordinate space based on all previous dense
|
PeimingLiu
approved these changes
Mar 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.