[mlir][sparse] refine heuristic for iteration graph topsort
authorAart Bik <ajcbik@google.com>
Wed, 1 Sep 2021 22:29:52 +0000 (15:29 -0700)
committerAart Bik <ajcbik@google.com>
Fri, 3 Sep 2021 15:37:15 +0000 (08:37 -0700)
commitb6d1a31c1b88227b38b3dad7b4430fa42516e82c
tree89e9682d0e2e4fd0e86acbaca75db54ad85faeb0
parent36895cd8d83f4333bcdd9ac02793be5468ff21cd
[mlir][sparse] refine heuristic for iteration graph topsort

The sparse index order must always be satisfied, but this
may give a choice in topsorts for several cases. We broke
ties in favor of any dense index order, since this gives
good locality. However, breaking ties in favor of pushing
unrelated indices into sparse iteration spaces gives better
asymptotic complexity. This revision improves the heuristic.

Note that in the long run, we are really interested in using
ML for ML to find the best loop ordering as a replacement for
such heuristics.

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D109100
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
mlir/test/Dialect/SparseTensor/sparse_2d.mlir