This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tensor][linalg] Add a pattern that generalizes tensor.unpack op.
ClosedPublic

Authored by hanchung on Dec 16 2022, 4:27 PM.

Details

Summary

The pattern generalizes a tensor::UnPackOp into a sequence of tensor +
Linalg ops, when the outer dims are all 1s. It uses the trick of
rank-reduced tensor.extract_slice to get the tile; transpose the tile;
extract sub tile for incomplete cases if needed; use tensor.insert_slice
to insert it to the destination tensor.

Diff Detail

Event Timeline

hanchung created this revision.Dec 16 2022, 4:27 PM
hanchung requested review of this revision.Dec 16 2022, 4:27 PM
hanchung retitled this revision from [mlir][tensor][linalg] Add a pattern that generalizes tensor.unpack op. The pattern generalizes a tensor::UnPackOp into a sequence of tensor + Linalg ops, when the outer dims are all 1s. It uses the trick of rank-reduced tensor.extract_slice to... to [mlir][tensor][linalg] Add a pattern that generalizes tensor.unpack op..Dec 16 2022, 4:28 PM
hanchung edited the summary of this revision. (Show Details)
tyb0807 accepted this revision.Dec 17 2022, 2:29 PM

Thanks, LGTM

mlir/test/Dialect/Linalg/generalize-tensor-unpack.mlir
37–38

Suggestion: move this before tensor.extract_slice one line above for clarity

mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp
84

Nit: generalizes

89

Nit: generalizes unpack

This revision is now accepted and ready to land.Dec 17 2022, 2:29 PM
chelini accepted this revision.Dec 19 2022, 12:16 AM
hanchung updated this revision to Diff 484126.Dec 19 2022, 3:58 PM

address comments

This revision was landed with ongoing or failed builds.Dec 19 2022, 5:52 PM
This revision was automatically updated to reflect the committed changes.