This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] Add folding for ExtractOp with ShapeCastOp source
ClosedPublic

Authored by ThomasRaoux on Oct 20 2020, 11:50 PM.

Diff Detail

Event Timeline

ThomasRaoux created this revision.Oct 20 2020, 11:50 PM
ThomasRaoux requested review of this revision.Oct 20 2020, 11:50 PM
aartbik added inline comments.Oct 21 2020, 10:45 AM
mlir/lib/Dialect/Vector/VectorOps.cpp
857

if( -> if ( space missing

861

int -> int64_t

875

int -> int64_t

887

int -> int64_t

Address review comments

ThomasRaoux marked 3 inline comments as done.Oct 21 2020, 10:53 AM
ThomasRaoux added inline comments.
mlir/lib/Dialect/Vector/VectorOps.cpp
857

Oops I was sure I had run clang-format :(

aartbik accepted this revision.Oct 23 2020, 11:18 AM
This revision is now accepted and ready to land.Oct 23 2020, 11:18 AM

LGTM, thanks Thomas!

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

type.getShape().take_back(n).front() ?

856

extractOp.getResultType().cast<VectorType>().getRank()
would avoid using/assuming internal extractOp logic (not that it changes much though..)?

864

Add a TODO that this could be generalized with a canonicalization pattern, with the shape_cast moving after the extract ?
This seems reminiscent of manipulations we see in various places of IR (e.g. unrolling, linalg.reshape, vector distribution, etc).

881

s/assoociated/associated

894

Comment that OpBuilder is only used to getI64ArrayAttr (even if obvious)?
Creating builders is generally a slippery slope (re. rewrite patterns etc).