[linalg][fusion] Disallow fusion when it would create an invalid expand_shape
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 4 Jan 2022 15:52:44 +0000 (16:52 +0100)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 18 Jan 2022 22:44:14 +0000 (23:44 +0100)
commitff5de8a9e0e5cb7f82b945486b784407f6aab8fe
tree756eb37ba3e597b2fe6ced7bdabb550e4563acb4
parentf100bedb036276f6a1c73b6467fe7585c1b20292
[linalg][fusion] Disallow fusion when it would create an invalid expand_shape

The input type of a linalg.generic can be less dynamic than its output
type. If this is the case moving a reshape across the generic op would
create invalid IR, as expand_shape cannot expand arbitrary dynamic
dimensions.

Check that the reshape is actually valid before creating the
expand_shape. This exposes the existing verification logic in reshape
utils and removes the incomplete custom implementation in fusion.

Differential Revision: https://reviews.llvm.org/D116600
mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h
mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
mlir/test/Dialect/Linalg/reshape_fusion.mlir