This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Vector] Add support for TupleGetOp folding through InsertSlicesOp and ExtractSlicesOp.
ClosedPublic

Authored by andydavis1 on Mar 26 2020, 3:07 PM.

Details

Summary

Add support for TupleGetOp folding through InsertSlicesOp and ExtractSlicesOp.
Vector-to-vector transformations for unrolling and lowering to hardware vectors
can generate chains of structured vector operations (InsertSlicesOp,
ExtractSlicesOp and ShapeCastOp) between the producer of a hardware vector
value and its consumer. Because InsertSlicesOp, ExtractSlicesOp and ShapeCastOp
are structured, we can track the location (tuple index and vector offsets) of
the consumer vector value through the chain of structured operations to the
producer, enabling a much more powerful producer-consumer fowarding of values
through structured ops and tuple, which in turn enables a more powerful
TupleGetOp folding transformation.

Diff Detail

Event Timeline

andydavis1 created this revision.Mar 26 2020, 3:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2020, 3:07 PM
rriddle retitled this revision from BEGIN_PUBLIC [MLIR][Vector] Add support for TupleGetOp folding through InsertSlicesOp and ExtractSlicesOp. to [MLIR][Vector] Add support for TupleGetOp folding through InsertSlicesOp and ExtractSlicesOp..Mar 26 2020, 3:24 PM
rriddle edited the summary of this revision. (Show Details)
rriddle added inline comments.Mar 26 2020, 3:28 PM
mlir/lib/Dialect/Vector/VectorTransforms.cpp
677

nit: -> /

677

Sorry, meant ///. (The formatting messed up here)

692

Please add a comment to this assert.

715

nit: Drop all trivial braces.

758

cast never returns null, did you intend to use dyn_cast here? Also, can you just merge these two predicates:

if (value.getType() == consumerVectorType)
   ...

?

mlir/lib/Dialect/Vector/VectorUtils.cpp
31

We should not be doing this inside of .cpp files. It should be using namespace mlir with the functions explicitly qualified.

https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions

aartbik added inline comments.Mar 26 2020, 4:25 PM
mlir/lib/Dialect/Vector/VectorTransforms.cpp
822

just curious, this is part of VectorTransforms explicitly now.

Does it make sense to do this as part of the TupleGetOp::fold() at some point?

mlir/test/Dialect/Vector/vector-transforms.mlir
317

I noticed I may have introduced this at L308 at some point, but in general it seems a bit cleaner to capture the argument

CHECK-SAME: %[[A:.*0]]: vector<2x4xf32>,
CHECK-SAME: %[[A:.*1]]: vector<2x4xf32>,
...

and then check for [[D]] in the return
(note that I use the 0,1 etc. in the end to avoid some ambiguities for same typed arguments)

347

same request

Nice foldings.

One request on my end, could we please beef up the test?
Atm the cases tested are: tupleIndex = -1, offsets = [4, 0], tupleIndex = -1, offsets = [0, 0] and tupleIndex >= 0, offsets = [0, 0].

Can you reshuffle things a bit so we get more: tupleIndex = x, offsets = [y, z] combinations tested?

andydavis1 marked 9 inline comments as done.Mar 27 2020, 8:57 AM

Thanks. I've addressed comments and will update with a new patch soon...

mlir/lib/Dialect/Vector/VectorTransforms.cpp
822

Perhaps. What are the tradeoffs of moving it to a fold method?

andydavis1 marked an inline comment as done.Mar 27 2020, 8:58 AM

addressing feedback

PTAL. Let me know if there are any more comments...Thanks!

aartbik accepted this revision.Mar 30 2020, 5:29 PM
This revision is now accepted and ready to land.Mar 30 2020, 5:29 PM
This revision was automatically updated to reflect the committed changes.