o
    "i                     @   s(   d dl Z d dlmZ 	 G dd dZdS )    Nc                   @   s   e Zd ZdZdZg dZg dZee Zdd Z	 dd Z		 d	d
 Z
	 dd Z	 dd Z	 dd Z	 dd Z	 dd Z	 dd ZdS )PythonDispatcherZ__test__foo)ZCPUZAutogradCPUZFPGAZAutogradOtherZXLAZAutogradXLAZLazyZAutogradLazy)CompositeExplicitAutogradZAutogradCompositeImplicitAutogradc                 C   s.   t | j t d| jd| _| jd d S )NZFRAGMENT zfoo(Tensor x) -> Tensor)CZ_dispatch_check_invariantsnameZ_dispatch_library	namespacerefZdef_self r   g/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/torch/_python_dispatcher.py__init__H   s   zPythonDispatcher.__init__c                 C   s   | j S N)supported_keysr   r   r   r   keysR   s   zPythonDispatcher.keysc                 C   s   t t|t |krtd| dd|v rd|v rtd|D ]}|| jvr2t| d| j d| jjd|d| d	 q d S )
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   Zfn_)dispatchdebug)lensetRuntimeErrorr   r
   Zimpl_t_t)r   ZdispatchKeyskeyr   r   r   register]   s    

zPythonDispatcher.registerc                 C   s   |dd| dS )Nz<15 
r   )r   r   kernelr   r   r   _format_linev   s   zPythonDispatcher._format_linec                 C   s(   d| d}||  dd7 }|d7 }|S )Nr   r   r   z---------------------------
)r   )r   headersr   r   r   _format_header}   s   zPythonDispatcher._format_headerc                 C      t | j d| j S N::)r   Z_dispatch_dumpr	   r   r   r   r   r   rawRegistrations      z!PythonDispatcher.rawRegistrationsc                 C   r"   r#   )r   Z_dispatch_dump_tabler	   r   r   r   r   r   rawDispatchTable   r&   z!PythonDispatcher.rawDispatchTablec                    sx   |  d}|  }|d}|D ])}|dd  t fdd| jD r9|dd dd	 }||  |7 }q|S )
NzRegistered Kernelsr   :r   c                 3   s    | ]}  |V  qd S r   )
startswith).0kfirstr   r   	<genexpr>   s    z1PythonDispatcher.registrations.<locals>.<genexpr>r$   r      )r!   r%   splitanyr   r   )r   outputstateZstate_entriesliner   r   r,   r   registrations   s   

zPythonDispatcher.registrationsc                 C   sr   |  d}|  }|d}td}|D ]!}|dd }|| jv r6|d|}|| ||dd 7 }q|S )	NzComputed Dispatch Tabler   z)registered at .*FallbackKernel\.cpp.*(\[)r(   r   [z: r/   )r!   r'   r0   recompileruntime_keyssubr   )r   r2   tableZtable_entriesregexr4   r+   entryr   r   r   dispatchTable   s   



zPythonDispatcher.dispatchTableN)__name__
__module____qualname__r	   r   r9   Z
alias_keysr   r   r   r   r   r!   r%   r'   r5   r>   r   r   r   r   r   6   s.    r   )r7   Ztorch._CZ_Cr   r   r   r   r   r   <module>   s    0