This is a followup to D128847. The AffineMap::getPermutedPosition method performs a linear scan of the map, thus the previous implementation had asymptotic complexity of O(|topSort| * |m|). This change reduces that to O(|topSort| + |m|).
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp | ||
---|---|---|
119 | why do you compute the invSz and permSz twice? | |
122 | Perhaps, in the long run, we should push such logic into AffineMap for permutations, so that getPermutedPosition is O(1) again, or we get a direct inverse back, because the original code is easier to read than the optimized code (and it would benefit all clients). Maybe add a TODO for that (bonus points for also making it happen ;-) |
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp | ||
---|---|---|
119 | Each one is only computed once? I use them separately because of the mismatch worry. I considered asserting they were the same, but wasn't sure if that was actually an invariant or not (it's been too ling since I looked at this code). I'll add the assertion | |
122 | +1. I'll write up an RFC for that |
why do you compute the invSz and permSz twice?
just use the one below, and assert on it if you are worried about a mismatch
(although that is done at many other places too already)