Commit 5f76e91
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]1 file changed
+2
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1278 | 1278 | | |
1279 | 1279 | | |
1280 | 1280 | | |
1281 | | - | |
1282 | 1281 | | |
1283 | 1282 | | |
1284 | 1283 | | |
| |||
1353 | 1352 | | |
1354 | 1353 | | |
1355 | 1354 | | |
1356 | | - | |
| 1355 | + | |
1357 | 1356 | | |
1358 | 1357 | | |
1359 | 1358 | | |
| |||
1365 | 1364 | | |
1366 | 1365 | | |
1367 | 1366 | | |
1368 | | - | |
| 1367 | + | |
1369 | 1368 | | |
1370 | 1369 | | |
1371 | 1370 | | |
| |||
0 commit comments