[MLIR][Tensor] Canonicalize expand/collapse_shape of splat to splat
authorliqinweng <Liqin.Weng@streamcomputing.com>
Wed, 4 Jan 2023 21:05:57 +0000 (13:05 -0800)
committerRob Suderman <suderman@google.com>
Wed, 4 Jan 2023 21:07:55 +0000 (13:07 -0800)
commit5c18ae3135d1ff4b9e554480da78bc93e35ef00a
treef24a7847cbff2203be90e3d91235dcb0840aeac3
parent63d31a4d15aa5f7fe4a6c504bba9944e5b0afc6a
[MLIR][Tensor] Canonicalize expand/collapse_shape of splat to splat

Collapsing / expanding a splatted value can be replaced with a single `tensor.splat` operation. Replace
these cases with a simple `tensor.splat` operation.

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D140552
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
mlir/test/Dialect/Tensor/canonicalize.mlir