[mlir][tensor] Extend reshape utils.
authorStephan Herhut <herhut@google.com>
Mon, 14 Feb 2022 16:46:35 +0000 (17:46 +0100)
committerStephan Herhut <herhut@google.com>
Fri, 18 Feb 2022 08:57:39 +0000 (09:57 +0100)
commita43f7d6d76984ddae4a5e5e0bebf82ee2edebabb
tree102af50cd788ef8816d480158383a4bb1852718b
parent35baa26747b0033afac15d7989bc2100b251412c
[mlir][tensor] Extend reshape utils.

This change changes the handling of trailing dimensions with unknown
extent. Users of the changessociationIndicesForReshape helper should
see benefits when transforming reshape like operations into
expand/collapse pairs if the higher-rank type has trailing unknown
dimensions.

The motivating example is a reshape from tensor<16x1x?xi32> to
tensor<16xi32> that can be modeled as collapsing the three dimensions.

Differential Revision: https://reviews.llvm.org/D119730
mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
mlir/test/Dialect/Tensor/canonicalize.mlir