[mlir][sparse] auto-insertion of conversion to resolve cycles
authorAart Bik <ajcbik@google.com>
Wed, 29 Jun 2022 19:33:01 +0000 (12:33 -0700)
committerAart Bik <ajcbik@google.com>
Thu, 30 Jun 2022 01:28:18 +0000 (18:28 -0700)
commite057f25dee59e61b870595156656f90d015b859f
tree3e1f443c9e2e574ba8917c4bad8c4ad01a02028c
parentd129ac27e872e189363e3d8cd6bc4e2152cd73ec
[mlir][sparse] auto-insertion of conversion to resolve cycles

When the iteration graph is cyclic (even after several attempts using less and less constraints), the current sparse compiler bails out, and no rewriting hapens. However, this revision adds some new logic where the sparse compiler tries to find a single input sparse tensor that breaks the cycle, and then adds a proper sparse conversion operation. This way, more incoming kernels can be handled!

Note, the resulting code is not optimal (although it keeps more or less proper "sparse" complexity), and more improvements should be added (especially when the kernel directly yields without computation, such as the transpose example). However, handling is better than not handling ;-)

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D128847
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
mlir/test/Dialect/SparseTensor/sparse_transpose.mlir [new file with mode: 0644]
mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_transpose.mlir