
    Ǆg                        d dl mZmZ d dlmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZ  e       ZdZ G d de      Z e       Z e       Z G d	 d
e      Zd Zd Zd Zd Zd Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z eed<   eed<   eed<   eed<   eed<   eed<   eed <   e ed!<    ee"      Z!ed   Z"ee!e"<   eee"<   y#)$    )ABCabstractmethod)DelayedRegistryCPUDispatcher)jit)InternalTargetMismatchErrorNonexistentTargetError)localcpuc                        e Zd Z fdZ xZS )_TargetRegistryc                    	 t         |   |      S # t        $ rf d}dj                  t        j                         D cg c]  \  }}|dd dd|  nc c}}w c}}      }t        |j                  ||            d w xY w)Nz7No target is registered against '{}', known targets:
{}
z <
    z -> )super__getitem__KeyErrorjointarget_registryitemsr	   format)selfitemmsgkvknown	__class__s         c/home/mcse/projects/flask_80/flask-venv/lib/python3.12/site-packages/numba/core/target_extension.pyr   z_TargetRegistry.__getitem__   s    	L7&t,, 	LLCII+:+@+@+BD#'1a #$Brd 74s3 D D EE(D%)@AtK		Ls    -BA,B)__name__
__module____qualname__r   __classcell__)r   s   @r    r   r      s    L L    r   c                   "    e Zd ZdZd Zd Zd Zy)target_overridezWContext manager to temporarily override the current target with that
       prescribed.c                 F    t        t        dt              | _        || _        y )Ntarget)getattr_active_context_active_context_default_orig_targetr)   )r   names     r    __init__ztarget_override.__init__#   s    #OX$;=r%   c                 .    | j                   t        _         y N)r)   r+   r   s    r    	__enter__ztarget_override.__enter__(   s    !%r%   c                 .    | j                   t        _        y r1   )r-   r+   r)   )r   tyvaltbs       r    __exit__ztarget_override.__exit__+   s    !%!2!2r%   N)r!   r"   r#   __doc__r/   r3   r8    r%   r    r'   r'       s    
-3r%   r'   c                  ,    t        t        dt              S )zReturns the current target
    r)   )r*   r+   r,   r:   r%   r    current_targetr<   /   s     ?H.EFFr%   c                     t        | j                  j                        dkD  r| j                  d   j                  }nt        j                  t               d      }|d}t        |j                  |            |S )za
    Gets the local target from the call stack if available and the TLS
    override if not.
    r   Nz7The target found is not registered.Given target was {}.)	len	callstack_stackr)   r   getr<   
ValueErrorr   )contextr)   r   s      r    get_local_targetrD   5   sm     7##$q(""1%,, $$^%5t<~&F+,,r%   c                     t         |    S )z<Resolves a target specified as a string to its Target class.)r   )
target_strs    r    resolve_target_strrG   G   s    :&&r%   c                 *    t        |       }t        |   S )z6Returns the dispatcher associated with a target string)rG   dispatcher_registry)rF   	target_hws     r    resolve_dispatcher_from_strrK   L   s    ":.Iy))r%   c                 n    t        |      }t        |       }|j                  |      st        |||      |S )a  Returns the local target if it is compatible with the given target
    name during a type resolution; otherwise, raises an exception.

    Parameters
    ----------
    tyctx: typing context
    hwstr: str
        target name to check against
    reason: str
        Reason for the resolution. Expects a noun.
    Returns
    -------
    target_hw : Target

    Raises
    ------
    InternalTargetMismatchError
    )rG   rD   inherits_fromr   )tyctxhwstrreasonhw_clazzrJ   s        r    _get_local_target_checkedrR   R   s;    ( "%(H 'I""8,)&)XFFr%   c                       e Zd Zed        Zy)JitDecoratorc                     t         S r1   )NotImplementedr2   s    r    __call__zJitDecorator.__call__q   s    r%   N)r!   r"   r#   r   rW   r:   r%   r    rT   rT   o   s     r%   rT   c                        e Zd ZdZed        Zy)Targetz Implements a target c                     t        | |      S )zAReturns True if this target inherits from 'other' False otherwise)
issubclass)clsothers     r    rM   zTarget.inherits_fromy   s     #u%%r%   N)r!   r"   r#   r9   classmethodrM   r:   r%   r    rY   rY   v   s    & &r%   rY   c                       e Zd ZdZy)GenericzmMark the target as generic, i.e. suitable for compilation on
    any target. All must inherit from this.
    Nr!   r"   r#   r9   r:   r%   r    r`   r`          r%   r`   c                       e Zd ZdZy)CPUzMark the target as CPU.
    Nra   r:   r%   r    rd   rd          r%   rd   c                       e Zd ZdZy)GPUzOMark the target as GPU, i.e. suitable for compilation on a GPU
    target.
    Nra   r:   r%   r    rg   rg      rb   r%   rg   c                       e Zd ZdZy)CUDAzMark the target as CUDA.
    Nra   r:   r%   r    ri   ri      re   r%   ri   c                       e Zd ZdZy)NPyUfunczMark the target as a ufunc
    Nra   r:   r%   r    rk   rk      re   r%   rk   genericgpucudanpyufunc)key_typeN)#abcr   r   numba.core.registryr   r   numba.core.decoratorsr   numba.core.errorsr   r	   	threadingr
   tlsr+   r,   r   r   jit_registryobjectr'   r<   rD   rG   rK   rR   rT   rY   r`   rd   rg   ri   rk   rI   
cpu_targetr:   r%   r    <module>rz      s?   # > %7 " % 	Lo 	L "#  3f 3G$'
*:3 &S &f ' 
' 3 
v 
 %	       &
 %v6  U#
"/ J Z r%   