[mlir][Linalg] Use reify for padded op shape derivation.
authorNicolas Vasilache <nicolas.vasilache@gmail.com>
Fri, 10 Sep 2021 07:12:14 +0000 (07:12 +0000)
committerNicolas Vasilache <nicolas.vasilache@gmail.com>
Mon, 13 Sep 2021 11:54:59 +0000 (11:54 +0000)
commitb01d223faf8ac4d62baea8a0e1d7b6cab7938118
tree3cb27b228caf5fb21064e29ca3b4867429e75e8a
parent0213d7ec0c501414d12020737fdc47e47e4392d9
[mlir][Linalg] Use reify for padded op shape derivation.

Previously, we would insert a DimOp and rely on later canonicalizations.
Unfortunately, reifyShape kind of rewrites are not canonicalizations anymore.
This introduces undesirable pass dependencies.

Instead, immediately reify the result shape and avoid the DimOp altogether.
This is akin to a local folding, which avoids introducing more reliance on `-resolve-shaped-type-result-dims` (similar to compositions of `affine.apply` by construction to avoid chains of size > 1).

It does not completely get rid of the reliance on the pass as the process is merely local: calling the pass may still be necessary for global effects. Indeed, one of the tests still requires the pass.

Differential Revision: https://reviews.llvm.org/D109571
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/test/Dialect/Linalg/tile-pad-tensor-op.mlir