[mlir][Vector] Support 0-D vectors in `ConstantMaskOp`
authorMichal Terepeta <michalt@google.com>
Mon, 6 Dec 2021 07:59:49 +0000 (07:59 +0000)
committerNicolas Vasilache <nicolas.vasilache@gmail.com>
Mon, 6 Dec 2021 08:03:04 +0000 (08:03 +0000)
commitcaf89c0db679f79ca6c9a75c5acc6151dd380f26
tree22c0d0b6c5ffe0575f128fcd4209591eaed7d63b
parent69bcff46bff34838c91880ecaa6616bb6979cd23
[mlir][Vector] Support 0-D vectors in `ConstantMaskOp`

To support creating both a mask with just a single `true` and `false` values,
I had to relax the restriction in the verifier that the rank is always equal to
the length of the attribute array, in other words, we now allow:

- `vector.constant_mask [0] : vector<i1>` which gets lowered to
  `arith.constant dense<false> : vector<i1>`
- `vector.constant_mask [1] : vector<i1>` which gets lowered to
  `arith.constant dense<true> : vector<i1>`

(the attribute list for the 0-D case must be a singleton containing
either `0` or `1`)

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D115023
mlir/include/mlir/Dialect/Vector/VectorOps.td
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/lib/Dialect/Vector/VectorTransforms.cpp
mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir
mlir/test/Dialect/Vector/invalid.mlir
mlir/test/Dialect/Vector/ops.mlir
mlir/test/Integration/Dialect/Vector/CPU/test-0-d-vectors.mlir