This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Add verification checks to disallow illegal reshape ops.
ClosedPublic

Authored by mravishankar on Dec 22 2020, 12:23 PM.

Details

Summary

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.

Diff Detail

Event Timeline

mravishankar created this revision.Dec 22 2020, 12:23 PM
mravishankar requested review of this revision.Dec 22 2020, 12:23 PM

Updating stale comment

hanchung requested changes to this revision.Dec 23 2020, 5:23 AM

This patch also move "invalid" tests to roundtrip.mlir file, which is not related to patch description. Could we split it into two patches?

mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
1030

Remove one the.

1031–1032

[optional] I would add two more spaces for a) and b)

1033

s/collapes/collapsed

1036

Let's use OpTy for consistency.

This revision now requires changes to proceed.Dec 23 2020, 5:23 AM
mravishankar marked 3 inline comments as done.Dec 26 2020, 10:41 AM

This patch also move "invalid" tests to roundtrip.mlir file, which is not related to patch description. Could we split it into two patches?

Maybe, but my stack of CLs is already big. I would rather keep this one intact...

mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
1031–1032

Its indented w.r.t to 1), ....

This revision is now accepted and ready to land.Dec 28 2020, 11:02 AM