[mlir][sparse] Sparse reduction in lex order no longer produces dense output
authorJim Kitchen <jim22k@gmail.com>
Fri, 10 Feb 2023 19:08:49 +0000 (13:08 -0600)
committerJim Kitchen <jim22k@gmail.com>
Fri, 10 Feb 2023 19:09:28 +0000 (13:09 -0600)
commit81d0d2b2a068eae9692b9317bceaaea252c1bbf8
tree93d1f287b2fbda21ef52f3ef0fc873d025dba7d5
parentae2d8b49713d8987124ba5eee41b4b29191bbd56
[mlir][sparse] Sparse reduction in lex order no longer produces dense output

Previously, when performing a reduction on a sparse tensor, the result
would be different depending on iteration order. For expanded access pattern,
an empty row would contribute no entry in the output. For lex ordering, the
identity would end up in the output.

This code changes that behavior and keeps track of whether any entries were
actually reduced in lex ordering, making the output consistent between the
two iteration styles.

Differential Revision: https://reviews.llvm.org/D142050
mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.cpp
mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.h
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
mlir/test/Dialect/SparseTensor/sparse_affine.mlir
mlir/test/Dialect/SparseTensor/sparse_out.mlir
mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reduce_custom.mlir