Skip to content

Commit d8a5215

Browse files
authored
[mlir][doc] Slightly clarify bufferization documentation (#70212)
I was reading through the very well written Destination-Passing Style docs. Even though I know not much about compilers, I managed to understand it pretty well. A few things tripped me up though, which this PR suggests to rewrite: 1. Write `buffer(%0)` instead of buffer(`%0`). While reading, I first interpreted the text as "the buffer (%0)", whereas it should be interpreted as pseudocode for "a function that determines the buffer applied to %0". Quickly introducing it and moving the backticks around as this PR does should make this more clear. Also, I verified that MLIR does not contain any other occurences of `"buffer(<BACKTICK>"`. It does contain many occurences of `"buffer("` (without the backtick after the opening bracket), so this PR makes notation a bit more consistent. 2. Quotation marks slowed me down during reading, so I removed them. I think it's also clear without. 3. The `outs` from `linalg` was suddenly introduced. I've tried to clarify in as few words as possible that `outs` stands for `outputs` but suggestions are welcome.
1 parent 04ca1b6 commit d8a5215

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

mlir/docs/Bufferization.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ As an example, consider the following op: `%0 = tensor.insert %cst into
110110
%t[%idx] : tensor<?xf32>`
111111

112112
`%t` is the destination in this example. When choosing a buffer for the result
113-
`%0`, One-Shot Bufferize considers only two options:
113+
`%0`, denoted as `buffer(%0)`, One-Shot Bufferize considers only two options:
114114

115-
1. buffer(`%0`) = buffer(`%t`).
116-
2. buffer(`%0`) is a newly allocated buffer.
115+
1. `buffer(%0) = buffer(%t)`, or
116+
2. `buffer(%0)` is a newly allocated buffer.
117117

118118
There may be other buffers in the same function that could potentially be used
119-
for buffer(`%0`), but those are not considered by One-Shot Bufferize to keep the
119+
for `buffer(%0)`, but those are not considered by One-Shot Bufferize to keep the
120120
bufferization simple. One-Shot Bufferize could be extended to consider such
121121
buffers in the future to achieve a better quality of bufferization.
122122

@@ -131,10 +131,10 @@ memory allocation. E.g.:
131131
} : tensor<?xf32>
132132
```
133133

134-
The result of `tensor.generate` does not have a "destination", so bufferization
135-
allocates a new buffer. This could be avoided by choosing an op such as
136-
`linalg.generic`, which can express the same computation with a destination
137-
("out") tensor:
134+
The result of `tensor.generate` does not have a destination operand, so
135+
bufferization allocates a new buffer. This could be avoided by choosing an
136+
op such as `linalg.generic`, which can express the same computation with a
137+
destination operand, as specified behind outputs (`outs`):
138138

139139
```mlir
140140
#map = affine_map<(i) -> (i)>
@@ -165,7 +165,7 @@ such as a subsequent read of `%s`).
165165

166166
RaW conflicts are detected with an analysis of SSA use-def chains (details
167167
later). One-Shot Bufferize works best if there is a single SSA use-def chain,
168-
where the result of a tensor op is the "destination" operand of the next tensor
168+
where the result of a tensor op is the destination operand of the next tensor
169169
ops, e.g.:
170170

171171
```mlir
@@ -263,7 +263,7 @@ must be inserted due to a RaW conflict. E.g.:
263263
}
264264
```
265265

266-
In the above example, a buffer copy of buffer(`%another_tensor`) (with `%cst`
266+
In the above example, a buffer copy of `buffer(%another_tensor)` (with `%cst`
267267
inserted) is yielded from the "then" branch.
268268

269269
Note: Buffer allocations that are returned from a function are not deallocated.

0 commit comments

Comments
 (0)