24
24
from executorch .exir ._serialize .data_serializer import DataSerializer
25
25
from executorch .exir ._warnings import experimental
26
26
from executorch .exir .backend .backend_api import to_backend
27
- from executorch .exir .backend .canonical_partitioners .all_node_partitioner import (
28
- AllNodePartitioner ,
29
- )
30
- from executorch .exir .backend .partitioner import DelegationSpec , Partitioner
27
+ from executorch .exir .backend .partitioner import Partitioner
31
28
from executorch .exir .capture ._config import EdgeCompileConfig , ExecutorchBackendConfig
32
29
from executorch .exir .delegate import executorch_call_delegate , is_lowered_module
33
30
from executorch .exir .emit import emit_program , EmitterOutput
@@ -1442,29 +1439,20 @@ def transform(
1442
1439
1443
1440
@et_logger ("to_backend" )
1444
1441
def to_backend (
1445
- self ,
1446
- partitioner : Union [
1447
- DelegationSpec ,
1448
- Dict [str , DelegationSpec ],
1449
- Partitioner ,
1450
- Dict [str , Partitioner ],
1451
- ],
1442
+ self , partitioner : Union [Partitioner , Dict [str , Partitioner ]]
1452
1443
) -> "EdgeProgramManager" :
1453
1444
"""
1454
1445
Returns a semantically-equivalent program to the one given as input,
1455
1446
but with portions of each program in the EdgeProgramManager targeted
1456
1447
for delegation as determined by the partitioner.
1457
1448
1458
1449
Args:
1459
- partitioner: The partitioner can be:
1460
- - Partitioner Subclass Instance; all programs in the EdgeProgramManager are lowered with
1461
- this partitioner
1462
- - Dictionary mapping method name to partitioner subclass instance; Only method names specified
1463
- in the dictionary will be lowered by the given partitioner.
1464
- - DelegationSpec; All programs are completely lowered to the backend_id specified in the
1465
- DelegationSpec
1466
- - Dictionary mapping method name to DelegationSpec; Only method names specified in the dictionary
1467
- will be lowered to the backend_id specified in the DelegationSpec
1450
+ partitioner: The partitioner can either be a Partitioner subclass instance, or a
1451
+ dictionary mapping method names to Partitioner subclass instance. If it is a
1452
+ Partitioner subclass, all programs in the given EdgeProgramManager
1453
+ will be lowered using the given partitioner. If it is a
1454
+ dictionary, only method names specified in the dictionary will be
1455
+ lowered with the given partitioner.
1468
1456
1469
1457
The Partitioner subclass instance is in charge with tagging portions of the
1470
1458
input program for delegation. A valid partitioner must return PartitionerResult including valid
@@ -1480,19 +1468,13 @@ def to_backend(
1480
1468
if isinstance (partitioner , dict ):
1481
1469
for name , program in self ._edge_programs .items ():
1482
1470
if name in partitioner .keys ():
1483
- partitioner_to_use = partitioner [name ]
1484
- if isinstance (partitioner_to_use , DelegationSpec ):
1485
- partitioner_to_use = AllNodePartitioner (partitioner_to_use )
1486
- new_edge_programs [name ] = to_backend (program , partitioner_to_use )
1471
+ new_edge_programs [name ] = to_backend (program , partitioner [name ])
1487
1472
else :
1488
1473
new_edge_programs [name ] = program
1489
1474
1490
1475
else : # apply partitioner to every method
1491
1476
for name , program in self ._edge_programs .items ():
1492
- partitioner_to_use = partitioner
1493
- if isinstance (partitioner , DelegationSpec ):
1494
- partitioner_to_use = AllNodePartitioner (partitioner )
1495
- new_edge_programs [name ] = to_backend (program , partitioner_to_use )
1477
+ new_edge_programs [name ] = to_backend (program , partitioner )
1496
1478
1497
1479
config = EdgeCompileConfig (_check_ir_validity = False )
1498
1480
return EdgeProgramManager (
0 commit comments