This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Support packing external data into arbitrary sparse tensor encoding.
ClosedPublic

Authored by Peiming on May 18 2023, 3:54 PM.

Details

Summary

We previously only support packing two array (values and coordinates) into COO tensors.
This patch allows packing inputs into arbitrary sparse tensor format.

It also deletes the "implicit" data canonicalization performed inside sparse compiler,
but instead requires users to canonicalize the data before passing it to the sparse compiler.

Diff Detail

Event Timeline

Peiming created this revision.May 18 2023, 3:54 PM
Herald added a project: Restricted Project. · View Herald Transcript
Peiming requested review of this revision.May 18 2023, 3:54 PM
aartbik added inline comments.May 18 2023, 4:23 PM
mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h
113

to query whether (no "the")

115

hmm, I am not sure if I find these convenience methods more clear than just spelling them out

mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
63–78

values refers to one array (with values)
levels refers to per-dimension arrays (with coord/pos)

I would rephrase this as

Pack the values and per-level coordinate or position arrays ...

to make it more clear, since the plural in the text refers to different things

mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
69

I found the original much better because it spelled out all cases ending with L75 on the assert.
If we use these kind of convenience utils, this seems less clear

920

do we need the this?

wrengr added inline comments.May 18 2023, 4:40 PM
mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h
115

In addition to what we discussed in the chat, these new predicates should also be moved off to Enum.h to live with the other DLT predicates. Also, they should be made constexpr rather than merely inline

wrengr added inline comments.May 18 2023, 4:42 PM
mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
63–78

+1 to Aart's rephrasing

Peiming updated this revision to Diff 523604.May 18 2023, 4:56 PM
Peiming marked 2 inline comments as done.

address comments.

Peiming marked 4 inline comments as done.May 18 2023, 4:57 PM
Peiming added inline comments.
mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h
115

Change the code per offline discussion.

Peiming updated this revision to Diff 523606.May 18 2023, 5:03 PM

address comments.

Peiming marked an inline comment as done.May 18 2023, 5:03 PM
aartbik accepted this revision.May 19 2023, 10:21 AM
aartbik added inline comments.
mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
69

Admitably, this looks elegant

the only thing that I liked better in the original is that it ended with an assert if all cases are covered, that is harder to do now

This revision is now accepted and ready to land.May 19 2023, 10:21 AM