[mlir][linalg] Fix `FoldInitTensorWithDimOp` if dim(init_tensor) is static.
authorAlexander Belyaev <pifon@google.com>
Fri, 3 Sep 2021 17:06:15 +0000 (19:06 +0200)
committerAlexander Belyaev <pifon@google.com>
Mon, 6 Sep 2021 08:47:26 +0000 (10:47 +0200)
commit58c188507f724feee181018bfb6a330be2c6ac9a
tree9b27e5614687ae3da8b26e429859a83cf002e01a
parent915a8bb5ee596f38df0bc72564d57034fe57ae3c
[mlir][linalg] Fix `FoldInitTensorWithDimOp` if dim(init_tensor) is static.

It looks like it was a typo. Instead of `*maybeConstantIndex`,
`initTensorOp.getStaticSize(*maybeConstantIndex)` should be used to access the
dim size of the tensor. There is a test for that in `canonicalize.mlir`, but it
was working correctly because `ReplaceStaticShapeDims` was canonicalizing DimOp
before `FoldInitTensorWithDimOp`. So, to make the patterns more "orthogonal",
this case is disabled.

Differential Revision: https://reviews.llvm.org/D109247
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp