-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[mlir][vector] Remove unneeded mask restriction #113742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1819,17 +1819,17 @@ def Vector_MaskedLoadOp : | |
| Vector_Op<"maskedload">, | ||
| Arguments<(ins Arg<AnyMemRef, "", [MemRead]>:$base, | ||
| Variadic<Index>:$indices, | ||
| VectorOfRankAndType<[1], [I1]>:$mask, | ||
| VectorOfRank<[1]>:$pass_thru)>, | ||
| Results<(outs VectorOfRank<[1]>:$result)> { | ||
| VectorOf<[I1]>:$mask, | ||
| AnyVector:$pass_thru)>, | ||
| Results<(outs AnyVector:$result)> { | ||
|
|
||
| let summary = "loads elements from memory into a vector as defined by a mask vector"; | ||
|
|
||
| let description = [{ | ||
| The masked load reads elements from memory into a 1-D vector as defined | ||
| by a base with indices and a 1-D mask vector. When the mask is set, the | ||
| The masked load reads elements from memory into a vector as defined | ||
| by a base with indices and a mask vector. When the mask is set, the | ||
| element is read from memory. Otherwise, the corresponding element is taken | ||
| from a 1-D pass-through vector. Informally the semantics are: | ||
| from a pass-through vector. Informally the semantics are: | ||
| ``` | ||
| result[0] := if mask[0] then base[i + 0] else pass_thru[0] | ||
| result[1] := if mask[1] then base[i + 1] else pass_thru[1] | ||
|
|
@@ -1882,14 +1882,14 @@ def Vector_MaskedStoreOp : | |
| Vector_Op<"maskedstore">, | ||
| Arguments<(ins Arg<AnyMemRef, "", [MemWrite]>:$base, | ||
| Variadic<Index>:$indices, | ||
| VectorOfRankAndType<[1], [I1]>:$mask, | ||
| VectorOfRank<[1]>:$valueToStore)> { | ||
| VectorOf<[I1]>:$mask, | ||
| AnyVector:$valueToStore)> { | ||
|
|
||
| let summary = "stores elements from a vector into memory as defined by a mask vector"; | ||
|
|
||
| let description = [{ | ||
| The masked store operation writes elements from a 1-D vector into memory | ||
| as defined by a base with indices and a 1-D mask vector. When the mask is | ||
| The masked store operation writes elements from a vector into memory | ||
| as defined by a base with indices and a mask vector. When the mask is | ||
| set, the corresponding element from the vector is written to memory. Otherwise, | ||
| no action is taken for the element. Informally the semantics are: | ||
| ``` | ||
|
|
@@ -2076,23 +2076,26 @@ def Vector_ExpandLoadOp : | |
| Vector_Op<"expandload">, | ||
| Arguments<(ins Arg<AnyMemRef, "", [MemRead]>:$base, | ||
| Variadic<Index>:$indices, | ||
| VectorOfRankAndType<[1], [I1]>:$mask, | ||
| VectorOfRank<[1]>:$pass_thru)>, | ||
| Results<(outs VectorOfRank<[1]>:$result)> { | ||
| VectorOf<[I1]>:$mask, | ||
| AnyVector:$pass_thru)>, | ||
| Results<(outs AnyVector:$result)> { | ||
|
|
||
| let summary = "reads elements from memory and spreads them into a vector as defined by a mask"; | ||
|
|
||
| let description = [{ | ||
| The expand load reads elements from memory into a 1-D vector as defined | ||
| by a base with indices and a 1-D mask vector. When the mask is set, the | ||
| next element is read from memory. Otherwise, the corresponding element | ||
| is taken from a 1-D pass-through vector. Informally the semantics are: | ||
| The expand load reads elements from memory into a vector as defined by a | ||
| base with indices and a mask vector. Expansion only applies to the innermost | ||
| dimension. When the mask is set, the next element is read from memory. | ||
| Otherwise, the corresponding element is taken from a pass-through vector. | ||
| Informally the semantics are: | ||
|
|
||
| ``` | ||
| index = i | ||
| result[0] := if mask[0] then base[index++] else pass_thru[0] | ||
| result[1] := if mask[1] then base[index++] else pass_thru[1] | ||
| etc. | ||
| ``` | ||
|
|
||
| Note that the index increment is done conditionally. | ||
|
|
||
| If a mask bit is set and the corresponding index is out-of-bounds for the | ||
|
|
@@ -2140,22 +2143,25 @@ def Vector_CompressStoreOp : | |
| Vector_Op<"compressstore">, | ||
| Arguments<(ins Arg<AnyMemRef, "", [MemWrite]>:$base, | ||
| Variadic<Index>:$indices, | ||
| VectorOfRankAndType<[1], [I1]>:$mask, | ||
| VectorOfRank<[1]>:$valueToStore)> { | ||
| VectorOf<[I1]>:$mask, | ||
| AnyVector:$valueToStore)> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For compress and expand, I would state in the doc that the compression/expansion applies only along the innermost dimension.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SG |
||
|
|
||
| let summary = "writes elements selectively from a vector as defined by a mask"; | ||
|
|
||
| let description = [{ | ||
| The compress store operation writes elements from a 1-D vector into memory | ||
| as defined by a base with indices and a 1-D mask vector. When the mask is | ||
| set, the corresponding element from the vector is written next to memory. | ||
| Otherwise, no action is taken for the element. Informally the semantics are: | ||
| The compress store operation writes elements from a vector into memory as | ||
| defined by a base with indices and a mask vector. Compression only applies | ||
| to the innermost dimension. When the mask is set, the corresponding element | ||
| from the vector is written next to memory. Otherwise, no action is taken | ||
| for the element. Informally the semantics are: | ||
|
|
||
| ``` | ||
| index = i | ||
| if (mask[0]) base[index++] = value[0] | ||
| if (mask[1]) base[index++] = value[1] | ||
| etc. | ||
| ``` | ||
|
|
||
| Note that the index increment is done conditionally. | ||
|
|
||
| If a mask bit is set and the corresponding index is out-of-bounds for the | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably good to add constraints to ensure that pass_thru and result's types match and that the number of elements in mask and one of the other vectors match as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha this let to finding a bug in the generated inference with variadics (well known limitations there)