-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][doc] Slightly clarify bufferization documentation #70212
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
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 |
---|---|---|
|
@@ -110,13 +110,13 @@ As an example, consider the following op: `%0 = tensor.insert %cst into | |
%t[%idx] : tensor<?xf32>` | ||
|
||
`%t` is the destination in this example. When choosing a buffer for the result | ||
`%0`, One-Shot Bufferize considers only two options: | ||
`%0`, denoted as `buffer(%0)`, One-Shot Bufferize considers only two options: | ||
|
||
1. buffer(`%0`) = buffer(`%t`). | ||
2. buffer(`%0`) is a newly allocated buffer. | ||
1. `buffer(%0) = buffer(%t)`, or | ||
2. `buffer(%0)` is a newly allocated buffer. | ||
|
||
There may be other buffers in the same function that could potentially be used | ||
for buffer(`%0`), but those are not considered by One-Shot Bufferize to keep the | ||
for `buffer(%0)`, but those are not considered by One-Shot Bufferize to keep the | ||
bufferization simple. One-Shot Bufferize could be extended to consider such | ||
buffers in the future to achieve a better quality of bufferization. | ||
|
||
|
@@ -131,10 +131,10 @@ memory allocation. E.g.: | |
} : tensor<?xf32> | ||
``` | ||
|
||
The result of `tensor.generate` does not have a "destination", so bufferization | ||
allocates a new buffer. This could be avoided by choosing an op such as | ||
`linalg.generic`, which can express the same computation with a destination | ||
("out") tensor: | ||
The result of `tensor.generate` does not have a destination operand, so | ||
bufferization allocates a new buffer. This could be avoided by choosing an | ||
op such as `linalg.generic`, which can express the same computation with a | ||
destination operand, as specified behind outputs (`outs`): | ||
|
||
```mlir | ||
#map = affine_map<(i) -> (i)> | ||
|
@@ -165,7 +165,7 @@ such as a subsequent read of `%s`). | |
|
||
RaW conflicts are detected with an analysis of SSA use-def chains (details | ||
later). One-Shot Bufferize works best if there is a single SSA use-def chain, | ||
where the result of a tensor op is the "destination" operand of the next tensor | ||
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. The quote here are meant to express that this isn't really a "destination" at the SSA level but only an input for the operation. |
||
where the result of a tensor op is the destination operand of the next tensor | ||
ops, e.g.: | ||
|
||
```mlir | ||
|
@@ -263,7 +263,7 @@ must be inserted due to a RaW conflict. E.g.: | |
} | ||
``` | ||
|
||
In the above example, a buffer copy of buffer(`%another_tensor`) (with `%cst` | ||
In the above example, a buffer copy of `buffer(%another_tensor)` (with `%cst` | ||
inserted) is yielded from the "then" branch. | ||
|
||
Note: Buffer allocations that are returned from a function are not deallocated. | ||
|
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.
I actually don't think this sentence is correct, but I should probably rewrite the entire first part of the doc separately.