This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Tensor] Add canonicalization for UnpackOp
ClosedPublic

Authored by chelini on Nov 29 2022, 6:08 AM.

Diff Detail

Event Timeline

chelini created this revision.Nov 29 2022, 6:08 AM
chelini requested review of this revision.Nov 29 2022, 6:08 AM
hanchung requested changes to this revision.Nov 29 2022, 11:31 AM
hanchung added inline comments.
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
3426–3427

I think the check is not enough, we should probably look into the inner dims pos and inner tile sizes?

E.g., we can not fold the below chain away:

unpack NCnc -> NC
pack NC -> cnCN

The shape of NCnc and cnCN can be identical. E.g., when N=C=128 and inner_tile sizes are [8, 8].

This revision now requires changes to proceed.Nov 29 2022, 11:31 AM
hanchung added inline comments.Nov 29 2022, 11:36 AM
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
3426–3427

typo:

pack NC -> CNcn

more context: CNcn is not equivalent to NCnc because there are transpose involved.

chelini updated this revision to Diff 478864.Nov 30 2022, 2:25 AM

Address comments.

chelini added inline comments.Nov 30 2022, 2:27 AM
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
3426–3427

Thanks for the comments. To clarify, do you mean outer_dims_perm instead of tile sizes? Tile sizes are taken into account looking at the type.

hanchung accepted this revision.Nov 30 2022, 11:00 AM
hanchung added inline comments.
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
3426–3427

yes, I meant inner_dims_pos and outer_dims_perm!

This revision is now accepted and ready to land.Nov 30 2022, 11:00 AM
This revision was automatically updated to reflect the committed changes.