[mlir][utils] Fix invalid reshapes in ComposeCollapseOfExpandOp
authorMatthias Springer <springerm@google.com>
Wed, 23 Nov 2022 10:56:07 +0000 (11:56 +0100)
committerMatthias Springer <springerm@google.com>
Wed, 23 Nov 2022 12:52:00 +0000 (13:52 +0100)
commitf2d91a7ae1172d4cf8f06a0204a2dc64a0d68ea4
treed6acf2cd5f01210356ad14daa9dd8920a22ebc92
parent19ab2a671eb32bede5a0bf686aebf3c6838848e3
[mlir][utils] Fix invalid reshapes in ComposeCollapseOfExpandOp

Do not generate CollapseShapeOps/ExpandShapeOps that have the same source and result shape. Generate casts instead. Such reshapes became invalid with D138498.

Differential Revision: https://reviews.llvm.org/D138557
mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
mlir/test/Dialect/MemRef/canonicalize.mlir
mlir/test/Dialect/Tensor/canonicalize.mlir