This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] fix a bug in sparse2sparse reshape.
ClosedPublic

Authored by Peiming on Sep 8 2022, 1:48 PM.

Diff Detail

Event Timeline

Peiming created this revision.Sep 8 2022, 1:48 PM
Herald added a project: Restricted Project. · View Herald Transcript
Peiming requested review of this revision.Sep 8 2022, 1:48 PM
Peiming added inline comments.Sep 8 2022, 1:52 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
567

The reason why I change it to a template function is that I can use more meaningful op.getSrc() instead of op.getOperand()[0], but let me know if you prefer the previous one.

aartbik added inline comments.Sep 8 2022, 1:57 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
567

I am fine with the template, looks cleaner. But as discussed offline, the fact you can change this without hitting a test change probably indicates we are missing a test case ;-) Please see if you can find one.

Peiming added inline comments.Sep 8 2022, 2:34 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
567

I can't find one, it would be triggered when the dst tensor are always static shaped.

567

I can't find one, it would be triggered when the dst tensor are always static shaped.

Sorry, would NOT be triggered

aartbik added inline comments.Sep 8 2022, 5:16 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
575

note that this one sets the size to 0 for dynamic (used for new to simply verify that the static sizes are as expected), but for EmptyCOO that is not allowed

so should we assert on the dynamic size then?

766

yeah, much cleaner like this!

Peiming marked an inline comment as done.Sep 8 2022, 5:21 PM
Peiming added inline comments.
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
575

Or assert on the dstTp before calling it? I am not sure whether 0 is chose for some special purposes in other converters.

aartbik added inline comments.Sep 8 2022, 5:23 PM
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
575

yeah, you don't have to change the util, but just check for static shape prior to using it
(I think we will anyway assert in support lib for zero sizes other than when reading a tensor, but always good to be extra safe)

Peiming updated this revision to Diff 458927.Sep 8 2022, 5:29 PM

Address comments from Aart

Peiming marked 3 inline comments as done.Sep 8 2022, 5:29 PM
aartbik accepted this revision.Sep 8 2022, 5:30 PM

Ship it! Thanks for carefully looking at this.

This revision is now accepted and ready to land.Sep 8 2022, 5:30 PM
This revision was landed with ongoing or failed builds.Sep 8 2022, 5:32 PM
This revision was automatically updated to reflect the committed changes.