This is an archive of the discontinued LLVM Phabricator instance.

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

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



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

%0 => %arg0


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


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


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?


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.


asserting was actually fine


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.