add duplicate constant node pass (#2570)
Summary:
Pull Request resolved: https://github.com/pytorch/executorch/pull/2570
This diff is the follow up for https://github.com/pytorch/executorch/pull/2424
In the case like
```
consant_0 (tag_10) ----> op_b (tag_10)
|-------------> op_a (tag_11)
```
`op_b` and `op_a` are in two delegated payload and `constant_0` have two options:
In this diff, we're making the default behavior as allowing copying, meaning it will become
```
consant_0 (tag_10)------------------> op_b (tag_10)
consant_0_copy (tag_11) -------------> op_a (tag_11)
```
The backend can tag the node with `no_copy` to allert users in cases like constants are too large or etc. In this case, a better approach can be
```
consant_0 (tag_10) ----> op_b (tag_10)
|-----(output consant_0) --------> op_a (tag_11)
```
Reviewed By: angelayi
Differential Revision: D55113232
fbshipit-source-id: 49559a8cc8225b866a399b4db04ef59fc6860cc1 C
Chen Lai committed
7f96f5a852ba452670255d28d59f1e6398141fbb
Parent: e603f4f
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 3/25/2024, 12:10:57 AM