[mlir][Vector] Let vector.multi_reduction reduce down to a scalar.
authorNicolas Vasilache <nicolas.vasilache@gmail.com>
Tue, 12 Oct 2021 10:30:10 +0000 (10:30 +0000)
committerNicolas Vasilache <nicolas.vasilache@gmail.com>
Tue, 12 Oct 2021 11:03:54 +0000 (11:03 +0000)
commit31270eb16501cca73fb3fbac254fe9965a3f3fc1
tree9b7730bd9f06a3601fbb01664e4bbf86b0f5850d
parent7a79c6afea93d1237bea2317bea624947ce8a4a5
[mlir][Vector] Let vector.multi_reduction reduce down to a scalar.

vector.multi_reduction currently does not allow reducing down to a scalar.
This creates corner cases that are hard to handle during vectorization.
This revision extends the semantics and adds the proper transforms, lowerings and canonicalizations to allow lowering out of vector.multi_reduction to other abstractions all the way to LLVM.

In a future, where we will also allow 0-d vectors, scalars will still be relevant: 0-d vector and scalars are not equivalent on all hardware.

In the process, splice out the implementation patterns related to vector.multi_reduce into a new file.

Reviewed By: pifon2a

Differential Revision: https://reviews.llvm.org/D111442
mlir/include/mlir/Dialect/Vector/VectorOps.h
mlir/include/mlir/Dialect/Vector/VectorOps.td
mlir/lib/Dialect/Vector/CMakeLists.txt
mlir/lib/Dialect/Vector/VectorMultiDimReductionTransforms.cpp [new file with mode: 0644]
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/lib/Dialect/Vector/VectorTransforms.cpp
mlir/test/Dialect/Vector/canonicalize.mlir
mlir/test/Dialect/Vector/ops.mlir
mlir/test/Dialect/Vector/vector-multi-reduction-lowering.mlir