This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] implement sparse2sparse reshaping (expand/collapse)
ClosedPublic

Authored by aartbik on Jul 8 2022, 9:27 PM.

Details

Summary

A previous revision implemented expand/collapse reshaping between
dense and sparse tensors for sparse2dense and dense2sparse since those
could use the "cheap" view reshape on the already materialized
dense tensor (at either the input or output side), and do some
reshuffling from or to sparse. The dense2dense case, as always,
is handled with a "cheap" view change.

This revision implements the sparse2sparse cases. Lacking any "view"
support on sparse tensors this operation necessarily has to perform
data reshuffling on both ends.

Tracker for improving this:
https://github.com/llvm/llvm-project/issues/56477

Diff Detail

Event Timeline

aartbik created this revision.Jul 8 2022, 9:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2022, 9:27 PM
aartbik requested review of this revision.Jul 8 2022, 9:27 PM
bixia added inline comments.Jul 11 2022, 10:44 AM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
495

s/as is/as the value is/ ?

568–606

Can we use a template class that takes a tensor dialect reshape op to avoid repeating the code?

(should we in the future add this?!)

Can you file a bug/feature-request for this (and post the link)? This is definitely something we should do, so having the github issue number would make it easier to track progress/discussion/etc

aartbik edited the summary of this revision. (Show Details)Jul 11 2022, 12:15 PM
aartbik updated this revision to Diff 443716.Jul 11 2022, 12:18 PM
aartbik marked 2 inline comments as done.

addressed comments

bixia accepted this revision.Jul 11 2022, 1:55 PM
This revision is now accepted and ready to land.Jul 11 2022, 1:55 PM
aartbik updated this revision to Diff 443752.Jul 11 2022, 2:09 PM

rebased with main

aartbik updated this revision to Diff 443760.Jul 11 2022, 2:31 PM

use getSrc() and getResult() instead of src() and result()
[to be consistent with direction Jacques was taking]

This revision was landed with ongoing or failed builds.Jul 11 2022, 2:49 PM
This revision was automatically updated to reflect the committed changes.

Still have to read through genSparse2SparseReshape, but other than that everything LGTM

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
401

It'd be a bit cleaner to float this definition out, so it can be reused for here, the next loop, and the start = end; at the end of the for-loop