[mlir][sparse] Rename the public SparseTensorStorage::asCOO to toCOO

Trying to reduce confusion by having the name of the public method match that of the private method for handling the recursion.  Also adding some comments to SparseTensorStorage::fromCOO to help clarify what the recursive calls are doing in the dense case.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D108954
This commit is contained in:
wren romano 2021-08-30 16:47:09 -07:00
parent befb384484
commit b04b757a8e
1 changed files with 7 additions and 2 deletions

View File

@ -217,7 +217,7 @@ public:
/// Returns this sparse tensor storage scheme as a new memory-resident
/// sparse tensor in coordinate scheme with the given dimension order.
SparseTensor<V> *asCOO(uint64_t *perm) {
SparseTensor<V> *toCOO(uint64_t *perm) {
// Restore original order of the dimension sizes and allocate coordinate
// scheme with desired new ordering specified in perm.
uint64_t size = getRank();
@ -272,6 +272,9 @@ private:
if (sparsity[d] == kCompressed) {
indices[d].push_back(idx);
} else {
// For dense storage we must fill in all the zero values between
// the previous element (when last we ran this for-loop) and the
// current element.
for (; full < idx; full++)
fromCOO(tensor, sparsity, 0, 0, d + 1); // pass empty
full++;
@ -284,6 +287,8 @@ private:
if (sparsity[d] == kCompressed) {
pointers[d].push_back(indices[d].size());
} else {
// For dense storage we must fill in all the zero values after
// the last element.
for (uint64_t sz = tensor->getSizes()[d]; full < sz; full++)
fromCOO(tensor, sparsity, 0, 0, d + 1); // pass empty
}
@ -495,7 +500,7 @@ char *getTensorFilename(uint64_t id) {
else if (action == 2) \
return SparseTensor<V>::newSparseTensor(asize, sizes, perm); \
else \
return static_cast<SparseTensorStorage<P, I, V> *>(ptr)->asCOO(perm); \
return static_cast<SparseTensorStorage<P, I, V> *>(ptr)->toCOO(perm); \
return SparseTensorStorage<P, I, V>::newSparseTensor(tensor, sparsity, \
perm); \
}