[mlir][Linalg] Disable fusion of reshape with elementwise ops for purely dynamic...
authorMaheshRavishankar <ravishankarm@google.com>
Thu, 6 Jan 2022 18:31:53 +0000 (10:31 -0800)
committerMaheshRavishankar <ravishankarm@google.com>
Thu, 6 Jan 2022 18:32:24 +0000 (10:32 -0800)
commit4317a3dfad52ee2830d686c6f3a9ef8011f7e6ad
treebcffe73380b2e312adba60eb6d05204c6271f7ad
parent0b5340acb758e2d89acf801ebf77106e3a32f03f
[mlir][Linalg] Disable fusion of reshape with elementwise ops for purely dynamic cases.

`tensor.collapse_shape` op when fused with a consumer elementwise
`linalg.generic` operation results in creation of tensor.expand_shape
ops. In purely dynamic cases this can end up with a dynamic dimensions
being expanded to more than one dynamic dimension. This is disallowed
by the semantics of `tensor.expand_shape` operation. (While the
transformation is itself correct, its a gap in the specification of
`tensor.expand_shape` that is the issue). So disallow fusions which
result in such a pattern.

Differential Revision: https://reviews.llvm.org/D116703
mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
mlir/test/Dialect/Linalg/reshape_fusion.mlir