Introduce `tensor.pack` and `tensor.unpack` operations
authorLorenzo Chelini <l.chelini@icloud.com>
Tue, 15 Nov 2022 09:30:50 +0000 (10:30 +0100)
committerLorenzo Chelini <l.chelini@icloud.com>
Tue, 22 Nov 2022 08:11:59 +0000 (09:11 +0100)
commit9aa505a28d827f13ac9c6268f5834592b1a150e3
tree35c5f52145824f1b802ca298017678a17bec9828
parentd9143ce3fd1da95943b76e245a7e273dac73afd2
Introduce `tensor.pack` and `tensor.unpack` operations

Pack and Unpack return new tensors within which the individual elements
are reshuffled according to the packing specification. This has the
consequence of modifying the canonical order in which a given operator
(i.e., Matmul) accesses the individual elements. After bufferization,
this typically translates to increased access locality and cache
behavior improvement, e.g., eliminating cache line splitting.

Co-authored-by: Mahesh Ravishankar <ravishankarm@google.com>
Co-authored-by: Han-Chung Wang <hanchung@google.com>
RFC: https://discourse.llvm.org/t/rfc-tensor-pack-and-tensor-unpack/66408/1

Reviewed By: nicolasvasilache, rengolin, hanchung

Differential Revision: https://reviews.llvm.org/D138119
mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
mlir/test/Dialect/Tensor/invalid.mlir
mlir/test/Dialect/Tensor/ops.mlir
mlir/test/Transforms/loop-invariant-code-motion.mlir