OSDN Git Service

[mlir][Linalg] Add verification checks to disallow illegal reshape ops.
authorMaheshRavishankar <ravishankarm@google.com>
Fri, 8 Jan 2021 18:52:26 +0000 (10:52 -0800)
committerMaheshRavishankar <ravishankarm@google.com>
Fri, 8 Jan 2021 18:54:46 +0000 (10:54 -0800)
commitec13f6c3e56952c94909a36a590c679a6a57a046
treeacd592135dd0509d04730aaf83a1756337cf0c43
parentd9ce31ae7d1fc68de0ea1535fd25ef84e69aeb07
[mlir][Linalg] Add verification checks to disallow illegal reshape ops.

The existing verification of reshape ops in linalg (linalg.reshape and
linalg.tensor_reshape) allows specification of illegal ops, where
- A dynamic dimension is expanded into multiple dynamic
  dimensions. This is ill-specified.
- A static dimension is expanded into dynamic dimension or viceversa,
- The product of extents of the static dimensions in the expanded type
  doesnt match the static dimension of the collapsed type.
Making all of these illegal. This also implies that some pessimization
in canonicalization due to incomplete semantics of the operation can
be dropped.

Differential Revision: https://reviews.llvm.org/D93724
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/test/Dialect/Linalg/canonicalize.mlir
mlir/test/Dialect/Linalg/invalid.mlir
mlir/test/Dialect/Linalg/roundtrip.mlir