This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add SubViewOp::getOrCreateRanges and fix folding pattern
ClosedPublic

Authored by nicolasvasilache on May 11 2020, 7:15 PM.

Details

Summary

The existing implementation of SubViewOp::getRanges relies on all
offsets/sizes/strides to be dynamic values and does not work in
combination with canonicalization. This revision adds a
SubViewOp::getOrCreateRanges to create the missing constants in the
canonicalized case.

This allows reactivating the fused pass with staged pattern
applications.

However another issue surfaces that the SubViewOp verifier is now too
strict to allow folding. The existing folding pattern is turned into a
canonicalization pattern which rewrites memref_cast + subview into
subview + memref_cast.

The transform-patterns-matmul-to-vector can then be reactivated.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald Transcript

Drop spurious methods in Ops.td.

Harbormaster completed remote builds in B56391: Diff 263338.
mravishankar resigned from this revision.May 11 2020, 11:07 PM

Not familiar with the folding patterns for memref cast as much, but it seems fine to me. Please let someone with more knowledge of this to review it as well.

mlir/lib/Dialect/StandardOps/IR/Ops.cpp
2574

Nit: this name is misleading. How about SubViewOpConstantArgumentFolder ?

ftynse requested changes to this revision.May 12 2020, 1:39 AM
ftynse added inline comments.
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
2493

Please add documentation.

2503

I don't understand why you do std::prev, and there is no comment to help. Normally, all standard algorithms exclude the upper bound, so this would exclude the element _before_ idx-th.

2709

Could you please explain _how_ is it rewritten?

2714

This needs a test.

This revision now requires changes to proceed.May 12 2020, 1:39 AM
nicolasvasilache marked an inline comment as done.

Rebase.

Harbormaster completed remote builds in B56530: Diff 263593.
ftynse accepted this revision.May 13 2020, 12:59 AM
This revision is now accepted and ready to land.May 13 2020, 12:59 AM
This revision was automatically updated to reflect the committed changes.