This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Add ExtractOp folding
ClosedPublic

Authored by nicolasvasilache on Jul 3 2020, 5:31 PM.

Details

Summary

This revision adds foldings for ExtractOp operations that come from previous InsertOp.
InsertOp have cumulative semantic where multiple chained inserts are necessary to produce the final value from which the extracts are obtained.
Additionally, TransposeOp may be interleaved and need to be tracked in order to follow the producer consumer relationships and properly compute positions.

Diff Detail

Event Timeline

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

nice to cleanup the IR in between!

mlir/lib/Dialect/Vector/VectorOps.cpp
651

at first glance, i was wondering why it is okay to keep going on insert operations, but then i realized that you either insert in exactly the same position, or otherwise a necessarily different position (very specific to InsertOp, where all subscripts are constant)

I feel you need to document this a bit more for clarity....

mlir/lib/IR/AffineMap.cpp
366

I would add this to the method documentation (if more are requested than available...), since it may be unexpected to get a map back with size < numResults

rriddle added inline comments.Jul 6 2020, 6:55 PM
mlir/lib/Dialect/Vector/VectorOps.cpp
591

Why is the position specified with an ArrayAttr and not something like DenseElementsAttr?

609

Can you add some continues to break up this control flow?

mlir/lib/IR/AffineMap.cpp
370

nit: Can you use llvm::seq here instead?

nicolasvasilache marked 7 inline comments as done.Jul 7 2020, 8:59 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/Vector/VectorOps.cpp
591

Keeping this for a separate revision if you don't mind, there are multiple places that could benefit from an update.

651

Add more comments, should be clearer with the CF reorg,

nicolasvasilache marked 2 inline comments as done.

Address review.

aartbik accepted this revision.Jul 7 2020, 10:44 AM

Two comments, but good to go after that.

mlir/include/mlir/IR/AffineMap.h
185

typo: tihs -> this

mlir/lib/Dialect/Vector/VectorOps.cpp
590

nit: now that you have the continue, you no longer need this conditionally assigned "candidate", but can just push the transposeOp.vector() and insertOp.dest() into the branches below...

This revision is now accepted and ready to land.Jul 7 2020, 10:44 AM
nicolasvasilache marked 2 inline comments as done.

Last nits

This revision was automatically updated to reflect the committed changes.