Commit a7c7528
Fix placeholder lifetime bug in memory planning (#6971)
Summary:
If we have a node that is inserted between placeholders via a pass after to_edge then there is a bug in memory planning lifetime calculations which results in two placeholders being allocated the same memory segment.
Two placeholders should never be using the same memory segment and to prevent this we set the beginning lifetime of the placeholder to be always 0 in the memory planning pass.
In the test case added this is the graph:
```
graph():
%a : [num_users=1] = placeholder[target=a]
%aten_permute_copy_default : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.permute_copy.default](args = (%a, [1, 0, 2]), kwargs = {})
%b : [num_users=2] = placeholder[target=b]
%aten_add_tensor : [num_users=2] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_permute_copy_default, %b), kwargs = {})
%aten_add_tensor_1 : [num_users=1] = call_function[target=executorch.exir.dialects.edge._ops.aten.add.Tensor](args = (%aten_add_tensor, %b), kwargs = {})
return (aten_add_tensor, aten_add_tensor_1)
```
Without this fix the lifetimes of placeholders a and b are:
`a => [0, 2]`
`b => [3, 7]`
Thus the same memory segment is allocated for both of them.
After this fix the lifetimes of the placeholders a and b are:
`a => [0, 2]`
`b => [0, 7]`
Reviewed By: JacobSzwejbka
Differential Revision: D661848491 parent a2619e1 commit a7c7528
2 files changed
+72
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
272 | 274 | | |
273 | 275 | | |
274 | 276 | | |
| |||
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
282 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
283 | 288 | | |
284 | 289 | | |
285 | 290 | | |
| |||
444 | 449 | | |
445 | 450 | | |
446 | 451 | | |
447 | | - | |
| 452 | + | |
448 | 453 | | |
449 | 454 | | |
450 | 455 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
593 | 594 | | |
594 | 595 | | |
595 | 596 | | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
0 commit comments