[mlir][sparse] add asCOO() functionality to sparse tensor object
authorAart Bik <ajcbik@google.com>
Thu, 26 Aug 2021 04:01:12 +0000 (21:01 -0700)
committerAart Bik <ajcbik@google.com>
Thu, 26 Aug 2021 04:50:39 +0000 (21:50 -0700)
commit6b26857dbfc1f8675382f5510f9ca02dad62729a
treef02c62b3c53301a2d94396e0eb1ed62a95df10e8
parenta45d72e0247d080eb9437736bb6cadfc27e4c065
[mlir][sparse] add asCOO() functionality to sparse tensor object

This prepares general sparse to sparse conversions. The code that
needs to be generated using this new feature is now simply:

(1) coo = sparse_tensor_1->asCOO();          // source format1
(2) sparse_tensor_2 = newSparseTensor(coo);  // destination format2

By using COO as an intermediate, we can do *all* conversions without
having to implement the full O(N^2) conversion matrix. Note that we
can always improve particular conversions individually if a faster
solution is required.

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D108681
mlir/lib/ExecutionEngine/SparseUtils.cpp