[mlir][sparse] compute allocation size_hint
authorAart Bik <ajcbik@google.com>
Sat, 4 Feb 2023 01:26:04 +0000 (17:26 -0800)
committerAart Bik <ajcbik@google.com>
Mon, 6 Feb 2023 22:08:53 +0000 (14:08 -0800)
commit3bd82f30dcc25533de1ff900a704efa77a6951da
tree1ff2121be35e654e28b15e0c8118858818d8b4d4
parent1b80ccba0f9bb86eabeeb0c32876eae2088eafb8
[mlir][sparse] compute allocation size_hint

This adds the hint to a number of tensor allocations in codegens,
shaving off quite some time from e.g. reading in sparse matrices
due to zero-reallocation scheme. Note that we can probably provide
hints on all allocations, and refine the heuristics that use them
for general tensors.

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D143309
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
mlir/test/Dialect/SparseTensor/rewriting_for_codegen.mlir