[MLIR] [TOSA]: Move reshape(reshape(x)) -> reshape(x) from canonicalization to fold
authorMatthias Gehre <matthias.gehre@xilinx.com>
Thu, 13 Jul 2023 06:53:47 +0000 (08:53 +0200)
committerMatthias Gehre <matthias.gehre@xilinx.com>
Mon, 17 Jul 2023 08:14:37 +0000 (10:14 +0200)
commit0ebb0503113e97eb14dc679f06bdc1d2e7296d54
tree00ab1a2acec9e7175cb41a8ee28cbdff3423d90e
parentfdf36c3d4b467a48b628c96cc7e34c2f4bf090da
[MLIR] [TOSA]: Move reshape(reshape(x)) -> reshape(x) from canonicalization to fold

reshape(reshape(x)) -> reshape(x) can be directly written as a fold instead of a canonicalization,
to help other passes cleanup while they work.

This initially broke ReshapeConverterExpand/Collapse, which relies on creating foldable reshapes and a carefully crafted
benefit priority of patterns.
I turned this into a single pattern on reshapes, which does expand and/or collapse as needed in one go.

Differential Revision: https://reviews.llvm.org/D155266
mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp
mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp