Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2058,32 +2058,36 @@ def Vector_GatherOp :
Results<(outs AnyVectorOfNonZeroRank:$result)> {

let summary = [{
gathers elements from memory or ranked tensor into a vector as defined by an
index vector and a mask vector
Gathers elements from memory or ranked tensor into a vector as defined by an
index vector and a mask vector.
}];

let description = [{
The gather operation returns an n-D vector whose elements are either loaded
from memory or ranked tensor, or taken from a pass-through vector, depending
from a k-D memref or tensor, or taken from an n-D pass-through vector, depending
on the values of an n-D mask vector.
If a mask bit is set, the corresponding result element is defined by the base
with indices and the n-D index vector (each index is a 1-D offset on the base).
Otherwise, the corresponding element is taken from the n-D pass-through vector.
Informally the semantics are:

If a mask bit is set, the corresponding result element is taken from `base`
at an index defined by k `indices` and n-D `index_vec`. Otherwise, the element
is taken from the pass-through vector. As an example, suppose that base is
3-D and the result is 2-D. The indexing semantics are then,

```
result[0] := if mask[0] then base[index[0]] else pass_thru[0]
result[1] := if mask[1] then base[index[1]] else pass_thru[1]
etc.
result[i,j] := if mask[i,j] then
base[indices[0], indices[1], indices[2] + index_vec[i,j]]
else
pass_thru[i,j]
```
The index into `base` only varies in the dimension k-1.

If a mask bit is set and the corresponding index is out-of-bounds for the
given base, the behavior is undefined. If a mask bit is not set, the value
comes from the pass-through vector regardless of the index, and the index is
allowed to be out-of-bounds.

The gather operation can be used directly where applicable, or can be used
during progressively lowering to bring other memory operations closer to
hardware ISA support for a gather.
during progressive lowering to bring other memory operations closer to hardware
ISA support for a gather.

Examples:

Expand Down