[MLIR][Linalg] Change insertion point for `bubbleUpPackOpThroughElemGenericOp`
authorLorenzo Chelini <l.chelini@icloud.com>
Fri, 17 Feb 2023 10:00:07 +0000 (11:00 +0100)
committerLorenzo Chelini <l.chelini@icloud.com>
Thu, 23 Feb 2023 08:24:54 +0000 (09:24 +0100)
commit1c2280264058c26aee2bcd8fe4ca90d0f843cc5c
treecb00a6a7eca66d17451ad3edf15560d5c1250fc2
parent3064d6b7b062cca348fd5528f3a77bff7df7e5f9
[MLIR][Linalg] Change insertion point for `bubbleUpPackOpThroughElemGenericOp`

Currently, the insertion point for `bubbleUpPackOpThroughElemGenericOp`
is after the tensor.pack this means that the new generic will be created
right after the tensor.pack. This is inconvenient because we are moving
the position of the generic; the idea is to move pack/unpack around, not
linalg.generics. This PR changes the insertion point to preserve the
position of the generic.

Additionally, it restricts the pattern to fire if the generic has a
single user (`tensor.pack`) to avoid introducing recomputation.

Reviewed By: hanchung

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