[Mlir-commits] [mlir] b04b757 - [mlir][sparse] Rename the public SparseTensorStorage::asCOO to toCOO
wren romano
llvmlistbot at llvm.org
Tue Aug 31 15:44:44 PDT 2021
Author: wren romano
Date: 2021-08-31T15:44:34-07:00
New Revision: b04b757a8efcb194f2a3838819e9c370f71199c8
URL: https://github.com/llvm/llvm-project/commit/b04b757a8efcb194f2a3838819e9c370f71199c8
DIFF: https://github.com/llvm/llvm-project/commit/b04b757a8efcb194f2a3838819e9c370f71199c8.diff
LOG: [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
Added:
Modified:
mlir/lib/ExecutionEngine/SparseUtils.cpp
Removed:
################################################################################
diff --git a/mlir/lib/ExecutionEngine/SparseUtils.cpp b/mlir/lib/ExecutionEngine/SparseUtils.cpp
index 840a674fe1223..51195b03018ef 100644
--- a/mlir/lib/ExecutionEngine/SparseUtils.cpp
+++ b/mlir/lib/ExecutionEngine/SparseUtils.cpp
@@ -217,7 +217,7 @@ class SparseTensorStorage : public SparseTensorStorageBase {
/// 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 @@ class SparseTensorStorage : public SparseTensorStorageBase {
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 @@ class SparseTensorStorage : public SparseTensorStorageBase {
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); \
}
More information about the Mlir-commits
mailing list