
    0;jiC                     x    d dl mZ d dlmZ  G d de          Z G d de          Z e            Zej        Z	dS )    )defaultdict)configc                   &    e Zd ZdZddZd Zd ZdS )Rewritez8Defines the abstract base class for Numba rewrites.
    Nc                     dS )z+Constructor for the Rewrite class.
        N )selfstates     V/root/voice-cloning/.venv/lib/python3.11/site-packages/numba/core/rewrites/registry.py__init__zRewrite.__init__
   s	     	    c                     dS )z]Overload this method to check an IR block for matching terms in the
        rewrite.
        Fr   )r	   func_irblocktypemap	calltypess        r   matchzRewrite.match   s	     ur   c                      t          d          )zgOverload this method to return a rewritten IR basic block when a
        match has been found.
        z Abstract Rewrite.apply() called!)NotImplementedErrorr	   s    r   applyzRewrite.apply   s     ""DEEEr   )N)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r      sU            
  F F F F Fr   r   c                   >    e Zd ZdZ eddg          Zd Zd Zd ZdS )RewriteRegistryz+Defines a registry for Numba rewrites.
    zbefore-inferencezafter-inferencec                 8    t          t                    | _        dS )ziConstructor for the rewrite registry.  Initializes the rewrites
        member to an empty list.
        N)r   listrewritesr   s    r   r   zRewriteRegistry.__init__!   s     $D))r   c                 L      j         vrt          d           fd}|S )zf
        Decorator adding a subclass of Rewrite to the registry for
        the given *kind*.
        zinvalid kind c                     t          | t                    s"t          d                    |                     j                                     |            | S )Nz {0} is not a subclass of Rewrite)
issubclassr   	TypeErrorformatr    append)rewrite_clskindr	   s    r   do_registerz-RewriteRegistry.register.<locals>.do_register.   s^    k733 " B I I!! !! " " "M$&&{333r   )_kindsKeyError)r	   r(   r)   s   `` r   registerzRewriteRegistry.register'   sN    
 t{""(6777	 	 	 	 	 	 r   c                    || j         v sJ |j        j        }|                                }| j        |         D ]A} ||          }t          |                                          }|r|                                \  }}	|                    |j        |	|j	        |j
                  }
|
rt          j        st          j        rIt          d           t          d|j        z             |	                                 t          d           |                                }|||<   |                    ||f           t          j        st          j        r#|                                 t          d           |C|                                D ]%\  }}	|	||         k    r|	                                 &ddlm} |                    |j                  }|                                 dS )zGiven a pipeline and a dictionary of basic blocks, exhaustively
        attempt to apply all registered rewrites to all basic blocks.
        F______________________________________________________________________zREWRITING (%s):<____________________________________________________________r   )postprocN)r*   r   blockscopyr    r   itemspopr   r   r   r   DEBUGDUMP_IRprintr   dumpr   r&   verify
numba.corer0   PostProcessorrun)r	   r(   r
   r1   
old_blocksr'   rewrite	work_listkeyr   matches	new_blockr0   	post_procs                 r   r   zRewriteRegistry.apply6   s    t{""""%[[]]
=. 	( 	(K!k%((GV\\^^,,I (&]]__
U!--uem(-9 9 (| (v~ (h/+2FFGGG

h 'I"+F3K$$c9%5666| (v~ (!(((h  (" !,,.. 	 	JC
3'' 	('''''**5=99	r   N)	r   r   r   r   	frozensetr*   r   r,   r   r   r   r   r   r      sa         Y*,=>??F* * *  ( ( ( ( (r   r   N)
collectionsr   r:   r   objectr   r   rewrite_registryr,   register_rewriter   r   r   <module>rI      s    # # # # # #      F F F F Ff F F F,B B B B Bf B B BJ #?$$ #,   r   