
    i>                         S SK JrJrJrJrJr  S SKrS SKJr  S SK	J
r
  S SKJrJrJr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr   " S S\5      r\ " S S\5      5       rg)    )CallablefinalListOptionalTupleN)NeuropilotBackend)CompileSpec)DelegationSpecPartitionerPartitionResult)tag_constant_data)importer_v2)ExportedProgram)CapabilityBasedPartitioner)OperatorSupportBasec                   x    \ rS rSr  S
S\\   S\\   SS4S jjrS\R                  R                  S\
4S jrS	rg)NeuropilotOperatorsSupport   Nop_types_to_skipop_names_to_skipreturnc                 P    Uc
  [        5       nUc
  [        5       nXl        X l        g N)set_op_types_to_skip_op_names_to_skip)selfr   r   s      g/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/executorch/backends/mediatek/partitioner.py__init__#NeuropilotOperatorsSupport.__init__   s,    
 #"u#"u!1!1    nodec                    UR                   S:w  a  gUR                  R                  nUS:X  a  gX0R                  ;   d  UR                  U R
                  ;   a  [        SU SUR                   S35        g[        R                  " U5      $ )Ncall_functionFzaten._to_copy.defaultz[Neuropilot Backend] The z operator with name 'z' is skipped.)	optarget__name__r   namer   printr   is_fx_node_supported)r   _r"   op_types       r   is_node_supported,NeuropilotOperatorsSupport.is_node_supported(   s     77o%++&& --,,,		T=S=S0S+G94I$))Tab //55r!   )r   r   NN)r'   
__module____qualname____firstlineno__r   r   r   torchfxNodeboolr-   __static_attributes__ r!   r   r   r      sN     +/*.2"3-2 #3-2 
	26 64 6r!   r   c            	           \ rS rSr  SS\\   S\\   S\\   SS4S jjrS\	S\
\\R                  R                     \\\R                  R                   /\4      4   4S	 jrS
\	S\4S jrSrg)NeuropilotPartitioner=   Ncompile_specr   r   r   c                 Z    [        [        R                  U5      U l        X l        X0l        g r   )r
   r   r'   delegation_specr   r   )r   r<   r   r   s       r   r   NeuropilotPartitioner.__init__@   s&      ..?.H.H,W!1!1r!   epc                 *   [         R                  R                  R                  R                  [         R                  R                  R
                  R                  [         R                  R                  R
                  R                  [         R                  R                  R                  R                  [         R                  R                  R                  R                  [         R                  R                  R                  R                  /nUS 4$ r   )	r3   opsatenpixel_shuffledefaultupsample_bilinear2dvecupsample_nearest2d_safe_softmax)r   r@   ops_not_decomposes      r   ops_to_not_decompose*NeuropilotPartitioner.ops_to_not_decomposeJ   s    
 IINN((00IINN..66IINN..22IINN--55IINN--11IINN((00
 "4((r!   exported_programc                 B   [        UR                  [        U R                  U R                  5      SS9nUR                  5       n0 nU HA  nUR                   H.  nSUR                   3nXvR                  S'   U R                  XG'   M0     MC     [        U5        [        XS9$ )NT)allows_single_node_partitiontagdelegation_tag)tagged_exported_programpartition_tags)r   graph_moduler   r   r   propose_partitionsnodesidmetar>   r   r   )r   rM   capability_partitionerpartition_listrS   	partitionr"   rP   s           r   r[   NeuropilotPartitioner.partitionX   s    !;))&t'='=t?U?UV)-"

 0BBD'I!ILL>*.1		*+&*&:&:# ( ( 	*+$4
 	
r!   )r   r   r>   r/   )r'   r0   r1   r2   r   r	   r   r   r   r   r   r3   _ops
OpOverloadr   r4   r5   r6   rK   r   r[   r7   r8   r!   r   r:   r:   =   s     +/*.	2;'2 #3-2 #3-	2
 
2)) 
tEJJ))*HXuxx}}ot>S5T,UU	V)
/ 
o 
r!   r:   )typingr   r   r   r   r   r3   'executorch.backends.mediatek.preprocessr   'executorch.exir.backend.backend_detailsr	   #executorch.exir.backend.partitionerr
   r   r   executorch.exir.backend.utilsr   'mtk_converter.python.converters.pytorchr   torch.export.exported_programr   !torch.fx.passes.infra.partitionerr    torch.fx.passes.operator_supportr   r   r:   r8   r!   r   <module>rh      sZ    : 9  E ? 
 < ? 9 H @!6!4 !6H -
K -
 -
r!   