Skip to content

Commit 7b2bc84

Browse files
authored
[descriptors] Enable loop allocation for bufferization (#291)
Allows returning new allocations from loops. It allows lowering loops that cannot fully bufferize in-place without hard stopping compilation with bufferization failure. Cases where no allocations are required remain unaffected.
1 parent 2100788 commit 7b2bc84

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
Pipeline:
22
- pass: "eliminate-empty-tensors"
3-
- pass: "one-shot-bufferize{function-boundary-type-conversion=identity-layout-map bufferize-function-boundaries}"
3+
- pass: "one-shot-bufferize{
4+
function-boundary-type-conversion=identity-layout-map
5+
bufferize-function-boundaries
6+
allow-return-allocs-from-loops
7+
}"
48
- pass: "drop-equivalent-buffer-results"

‎lighthouse/schedule/bufferization.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
from lighthouse.pipeline.helper import apply_registered_pass
99

1010

11-
def bufferize(deallocation_pipeline: bool = False) -> ir.Module:
11+
def bufferize(
12+
deallocation_pipeline: bool = False, allow_return_allocs_from_loops: bool = False
13+
) -> ir.Module:
1214
"""
1315
Bufferize all ops.
1416
1517
Args:
1618
deallocation_pipeline: Applies deallocation pipeline
19+
allow_return_allocs_from_loops: Allows return allocs from loops
1720
Returns:
1821
Schedule
1922
"""
@@ -25,6 +28,7 @@ def bufferize(deallocation_pipeline: bool = False) -> ir.Module:
2528
target,
2629
function_boundary_type_conversion=LayoutMapOption.IdentityLayoutMap,
2730
bufferize_function_boundaries=True,
31+
allow_return_allocs_from_loops=allow_return_allocs_from_loops,
2832
)
2933
target = apply_registered_pass(target, "drop-equivalent-buffer-results")
3034
if deallocation_pipeline:

0 commit comments

Comments
 (0)