This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Fix hoist padding through scf.for iter_arg
ClosedPublic

Authored by nicolasvasilache on Apr 12 2023, 2:19 PM.

Details

Summary

Previously, hoisting through an iter_arg would mistakenly yield the unpadded value and
cast it to the padded value.

This was incorrect and resulted in out-of-bounds accesses.
The correct formulation is to yield the padded value and extract a smaller dynamic slice
out of it.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 2:19 PM
nicolasvasilache requested review of this revision.Apr 12 2023, 2:19 PM
qcolombet added inline comments.Apr 13 2023, 3:24 AM
mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp
756

%0 => %arg0

760

I'd add "return tensor::ExtractSliceOp when no rewrite happened".

763

What does packedTensor hold with respect to the rewrite in the comment?

813

We used to assert in this case.
Is it something we can reach now?
And if so could you add a test case for it?

835

Isn't that guaranteed by the fact that they both feed and use the same iter_arg?

qcolombet accepted this revision.Apr 13 2023, 3:33 AM
This revision is now accepted and ready to land.Apr 13 2023, 3:33 AM
nicolasvasilache marked 5 inline comments as done.

Address comments.

mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp
813

asserting was actually fine

835

Unfortunately no, so I went ahead and implemented a poor man's analysis.
In the future, this will be easier with a tensor.unpad op.

This revision was landed with ongoing or failed builds.Apr 13 2023, 5:25 AM
This revision was automatically updated to reflect the committed changes.