@@ -197,7 +197,7 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
197
197
const uint64_t *lvl2dim)
198
198
: SparseTensorStorageBase(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes,
199
199
dim2lvl, lvl2dim),
200
- positions (lvlRank), coordinates(lvlRank), lvlCursor(lvlRank), coo() {}
200
+ positions (lvlRank), coordinates(lvlRank), lvlCursor(lvlRank) {}
201
201
202
202
public:
203
203
// / Constructs a sparse tensor with the given encoding, and allocates
@@ -337,16 +337,6 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
337
337
}
338
338
}
339
339
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
-
350
340
// / Sort the unordered tensor in place, the method assumes that it is
351
341
// / an unordered COO tensor.
352
342
void sortInPlace () {
@@ -556,58 +546,10 @@ class SparseTensorStorage final : public SparseTensorStorageBase {
556
546
return -1u ;
557
547
}
558
548
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
-
606
549
std::vector<std::vector<P>> positions;
607
550
std::vector<std::vector<C>> coordinates;
608
551
std::vector<V> values;
609
552
std::vector<uint64_t > lvlCursor;
610
- SparseTensorCOO<V> *coo;
611
553
};
612
554
613
555
// ===----------------------------------------------------------------------===//
@@ -661,7 +603,6 @@ SparseTensorStorage<P, C, V>::SparseTensorStorage(
661
603
: SparseTensorStorage(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes,
662
604
dim2lvl, lvl2dim) {
663
605
assert (!lvlCOO || lvlRank == lvlCOO->getRank ());
664
- coo = lvlCOO;
665
606
// Provide hints on capacity of positions and coordinates.
666
607
// TODO: needs much fine-tuning based on actual sparsity; currently
667
608
// we reserve position/coordinate space based on all previous dense
0 commit comments