[mlir][Linalg] Add a transform.structured.pack operation
authorNicolas Vasilache <nicolas.vasilache@gmail.com>
Mon, 16 Jan 2023 17:06:14 +0000 (09:06 -0800)
committerNicolas Vasilache <nicolas.vasilache@gmail.com>
Tue, 17 Jan 2023 13:14:50 +0000 (05:14 -0800)
commit5443743ca1874acfe2d5654fedd4a0c0bed6777e
tree32c587e13c3293375f8e1ceaa7829f410f80efe6
parent78ba3e785cda23aa3bdf015988925e7f340f077a
[mlir][Linalg] Add a transform.structured.pack operation

This revision introduces a `transform.structured.pack` operation to
transform any Linalg operation to a higher-dimensional Linalg operation on
packed operands.

`tensor.pack` (resp. `tensor.unpack`) operations are inserted for the operands
(resp. results) that need to be packed (resp. unpacked) according to the
`packed_sizes` specification.

At the moment, the packing operation always pads with `getZeroAttr` which will
need to be adjusted depending on the consumers.

Packing is limited to those dimensions that are indexed only by AffineDimExpr.
Packing more advanced indexings requires modular arithmetic that is outside the
scoped of a `linalg.generic` at the moment.

Differential Revision: https://reviews.llvm.org/D141860
mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
mlir/test/Dialect/Linalg/transform-op-pack.mlir [new file with mode: 0644]