2424from  executorch .exir ._serialize .data_serializer  import  DataSerializer 
2525from  executorch .exir ._warnings  import  experimental 
2626from  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 
3128from  executorch .exir .capture ._config  import  EdgeCompileConfig , ExecutorchBackendConfig 
3229from  executorch .exir .delegate  import  executorch_call_delegate , is_lowered_module 
3330from  executorch .exir .emit  import  emit_program , EmitterOutput 
@@ -1442,29 +1439,20 @@ def transform(
14421439
14431440    @et_logger ("to_backend" ) 
14441441    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 ]]
14521443    ) ->  "EdgeProgramManager" :
14531444        """ 
14541445        Returns a semantically-equivalent program to the one given as input, 
14551446        but with portions of each program in the EdgeProgramManager targeted 
14561447        for delegation as determined by the partitioner. 
14571448
14581449        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. 
14681456
14691457                The Partitioner subclass instance is in charge with tagging portions of the 
14701458                input program for delegation. A valid partitioner must return PartitionerResult including valid 
@@ -1480,19 +1468,13 @@ def to_backend(
14801468        if  isinstance (partitioner , dict ):
14811469            for  name , program  in  self ._edge_programs .items ():
14821470                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 ])
14871472                else :
14881473                    new_edge_programs [name ] =  program 
14891474
14901475        else :  # apply partitioner to every method 
14911476            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 )
14961478
14971479        config  =  EdgeCompileConfig (_check_ir_validity = False )
14981480        return  EdgeProgramManager (
0 commit comments