Add a "kind" attribute to ContractionOp and OuterProductOp.
authorPraveen Narayanan <pravnar@google.com>
Fri, 12 Feb 2021 20:14:51 +0000 (20:14 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Fri, 12 Feb 2021 20:23:59 +0000 (20:23 +0000)
commita65fb1916cb49b2f1ab3e7016fa54c04b2b048b4
tree513da058c88297982754d85397b267c38386938a
parent48fcce1aea9e783c3fe64482f06a965707e75990
Add a "kind" attribute to ContractionOp and OuterProductOp.

Currently, vector.contract joins the intermediate result and the accumulator
argument (of ranks K) using summation. We desire more joining operations ---
such as max --- to help vector.contract express reductions. This change extends
Vector_ContractionOp to take an optional attribute (called "kind", of enum type
CombiningKind) specifying the joining operation to be add/mul/min/max for int/fp
, and and/or/xor for int only. By default this attribute has value "add".

To implement this we also need to extend vector.outerproduct, since
vector.contract gets transformed to vector.outerproduct (and that to
vector.fma). The extension for vector.outerproduct is also an optional kind
attribute that uses the same enum type and possible values. The default is
"add". In case of max/min we transform vector.outerproduct to a combination of
compare and select.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D93280
12 files changed:
mlir/include/mlir/Dialect/Vector/CMakeLists.txt
mlir/include/mlir/Dialect/Vector/VectorOps.h
mlir/include/mlir/Dialect/Vector/VectorOps.td
mlir/include/mlir/IR/OpBase.td
mlir/lib/Dialect/Vector/CMakeLists.txt
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/lib/Dialect/Vector/VectorTransforms.cpp
mlir/test/Dialect/Linalg/vectorization.mlir
mlir/test/Dialect/Vector/ops.mlir
mlir/test/Dialect/Vector/vector-contract-matvec-transforms.mlir
mlir/test/Dialect/Vector/vector-transforms.mlir
mlir/tools/mlir-tblgen/EnumsGen.cpp