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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
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. |
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>, and then check for [[D]] in the return | |
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?
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? |
nit: -> /