[PATCH] D148159: [mlir][TransformDialect] Simplify the lowering of pack/unpack when these are just pad/unpad

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 13:21:04 PDT 2023


qcolombet created this revision.
qcolombet added reviewers: ftynse, nicolasvasilache.
qcolombet added a project: MLIR.
Herald added subscribers: bviyer, hanchung, Moerafaat, zero9178, bzcheeseman, awarzynski, sdasgup3, wenzhicui, wrengr, jsetoain, cota, mravishankar, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, thopre, arphaman.
Herald added a project: All.
qcolombet requested review of this revision.
Herald added a subscriber: stephenneuendorffer.

This patch recognizes when `tensor.pack`/`unpack` operations are simple `tensor.pad`/`unpad` (a.k.a. `tensor.extract_slice`) and lowers them in a simpler sequence of instruction.

For pack, instead of doing:

  pad
  expand_shape
  transpose

we do

  pad
  insert_slice

For unpack, instead of doing:

  transpose
  collapse_shape
  extract_slice

we do

  extract_slice

Note: returning nullptr for the transform dialect is fine. The related handles are just ignored by the following transformation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148159

Files:
  mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
  mlir/include/mlir/Dialect/Utils/IndexingUtils.h
  mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h
  mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
  mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
  mlir/lib/Dialect/Utils/IndexingUtils.cpp
  mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
  mlir/test/Dialect/Linalg/transform-lower-pack.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148159.512949.patch
Type: text/x-patch
Size: 31162 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230412/3d8c3b00/attachment-0001.bin>


More information about the llvm-commits mailing list