diff --git a/mlir/lib/ExecutionEngine/SparseUtils.cpp b/mlir/lib/ExecutionEngine/SparseUtils.cpp --- a/mlir/lib/ExecutionEngine/SparseUtils.cpp +++ b/mlir/lib/ExecutionEngine/SparseUtils.cpp @@ -184,6 +184,10 @@ assert(sparsity[d] == kDense && "singleton not yet supported"); } } + // Prepare sparse pointer structures for all dimensions. + for (uint64_t d = 0, r = getRank(); d < r; ++d) + if (sparsity[d] == kCompressed) + pointers[d].push_back(0); // Then setup the tensor. traverse(tensor, sparsity, 0, nnz, 0); } @@ -224,9 +228,6 @@ values.push_back(lo < hi ? elements[lo].value : 0); return; } - // Prepare a sparse pointer structure at this dimension. - if (sparsity[d] == kCompressed && pointers[d].empty()) - pointers[d].push_back(0); // Visit all elements in this interval. uint64_t full = 0; while (lo < hi) {