This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Fix rewriting for convert op and concatenate op.
ClosedPublic

Authored by bixia on Nov 15 2022, 12:07 PM.

Details

Summary

Fix a problem in convert op rewriting where it used the original index for
ToIndicesOp.

Extend the concatenate op rewriting to handle dense destination and dynamic
shape destination.

Make the concatenate op integration test run on the codegen path.

Diff Detail

Event Timeline

bixia created this revision.Nov 15 2022, 12:07 PM
Herald added a project: Restricted Project. · View Herald Transcript
bixia requested review of this revision.Nov 15 2022, 12:07 PM
Peiming added inline comments.Nov 15 2022, 12:13 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
438

I think concatenate verifier ensures that only concatenate dimension can be dynamic.

So probably you do not need to iterate over shape here.

Peiming added inline comments.Nov 15 2022, 12:15 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
438

Oh, I am wrong. all the input are statically sized, only output tensor can be dynamically sized...

Peiming added inline comments.Nov 15 2022, 12:19 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
435

nit: I learned this from Alex, who suggest me not specify the number of stack elements in smallvector (unless you have strong reasons for it), maybe we should start to follow the new practice.

Peiming added inline comments.Nov 15 2022, 12:21 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
441

Maybe you should call createOrFoldDimOp instead?

bixia updated this revision to Diff 475562.Nov 15 2022, 1:25 PM
bixia marked 2 inline comments as done.

Use createOrFoldDimOp and remove N from SmallVector<>.

aartbik added inline comments.Nov 15 2022, 1:26 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
435

Yeah, in the past we used 4 for things that typically hold a rank, but I am perfectly okay letting the CalculateSmallVectorDefaultInlinedElements() do its magic.

Peiming accepted this revision.Nov 15 2022, 1:29 PM
This revision is now accepted and ready to land.Nov 15 2022, 1:29 PM