Commit 4127895
committed
Update on "[ExecuTorch][to_backend] Enable passing Delegation Spec to to_backend"
Support Entire Graph Delegation Flow through EdgeProgramManager's to_backend.
### Motivation
A current usecase for backend lowering is through the `to_backend(backend_id, exported_program, compile_spec)` API which lowers the entire exported program to the specified backend_id. However, lowering via the EdgeProgramManager only allows for partitioner based lowering. the EdgeProgramManager is the main component which enables support for multiple methods, as a result backends which leverage the old `to_backend(backend_id, ...)` api can not export executorch models with multiple methods.
### Design
We override EdgeProgramManager to also allow Partitioner to be replaceable by DelegationSpec. DelegationSpec is essentially a wrapper around the backend_id and the compile_spec, so any where a partitioenr is specified to lower a graph, the delegation spec can also be used to do entier graph lowering.
### Intended Flow
```
del_spec = DelegationSpec("BackendWithCompilerDemo", [CompileSpec(...)])
encode_graph = torch.export.export(Encoder(), sample_inputs)
decode_graph = torch.export.export(Decoder(), sample_inputs)
edge_manager = to_edge({
"encode": encode_graph,
"decode": decode_graph,
})
lowered_edge_manager = edge_manager.to_backend(del_spec)
# or if you want to specify which methods to lower to with del_spec
lowered_edge_manager= edge_manager.to_backend({
"encode": del_spec,
})
```
Differential Revision: [D69086565](https://our.internmc.facebook.com/intern/diff/D69086565/)
cc cccclai
[ghstack-poisoned]File tree
2 files changed
+6
-5
lines changed- exir/backend
- canonical_partitioners
- test
2 files changed
+6
-5
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1278 | 1278 | | |
1279 | 1279 | | |
1280 | 1280 | | |
1281 | | - | |
| 1281 | + | |
1282 | 1282 | | |
1283 | 1283 | | |
1284 | 1284 | | |
| |||
1372 | 1372 | | |
1373 | 1373 | | |
1374 | 1374 | | |
1375 | | - | |
| 1375 | + | |
1376 | 1376 | | |
1377 | 1377 | | |
1378 | 1378 | | |
1379 | 1379 | | |
1380 | 1380 | | |
1381 | 1381 | | |
1382 | | - | |
| 1382 | + | |
1383 | 1383 | | |
1384 | 1384 | | |
1385 | 1385 | | |
| |||
1430 | 1430 | | |
1431 | 1431 | | |
1432 | 1432 | | |
1433 | | - | |
1434 | | - | |
| 1433 | + | |
| 1434 | + | |
1435 | 1435 | | |
1436 | 1436 | | |
1437 | 1437 | | |
| |||
0 commit comments