o
    ZÛ·i  ã                   @   s8   d dl mZ d dlmZ G dd„ dƒZG dd„ dƒZdS )é    )Únumpy_support)Útypesc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚUfuncLowererBasezHCallable class responsible for lowering calls to a specific gufunc.
    c                 C   s    || _ || _||ƒ| _g | _d S ©N)ÚufuncÚmake_ufunc_kernel_fnÚkernelÚlibs)Úselfr   Úmake_kernel_fnr   © r   úO/home/ubuntu/vllm_env/lib/python3.10/site-packages/numba/np/ufunc/ufunc_base.pyÚ__init__   s   

zUfuncLowererBase.__init__c                 C   s   |   ||||| j| j¡S r   )r   r   r   )r
   ÚcontextÚbuilderÚsigÚargsr   r   r   Ú__call__   s   ÿzUfuncLowererBase.__call__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      s    r   c                   @   s¶   e Zd Zedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZed	d
„ ƒZedd„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdd„ Zd dd„Zdd„ ZdS )!Ú	UfuncBasec                 C   ó   | j jS r   )r   Únin©r
   r   r   r   r      ó   zUfuncBase.ninc                 C   r   r   )r   Únoutr   r   r   r   r      r   zUfuncBase.noutc                 C   r   r   )r   Únargsr   r   r   r   r      r   zUfuncBase.nargsc                 C   r   r   )r   Úntypesr   r   r   r   r   !   r   zUfuncBase.ntypesc                 C   r   r   )r   r   r   r   r   r   r   %   r   zUfuncBase.typesc                 C   r   r   )r   Úidentityr   r   r   r   r    )   r   zUfuncBase.identityc                 C   r   r   )r   Ú	signaturer   r   r   r   r!   -   r   zUfuncBase.signaturec                 C   r   r   )r   Ú
accumulater   r   r   r   r"   1   r   zUfuncBase.accumulatec                 C   r   r   )r   Úatr   r   r   r   r#   5   r   zUfuncBase.atc                 C   r   r   )r   Úouterr   r   r   r   r$   9   r   zUfuncBase.outerc                 C   r   r   )r   Úreducer   r   r   r   r%   =   r   zUfuncBase.reducec                 C   r   r   )r   Úreduceatr   r   r   r   r&   A   r   zUfuncBase.reduceatc                 C   s   t | jjƒdks
J ‚d| _dS )zI
        Disable the compilation of new signatures at call time.
        r   TN)ÚlenÚ_dispatcherÚ	overloadsÚ_frozenr   r   r   r   Údisable_compileE   s   
zUfuncBase.disable_compileNc                    sh   |du r	ˆ j jj}tj}tj}|fˆ jj |fˆ jj  }|fˆ jj }| 	‡ fdd„||fD ƒ¡ dS )a4  
        Install an implementation function for a GUFunc/DUFunc object in the
        given target context.  If no target context is given, then
        _install_cg() installs into the target context of the
        dispatcher object (should be same default context used by
        jit() and njit()).
        Nc                    s   g | ]}ˆ j ˆ |f‘qS r   )Ú	_lower_me)Ú.0r   r   r   r   Ú
<listcomp>]   s    z)UfuncBase._install_cg.<locals>.<listcomp>)
r(   ÚtargetdescrÚtarget_contextr   ÚAnyÚArrayr   r   r   Úinsert_func_defn)r
   Ú	targetctxÚ_anyÚ_arrÚsig0Úsig1r   r   r   Ú_install_cgM   s   
ÿzUfuncBase._install_cgc                 C   sl   | j rt | |¡}|du rdS t|j|j ƒdt|ƒ… }| jj 	¡ D ]\}}|  
||¡r3||f  S q#dS )a  
        Given a tuple of element-wise argument types, find a matching
        signature in the dispatcher.

        Return a 2-tuple containing the matching signature, and
        compilation result.  Will return two None's if no matching
        signature was found.
        N)NN)r*   r   Úufunc_find_matching_loopÚtupleÚinputsÚoutputsr'   r(   r)   ÚitemsÚmatch_signature)r
   Úewise_typesÚloopr   Úcresr   r   r   Úfind_ewise_function_   s   	ÿzUfuncBase.find_ewise_functionr   )r   r   r   Úpropertyr   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r+   r9   rC   r   r   r   r   r      s8    












r   N)Únumba.npr   Ú
numba.corer   r   r   r   r   r   r   Ú<module>   s    