This is an archive of the discontinued LLVM Phabricator instance.

[mlir][VectorOps] Implement insert_strided_slice conversion
ClosedPublic

Authored by nicolasvasilache on Jan 6 2020, 10:49 PM.

Details

Summary

This diff implements the progressive lowering of insert_strided_slice.
Two cases appear:

  1. when the source and dest vectors have different ranks, extract the dest

subvector at the proper offset and reduce to case 2.

  1. when they have the same rank N: a. if the source and dest type are the same, the insertion is trivial: just forward the source b. otherwise, iterate over all N-1 D subvectors and create an extract/insert_strided_slice/insert replacement, reducing the problem to vecotrs of the same N-1 rank.

This combines properly with the other conversion patterns to lower all the way to LLVM.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJan 6 2020, 10:49 PM

Unit tests: unknown.

clang-tidy: unknown.

clang-format: unknown.

Build artifacts: diff.json, console-log.txt

andydavis1 accepted this revision.Jan 7 2020, 4:56 PM
andydavis1 added inline comments.
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
112

I think I have a helper function like this in VectorOps.cpp Need to unify these at some point.

506

At first a little surprised to see that InsertStridedSliceOp would be extracting a vector first, but I'm guessing this is because of the rank difference. If this is the case, maybe comment that we need to extract a subvector of the same rank as the source?

549

replaceOpWithNewOp

612

We know this terminates because the rank is reduced at each recursive step?

This revision is now accepted and ready to land.Jan 7 2020, 4:56 PM
nicolasvasilache marked 6 inline comments as done.

Address review comments.

nicolasvasilache accepted this revision.Jan 8 2020, 6:36 PM
nicolasvasilache added inline comments.
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
112

Great, I also have something similar for SmallVector<AffineMap, 4> somewhere else that I need to unify too in a followup commit.
I'll address both and others that I see in a followup.

112

Ack, talked a bunch about this with @rriddle too and there is a generic range forwarding + slicing semantics way to do this but it is worth a full separate effort.

nicolasvasilache resigned from this revision.Jan 8 2020, 6:36 PM

Unit tests: unknown.

clang-tidy: unknown.

clang-format: unknown.

Build artifacts: diff.json, console-log.txt

This revision was automatically updated to reflect the committed changes.