
    i                     \    S SK r S SKrS SKJrJrJrJr  S SKJrJ	r	  S SK
Jr   " S S5      rg)    N)CallableDictListOptional)ExportErrorExportErrorTypePassTypec                       \ rS rSr% Sr0 r\\\\	   4   \
S'   \ SS\\   S\\	/\	4   4S jj5       r\S\S\\	   SS4S	 j5       r\S
\S\\	   4S j5       rSrg)PassRegistry   uF  
Allows passes to be automatically registered into a global registry, and
users to search within the registry by the pass’s string name to get a pass.

Attributes:
    registry: A dictionary of names of passes mapping to a list of passes in
    the form of callable functions or PassBase instances (which are also callable)
registryN	pass_namereturnc                 4   ^ ^ S[         S[         4U U4S jjnU$ )aF  
A decorator used on top of passes to insert a pass into the registry. If
pass_name is not specified, then it will be generated based on the name
of the function passed in.

This decorator can be used on top of functions (with type
PassManagerParams * torch.fx.GraphModule -> None) or on top of PassBase
subclasses instances.
one_passr   c                    > TnU(       d0  [         R                  " SSU R                  5      R                  5       nTR	                  X/5        U $ )Nz(?<!^)(?=[A-Z])_)resub__name__lowerregister_list)r   keyclsr   s     c/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/executorch/exir/passes/pass_registry.pywrapper&PassRegistry.register.<locals>.wrapper,   sB    Cff/h6G6GHNNPc:.O    r	   )r   r   r   s   `` r   registerPassRegistry.register   s"    	h 	8 	 	 r   	pass_listc                 r    XR                   ;   a  [        R                  " SU S3SS9  gX R                   U'   g)z
A function used to insert a list of passes into the registry. The pass
can be searched for in the registry according to the given pass name.
Pass z8 already exists inside of the PassRegistry. Will ignore.   )
stacklevelN)r   warningswarn)r   r   r"   s      r   r   PassRegistry.register_list6   s;     $MM	{"Z[ "+Yr   r   c                 ~    XR                   ;  a  [        [        R                  SU S35      eU R                   U   nU$ )z
Gets the pass corresponding to the given name. If the pass is a function
then it will directly return the callable function.

Args:
    key: The name of a pass

Return:
    A callable pass or a list of callable passes
r$   z+ does not exists inside of the PassRegistry)r   r   r   MISSING_PROPERTY)r   r   
pass_founds      r   getPassRegistry.getF   sG     ll"00uGH 
 \\#&
r    )N)r   
__module____qualname____firstlineno____doc__r   r   strr   r
   __annotations__classmethodr   r   r    r   r-   __static_attributes__r/   r   r   r   r      s     +-Hd3X&',(, 	8*h&	' . ,c ,d8n , , , c d8n  r   r   )r   r'   typingr   r   r   r   executorch.exir.errorr   r   executorch.exir.pass_managerr
   r   r/   r   r   <module>r;      s%    
  1 1 > 1G Gr   