This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] replace stack-based access pattern with dyn-alloc
ClosedPublic

Authored by aartbik on Apr 6 2022, 1:43 PM.

Details

Summary

Rationale:
Allocating the temporary buffers for access pattern expansion on the stack
(using alloca) is a bit too agressive, since it easily runs out of stack space
for large enveloping tensor dimensions. This revision changes the dynamic
allocation of these buffers with explicit alloc/dealloc pairs.

Diff Detail

Event Timeline

aartbik created this revision.Apr 6 2022, 1:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2022, 1:43 PM
aartbik requested review of this revision.Apr 6 2022, 1:43 PM
aartbik added inline comments.Apr 6 2022, 1:58 PM
mlir/test/Dialect/SparseTensor/conversion.mlir
463–464

Note that the original test was never even executed (no CHECK tags) ;-)

aartbik updated this revision to Diff 421010.Apr 6 2022, 2:22 PM

keep %added alive too

aartbik updated this revision to Diff 421015.Apr 6 2022, 2:41 PM

inlined helper method, does not save anything

bixia accepted this revision.Apr 6 2022, 4:05 PM
This revision is now accepted and ready to land.Apr 6 2022, 4:05 PM
wrengr added a comment.Apr 6 2022, 4:07 PM

I'll have to take a closer look at the new test, but otherwise everything lgtm

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
816–821

Why not do something like this instead?

mlir/test/Dialect/SparseTensor/conversion.mlir
480–488

Why have the numbers after the .*? We don't do that elsewhere so...

wrengr accepted this revision.Apr 6 2022, 4:10 PM

Modulo my comments, lgtm

mlir/test/Dialect/SparseTensor/sparse_expand.mlir
27

Why name %[[D]] if not using it anywhere, especially since it doesn't appear in the CHECK-CONVERT test

aartbik marked an inline comment as done.Apr 6 2022, 4:13 PM
aartbik added inline comments.
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
816–821

Because that is semantically different. If we are already at top level, that would set parent to the "func" and then exit the loop. In the original, we exit the loop, but at original level.

mlir/test/Dialect/SparseTensor/conversion.mlir
480–488

The joy of CHECK-SAME :-)

Normally CHECK is a bit smarter by using context,
However, since we have two times "memref<?xi1>," in the pattern, the first
CHECK-SAME would use the .* all the way to the longest match!

You see the use of numbers at a few other places to avoid this.

aartbik marked 2 inline comments as done.Apr 6 2022, 4:14 PM
aartbik added inline comments.
mlir/test/Dialect/SparseTensor/sparse_expand.mlir
27

Yeah, fair enough. Replaced with anonymous pattern.

aartbik updated this revision to Diff 421040.Apr 6 2022, 4:21 PM
aartbik marked an inline comment as done.

addressed comments

This revision was landed with ongoing or failed builds.Apr 6 2022, 5:11 PM
This revision was automatically updated to reflect the committed changes.