Skip to content

Commit 9d994e9

Browse files
authored
[mlir][sparse] remove deprecated toCOO from sparse runtime support lib (#85319)
1 parent c75009e commit 9d994e9

File tree

1 file changed

+1
-60
lines changed
  • mlir/include/mlir/ExecutionEngine/SparseTensor

1 file changed

+1
-60
lines changed

mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
197197
const uint64_t *lvl2dim)
198198
: SparseTensorStorageBase(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes,
199199
dim2lvl, lvl2dim),
200-
positions(lvlRank), coordinates(lvlRank), lvlCursor(lvlRank), coo() {}
200+
positions(lvlRank), coordinates(lvlRank), lvlCursor(lvlRank) {}
201201

202202
public:
203203
/// Constructs a sparse tensor with the given encoding, and allocates
@@ -337,16 +337,6 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
337337
}
338338
}
339339

340-
/// Allocates a new COO object and initializes it with the contents.
341-
/// Callers must make sure to delete the COO when they're done with it.
342-
SparseTensorCOO<V> *toCOO() {
343-
std::vector<uint64_t> dimCoords(getDimRank());
344-
coo = new SparseTensorCOO<V>(getDimSizes(), values.size());
345-
toCOO(0, 0, dimCoords);
346-
assert(coo->getElements().size() == values.size());
347-
return coo;
348-
}
349-
350340
/// Sort the unordered tensor in place, the method assumes that it is
351341
/// an unordered COO tensor.
352342
void sortInPlace() {
@@ -556,58 +546,10 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
556546
return -1u;
557547
}
558548

559-
// Performs forall on level entries and inserts into dim COO.
560-
void toCOO(uint64_t parentPos, uint64_t l, std::vector<uint64_t> &dimCoords) {
561-
if (l == getLvlRank()) {
562-
map.pushbackward(lvlCursor.data(), dimCoords.data());
563-
assert(coo);
564-
assert(parentPos < values.size());
565-
coo->add(dimCoords, values[parentPos]);
566-
return;
567-
}
568-
if (isCompressedLvl(l)) {
569-
const std::vector<P> &positionsL = positions[l];
570-
assert(parentPos + 1 < positionsL.size());
571-
const uint64_t pstart = static_cast<uint64_t>(positionsL[parentPos]);
572-
const uint64_t pstop = static_cast<uint64_t>(positionsL[parentPos + 1]);
573-
const std::vector<C> &coordinatesL = coordinates[l];
574-
assert(pstop <= coordinatesL.size());
575-
for (uint64_t pos = pstart; pos < pstop; pos++) {
576-
lvlCursor[l] = static_cast<uint64_t>(coordinatesL[pos]);
577-
toCOO(pos, l + 1, dimCoords);
578-
}
579-
} else if (isLooseCompressedLvl(l)) {
580-
const std::vector<P> &positionsL = positions[l];
581-
assert(2 * parentPos + 1 < positionsL.size());
582-
const uint64_t pstart = static_cast<uint64_t>(positionsL[2 * parentPos]);
583-
const uint64_t pstop =
584-
static_cast<uint64_t>(positionsL[2 * parentPos + 1]);
585-
const std::vector<C> &coordinatesL = coordinates[l];
586-
assert(pstop <= coordinatesL.size());
587-
for (uint64_t pos = pstart; pos < pstop; pos++) {
588-
lvlCursor[l] = static_cast<uint64_t>(coordinatesL[pos]);
589-
toCOO(pos, l + 1, dimCoords);
590-
}
591-
} else if (isSingletonLvl(l) || isNOutOfMLvl(l)) {
592-
assert(parentPos < coordinates[l].size());
593-
lvlCursor[l] = static_cast<uint64_t>(coordinates[l][parentPos]);
594-
toCOO(parentPos, l + 1, dimCoords);
595-
} else { // Dense level.
596-
assert(isDenseLvl(l));
597-
const uint64_t sz = getLvlSizes()[l];
598-
const uint64_t pstart = parentPos * sz;
599-
for (uint64_t c = 0; c < sz; c++) {
600-
lvlCursor[l] = c;
601-
toCOO(pstart + c, l + 1, dimCoords);
602-
}
603-
}
604-
}
605-
606549
std::vector<std::vector<P>> positions;
607550
std::vector<std::vector<C>> coordinates;
608551
std::vector<V> values;
609552
std::vector<uint64_t> lvlCursor;
610-
SparseTensorCOO<V> *coo;
611553
};
612554

613555
//===----------------------------------------------------------------------===//
@@ -661,7 +603,6 @@ SparseTensorStorage<P, C, V>::SparseTensorStorage(
661603
: SparseTensorStorage(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes,
662604
dim2lvl, lvl2dim) {
663605
assert(!lvlCOO || lvlRank == lvlCOO->getRank());
664-
coo = lvlCOO;
665606
// Provide hints on capacity of positions and coordinates.
666607
// TODO: needs much fine-tuning based on actual sparsity; currently
667608
// we reserve position/coordinate space based on all previous dense

0 commit comments

Comments
 (0)