
    Pg                     .    d dl Z d dlmZ 	  G d d      Zy)    Nc                   v    e Zd ZdZdZg dZg dZeez   ZddZ	 d Z		 d Z
	 d	 Z	 d
 Z	 d Z	 d Z	 d Z	 d Zy)PythonDispatcher__test__foo)CPUAutogradCPUFPGAAutogradOtherXLAAutogradXLALazyAutogradLazy)CompositeExplicitAutogradAutogradCompositeImplicitAutogradNc                     t        j                  | j                         t        j                  d| j                  d      | _        | j
                  j                  d       y )NFRAGMENT zfoo(Tensor x) -> Tensor)C_dispatch_check_invariantsname_dispatch_library	namespacerefdef_selfs    _/var/www/html/suriana-translation/venv/lib/python3.12/site-packages/torch/_python_dispatcher.py__init__zPythonDispatcher.__init__I   s?    	$$TYY/&&z4>>2F/0    c                     | j                   S N)supported_keysr   s    r   keyszPythonDispatcher.keysS   s    """r    c                 *   t        t        |            t        |      k7  rt        d| d      d|v rd|v rt        d      |D ]L  }|| j                  vrt        | d| j                   d      | j                  j                  d|d|z   	       N y )
Nz1Overriden is not allowed but found duplicates in .r   r   z\Registration to both CompositeImplicitAutograd and CompositeExplicitAutograd is not allowed.z3 is not supported, please select a dispatch key in r   fn_)dispatchdebug)lensetRuntimeErrorr#   r   impl_t_t)r   dispatchKeyskeys      r   registerzPythonDispatcher.register^   s    s< !S%66CL>QRS 
 (<7+|;n    	FC$---"eNtObObNccde  HHecE	Fr    c                     |dd| dS )Nz<15 
 )r   r/   kernels      r   _format_linezPythonDispatcher._format_linew   s    c!F82&&r    c                 F    d| d}|| j                  dd      z  }|dz  }|S )Nr3   r/   r5   z---------------------------
)r6   )r   headerss      r   _format_headerzPythonDispatcher._format_header~   sA     	 	
Tuh//	,,r    c                 ^    t        j                  | j                   d| j                         S N::)r   _dispatch_dumpr   r   r   s    r   rawRegistrationsz!PythonDispatcher.rawRegistrations   s'    4>>"2"TYYK @AAr    c                 ^    t        j                  | j                   d| j                         S r<   )r   _dispatch_dump_tabler   r   r   s    r   rawDispatchTablez!PythonDispatcher.rawDispatchTable   s'    %%(8499+&FGGr    c                 V   | j                  d      }| j                         }|j                  d      }|D ]p  }|j                  d      d   t        fd| j                  D              s6|j                  d      d   j                  d      d   }|| j                  |      z  }r |S )	NzRegistered Kernelsr3   :r   c              3   @   K   | ]  }j                  |        y wr"   )
startswith).0kfirsts     r   	<genexpr>z1PythonDispatcher.registrations.<locals>.<genexpr>   s     D15##A&Ds   r=   r2      )r:   r?   splitanyr#   r6   )r   outputstatestate_entriesliner5   rI   s         @r   registrationszPythonDispatcher.registrations   s    $$%9:%%'D)! 	;DJJsOA&ED0C0CDDD)!,2237:$++E6::		;
 r    c                 Z   | j                  d      }| j                         }|j                  d      }t        j                  d      }|D ]^  }|j                  d      d   }|| j
                  v s&|j                  d|      }|| j                  ||j                  d      d         z  }` |S )	NzComputed Dispatch Tabler3   z)registered at .*FallbackKernel\.cpp.*(\[)rD   r   [z: rK   )r:   rB   rL   recompileruntime_keyssubr6   )r   rN   tabletable_entriesregexrQ   rH   entrys           r   dispatchTablezPythonDispatcher.dispatchTable   s    $$%>?%%'D)

GH! 	ED

3"AD%%%		#t,$++Au{{4/@/CDD		E
 r    )returnN)__name__
__module____qualname__r   r   rW   
alias_keysr#   r   r$   r0   r6   r:   r?   rB   rR   r]   r4   r    r   r   r   7   s~    IDLJ
 "J.N1

#F*'
B
H
	
r    r   )rU   torch._C_Cr   r   r4   r    r   <module>re      s    	 -` r    