Commit ced2fc7
authored
[mlir][bufferization] Fix OneShotBufferize when
As described in issue llvm#91518, a previous PR
llvm#78484 introduced the `defaultMemorySpaceFn` into
bufferization options, allowing one to inform OneShotBufferize that it
should use a specified function to derive the memory space attribute
from the encoding attribute attached to tensor types.
However, introducing this feature exposed unhandled edge cases,
examples of which are introduced by this change in the new test under
`test/Dialect/Bufferization/Transforms/one-shot-bufferize-encodings.mlir`.
Fixing the inconsistencies introduced by `defaultMemorySpaceFn` is
pretty simple. This change:
- Updates the `bufferization.to_memref` and `bufferization.to_tensor`
operations to explicitly include operand and destination types,
whereas previously they relied on type inference to deduce the
tensor types. Since the type inference cannot recover the correct
tensor encoding/memory space, the operand and result types must be
explicitly included. This is a small assembly format change, but it
touches a large number of test files.
- Makes minor updates to other bufferization functions to handle the
changes in building the above ops.
- Updates bufferization of `tensor.from_elements` to handle memory
space.
Integration/upgrade guide:
In downstream projects, if you have tests or MLIR files that explicitly
use
`bufferization.to_tensor` or `bufferization.to_memref`, then update
them to the new assembly format as follows:
```
%1 = bufferization.to_memref %0 : memref<10xf32>
%2 = bufferization.to_tensor %1 : memref<10xf32>
```
becomes
```
%1 = bufferization.to_memref %0 : tensor<10xf32> to memref<10xf32>
%2 = bufferization.to_tensor %0 : memref<10xf32> to tensor<10xf32>
```defaultMemorySpaceFn is used (llvm#91524)1 parent 88cff86 commit ced2fc7
File tree
73 files changed
+608
-373
lines changed- mlir
- docs
- include/mlir/Dialect/Bufferization
- IR
- Transforms
- lib/Dialect
- Bufferization
- IR
- Transforms
- SCF/Transforms
- Tensor/Transforms
- test
- Dialect
- Affine
- Arith
- Bufferization
- Transforms
- OwnershipBasedBufferDeallocation
- ControlFlow
- Linalg
- MemRef
- SCF
- Shape
- SparseTensor
- GPU
- Tensor
- Vector
- Integration/Dialect
- SparseTensor/GPU/CUDA
- Tosa/CPU
- Vector/CPU/AMX
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
73 files changed
+608
-373
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
| 226 | + | |
| 227 | + | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| |||
Lines changed: 15 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
391 | | - | |
392 | | - | |
| 390 | + | |
393 | 391 | | |
394 | 392 | | |
395 | 393 | | |
| |||
404 | 402 | | |
405 | 403 | | |
406 | 404 | | |
407 | | - | |
| 405 | + | |
408 | 406 | | |
409 | 407 | | |
410 | 408 | | |
| |||
427 | 425 | | |
428 | 426 | | |
429 | 427 | | |
430 | | - | |
| 428 | + | |
431 | 429 | | |
432 | 430 | | |
433 | 431 | | |
| |||
476 | 474 | | |
477 | 475 | | |
478 | 476 | | |
479 | | - | |
| 477 | + | |
480 | 478 | | |
481 | 479 | | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
482 | 487 | | |
483 | 488 | | |
484 | 489 | | |
| |||
493 | 498 | | |
494 | 499 | | |
495 | 500 | | |
496 | | - | |
497 | | - | |
498 | | - | |
| 501 | + | |
| 502 | + | |
499 | 503 | | |
500 | 504 | | |
501 | 505 | | |
502 | 506 | | |
503 | 507 | | |
504 | 508 | | |
505 | 509 | | |
506 | | - | |
| 510 | + | |
507 | 511 | | |
508 | 512 | | |
509 | 513 | | |
| |||
550 | 554 | | |
551 | 555 | | |
552 | 556 | | |
553 | | - | |
| 557 | + | |
554 | 558 | | |
555 | 559 | | |
556 | 560 | | |
| |||
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
254 | | - | |
| 253 | + | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
513 | 517 | | |
514 | 518 | | |
515 | 519 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
718 | 718 | | |
719 | 719 | | |
720 | 720 | | |
721 | | - | |
| 721 | + | |
722 | 722 | | |
723 | 723 | | |
724 | 724 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
150 | 159 | | |
151 | 160 | | |
152 | 161 | | |
153 | 162 | | |
154 | 163 | | |
155 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
156 | 175 | | |
157 | 176 | | |
158 | 177 | | |
| |||
Lines changed: 17 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
| 207 | + | |
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| |||
485 | 486 | | |
486 | 487 | | |
487 | 488 | | |
| 489 | + | |
488 | 490 | | |
489 | 491 | | |
490 | 492 | | |
491 | 493 | | |
492 | 494 | | |
493 | 495 | | |
494 | | - | |
495 | | - | |
496 | | - | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
497 | 500 | | |
498 | 501 | | |
499 | 502 | | |
| |||
763 | 766 | | |
764 | 767 | | |
765 | 768 | | |
766 | | - | |
| 769 | + | |
| 770 | + | |
767 | 771 | | |
768 | 772 | | |
769 | 773 | | |
| |||
1000 | 1004 | | |
1001 | 1005 | | |
1002 | 1006 | | |
1003 | | - | |
1004 | | - | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
1005 | 1010 | | |
1006 | 1011 | | |
1007 | 1012 | | |
1008 | 1013 | | |
1009 | 1014 | | |
1010 | 1015 | | |
1011 | | - | |
1012 | | - | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
1013 | 1019 | | |
1014 | 1020 | | |
1015 | 1021 | | |
| |||
1255 | 1261 | | |
1256 | 1262 | | |
1257 | 1263 | | |
1258 | | - | |
1259 | | - | |
| 1264 | + | |
| 1265 | + | |
1260 | 1266 | | |
1261 | 1267 | | |
1262 | 1268 | | |
| |||
Lines changed: 5 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | 483 | | |
488 | 484 | | |
489 | 485 | | |
| |||
493 | 489 | | |
494 | 490 | | |
495 | 491 | | |
496 | | - | |
497 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
498 | 496 | | |
499 | | - | |
| 497 | + | |
500 | 498 | | |
501 | 499 | | |
502 | 500 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
0 commit comments