This is an archive of the discontinued LLVM Phabricator instance.

[mlir] [VectorOps] Implement a simple folder for identity vector.transpose operations.
ClosedPublic

Authored by grosul1 on Mar 30 2020, 1:41 PM.

Details

Summary

[VectorOps] Implement a simple folder for identity vector.transpose operations.

Diff Detail

Event Timeline

grosul1 created this revision.Mar 30 2020, 1:41 PM
Herald added a project: Restricted Project. · View Herald Transcript
grosul1 edited the summary of this revision. (Show Details)Mar 30 2020, 1:44 PM
nicolasvasilache accepted this revision.Mar 30 2020, 3:12 PM

Is there a followup revision planned in which you would canonicalize transpose(transpose()) and have it compose with these newly added folders?

This revision is now accepted and ready to land.Mar 30 2020, 3:12 PM
rriddle added inline comments.Mar 30 2020, 3:25 PM
mlir/lib/Dialect/Vector/VectorOps.cpp
1540

Please run clang-format.

please label title with mlir as well

[mlir] [VectorOps]

mlir/include/mlir/Dialect/Vector/VectorOps.td
1318

note that the attribute is really called "transp" (perhaps not such a good name looking back), so getTransp or getTranspArray would be slightly more in style; but I am okay with this too and perhaps rename the array later

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

wouldn't it read a little easier as

for (int64_t i = 0, n = permutation.size; i < n; i++)

if (permutation[i] != i) 
...

i.e. less casting?

mlir/test/Dialect/Vector/canonicalize.mlir
132

maybe for completeness of what you have right now also a combination of transpose-ID and transpose-non-ID to make sure only the latter remain?

Is there a followup revision planned in which you would canonicalize transpose(transpose()) and have it compose with these newly added folders?

Thanks, Nicolas, yes, I expect to make an update to eliminate combinations of transposes.

grosul1 retitled this revision from [VectorOps] Implement a simple folder for identity vector.transpose operations. to [mlir] [VectorOps] Implement a simple folder for identity vector.transpose operations..Mar 30 2020, 4:16 PM
grosul1 marked 3 inline comments as done.Mar 30 2020, 5:39 PM
grosul1 added inline comments.
mlir/include/mlir/Dialect/Vector/VectorOps.td
1318

Done! Renamed everything to transp/Transp, no discrepancy for now. Everything can be renamed at once if/when someone gets to do it.

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

Used "e = " as it seems to be a convention; in this file, at least.

grosul1 marked an inline comment as done.Mar 30 2020, 5:40 PM
aartbik accepted this revision.Mar 30 2020, 5:54 PM

Good to go, but some last comments to consider in the follow up.

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

Given the llvm style of leaving the {} out of trivial for/ifs (something I am not a big fan of), I am wondering if that actually also applies to this case, trivial for loop with trivial if, so no {} on for either; perhaps others will comment, otherwise just leave it

mlir/test/Dialect/Vector/canonicalize.mlir
155

this of course captures that the intermediate tranpose is gone, but to be completely consistent with your other tests, you would expect a CHECK-NOT here (to make sure it is also removed as dead code)

grosul1 updated this revision to Diff 253768.Mar 30 2020, 6:57 PM

Update the test

grosul1 marked an inline comment as done.Mar 30 2020, 6:58 PM
grosul1 added inline comments.Mar 30 2020, 7:18 PM
mlir/lib/Dialect/Vector/VectorOps.cpp
1536

I can turn this loop (back) into a lambda.
Not quite the same case, but similar: https://llvm.org/docs/CodingStandards.html#turn-predicate-loops-into-predicate-functions.

grosul1 marked an inline comment as done.Mar 31 2020, 10:50 AM
grosul1 added inline comments.
mlir/lib/Dialect/Vector/VectorOps.cpp
1536

Submitting as is.

This revision was automatically updated to reflect the committed changes.