| Issue |
239511
|
| Summary |
[mlir][vector] Unify masking in the Vector dialect
|
| Labels |
metaissue,
mlir:vectorops,
mlir,
mlir:vector
|
| Assignees |
|
| Reporter |
FedericoBruzzone
|
This is an umbrella ticket to track the implementation of the RFC: https://discourse.llvm.org/t/rfc-unify-masking-in-the-vector-dialect/92675.
### Motivation
An op can be masked either by wrapping it in `vector.mask` or by passing a mask operand.
For `transfer_read`, `transfer_write` and `gather` both forms are legal at the same time, and the combination is not defined.
This already causes bugs, e.g., #225244.
### Goal
An op has exactly one mask and can be masked in only one way, either via `vector.mask` or via a mask operand.
The mask operand exists only where the mask is part of the op semantics and mirrors an LLVM intrinsic.
**Now**
| Op | `vector.mask` | mask operand |
|---|---|---|
| `contract`, `reduction`, `multi_reduction`, `outerproduct` | yes | no |
| `transfer_read`, `transfer_write` | yes | optional |
| `gather` | yes | mandatory |
| `scatter`, `maskedload`, `maskedstore`, `expandload`, `compressstore` | no | mandatory |
**Target**
| Op | `vector.mask` | mask operand |
|---|---|---|
| `contract`, `reduction`, `multi_reduction`, `outerproduct`, `transfer_read`, `transfer_write` | **yes** | no |
| `gather`, `scatter`, `maskedload`, `maskedstore`, `expandload`, `compressstore` | no | **mandatory** |
### Non-Goals (discussed without consensus)
* Multiple ops inside one `vector.mask` region.
* Making `vector.load` / `vector.store` maskable, and eventually removing `vector.maskedload` / `vector.maskedstore`.
* Making `gather` / `scatter` / `expandload` / `compressstore` maskable and removing the _mask operand_.
### A note for `padding`
`transfer_read` has a `padding` operand for its masked-off and out-of-bounds lanes.
`vector.mask` has no padding, only an optional passthru, and the masked-off lanes of a `transfer_read` under `vector.mask` are not specified today (padding or poison).
Per the RFC, once `in_bounds` (#227821) and the mask operand are removed, `padding` only matters for masked-off lanes.
It can then become the `vector.mask` passthru, and the `padding` operand can disappear.
**This will be discussed in the relevant PR.**
### Tasks
- [ ] Add an `isMasked()` helper and use `notifyMatchFailure` in `-convert-vector-to-scf`, so it fails cleanly on region-masked ops instead of producing invalid IR (can land independently)
- [ ] Make `vector.gather` non-maskable, like `vector.scatter`, and pass the mask as an operand in the Linalg vectorizer
- [ ] Make the `vector.mask` verifier reject a masked op that already has a mask operand
- [ ] Specify the masked-off lanes of `transfer_read` under `vector.mask` with the `padding` semantics (related: #228328)
- [ ] Remove the optional mask operand from `transfer_read` and `transfer_write`
- [ ] Decide whether `padding` becomes the `vector.mask` passthru and the `padding` operand is removed
### PRs
- TBD
Cheers,
-Fede
P.S. If anything is unclear, please do not hesitate to point it out. Thank you all for the valuable discussions during the RFC process that led to this plan 🙏
CC: @banach-space @rengolin @Jianhui-Li @dcaballe @Groverkss @krzysz00 @dhairyashilRG @Vaisman @nprisament @snarang181 @StarOne01
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs