[mlir] Linalg: ensure tile-and-pad always creates padding as requested
authorAlex Zinenko <zinenko@google.com>
Fri, 24 Sep 2021 16:26:19 +0000 (18:26 +0200)
committerAlex Zinenko <zinenko@google.com>
Fri, 24 Sep 2021 16:40:13 +0000 (18:40 +0200)
commit5988a3b7a09126aff982944ecb36f533c450388e
treec7f6073ccdc90ed09ad31ab17dcc02ff1118b98b
parent3b0240e6c89d9201430ee83b09fe7c94256e8838
[mlir] Linalg: ensure tile-and-pad always creates padding as requested

Initially, the padding transformation and the related operation were only used
to guarantee static shapes of subtensors in tiled operations. The
transformation would not insert the padding operation if the shapes were
already static, and the overall code generation would actively remove such
"noop" pads. However, this transformation can be also used to pack data into
smaller tensors and marshall them into faster memory, regardless of the size
mismatches. In context of expert-driven transformation, we should assume that,
if padding is requested, a potentially padded tensor must be always created.
Update the transformation accordingly. To do this, introduce an optional
`packing` attribute to the `pad_tensor` op that serves as an indication that
the padding is an intentional choice (as opposed to side effect of type
normalization) and should be left alone by cleanups.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D110425
mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/test/Dialect/Linalg/canonicalize.mlir
mlir/test/Dialect/Linalg/tile-and-pad-tensors.mlir