[mlir][sparse] Avoid values buffer reallocation for annotated all dense tensors.
authorbixia1 <bixia@google.com>
Wed, 11 Jan 2023 17:06:42 +0000 (09:06 -0800)
committerbixia1 <bixia@google.com>
Thu, 12 Jan 2023 00:31:07 +0000 (16:31 -0800)
commitb78b547371253118b7ab04a12653c66878466d2b
treeb20f314a2d14d21204c45fd40520552112d46d77
parentc6b38f491fb22eb5705bf30fed1ce4a14416e8fe
[mlir][sparse] Avoid values buffer reallocation for annotated all dense tensors.

Previously, we rely on the InsertOp to gradually increase the size of the
storage for all sparse tensors. We now allocate the full size values buffer
for annotated all dense tensors when we first allocate the tensor. This avoids
the cost of gradually increasing the buffer and allows accessing the values
buffer as if it were a dense tensor.

Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D141516
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
mlir/test/Dialect/SparseTensor/codegen.mlir