This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Shape] Canonicalize assume_all with one input and tensor_cast of constant_shape
ClosedPublic

Authored by bkramer on Dec 8 2020, 6:39 AM.

Details

Summary

This allows simplifying some more complicated shape expressions

Diff Detail

Event Timeline

bkramer created this revision.Dec 8 2020, 6:39 AM
bkramer requested review of this revision.Dec 8 2020, 6:39 AM
tpopp requested changes to this revision.Dec 8 2020, 6:46 AM
tpopp added a subscriber: tpopp.
tpopp added inline comments.
mlir/lib/Dialect/Shape/IR/Shape.cpp
277–279

I don't think you really need these comments.

mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
16

Do you actually need the AssumingAll predicate? I thought this would only match on AssumingAll with a single input. Do multiple inputs still get matched and stored as a list?

36

Should this be $ty?

mlir/test/Dialect/Shape/canonicalize.mlir
871

nit: new line after this line.

This revision now requires changes to proceed.Dec 8 2020, 6:46 AM
bkramer updated this revision to Diff 310190.Dec 8 2020, 7:17 AM
bkramer marked 4 inline comments as done.
  • Address comments
mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
16

Yes, $x is a list here, so we have to check the length.

36

No, this is working as intended (although a bit weird with the implicit type cast)

tpopp accepted this revision.Dec 8 2020, 7:27 AM
tpopp added inline comments.
mlir/test/Dialect/Shape/canonicalize.mlir
430–431

This needs to be updated to if more than one witness is not statically passing

This revision was not accepted when it landed; it landed in state Needs Review.Dec 8 2020, 8:07 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
herhut added inline comments.Dec 8 2020, 8:16 AM
mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
36

This only works if the consumer can accept the new type of $c. This would break for example if the consumer is a select operation.

%s0 = shape.const_shape [2] : tensor<?xindex>
%s1 = shape.const_shape [1] : tensor<1xindex>
%c = tensor_cast %s1 : tensor<1xindex> to tensor<?xindex>
%r = select %p %s0 %c : tensor<?xindex>