[MLIR] Propagate unpack through element-wise ops
authorLorenzo Chelini <l.chelini@icloud.com>
Tue, 31 Jan 2023 13:25:14 +0000 (14:25 +0100)
committerLorenzo Chelini <l.chelini@icloud.com>
Wed, 1 Feb 2023 08:11:28 +0000 (09:11 +0100)
commit6bb0ab0de039ddbcc70eafc549b50da7867fb617
treee9de50376ae4e3248db4fdacda62e0bf8d0f5fa7
parent95e49f5a74c9e79778a62cc58b15875613cf9e59
[MLIR] Propagate unpack through element-wise ops

Introduce `pushDownUnPackOpThroughElemGenericOp` to propagate producer
unpack operation through an element-wise linalg.generic operation. This
pattern complements `BubbleUpPackOpThroughElemGenericOp`. The general
idea is to bubble up tensor.pack as much as possible while pushing down
tensor.unpack as much as possible, and canonicalize away symmetrical
tensor.pack and tensor.unpack operations.

Currently, `pushDownUnPackOpThroughElemGenericOp` expects a single
tensor.unpack operation as the producer of one of the linalg.generic's
operands.

Reviewed By: hanchung

Differential Revision: https://reviews.llvm.org/D142523
mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
mlir/test/Dialect/Linalg/data-layout-propagation.mlir