
    S3j                        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        $ re d}dj                  t        j                         D cg c]  \  }}|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         H/DATA/.local/lib/python3.12/site-packages/numba/core/target_extension.pyr   z_TargetRegistry.__getitem__   s    	L7&t,, 	LLCII+:+@+@+BD+B41a #$Brd74s3+B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 r0   )r,   r*   r(   )r   tyvaltbs       r   __exit__ztarget_override.__exit__+   s    !%!2!2r$   N)r    r!   r"   __doc__r.   r2   r7    r$   r   r&   r&       s    
-3r$   r&   c                  ,    t        t        dt              S )zReturns the current target
    r(   )r)   r*   r+   r9   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_targetrC   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_strrF   G   s    :&&r$   c                 *    t        |       }t        |   S )z6Returns the dispatcher associated with a target string)rF   dispatcher_registry)rE   	target_hws     r   resolve_dispatcher_from_strrJ   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
    )rF   rC   inherits_fromr   )tyctxhwstrreasonhw_clazzrI   s        r   _get_local_target_checkedrQ   R   s;    ( "%(H 'I""8,)&)XFFr$   c                       e Zd Zed        Zy)JitDecoratorc                     t         S r0   )NotImplementedr1   s    r   __call__zJitDecorator.__call__q   s    r$   N)r    r!   r"   r   rV   r9   r$   r   rS   rS   o   s     r$   rS   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   rL   zTarget.inherits_fromy   s     #u%%r$   N)r    r!   r"   r8   classmethodrL   r9   r$   r   rX   rX   v   s    & &r$   rX   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"   r8   r9   r$   r   r_   r_          r$   r_   c                       e Zd ZdZy)CPUzMark the target as CPU.
    Nr`   r9   r$   r   rc   rc          r$   rc   c                       e Zd ZdZy)GPUzOMark the target as GPU, i.e. suitable for compilation on a GPU
    target.
    Nr`   r9   r$   r   rf   rf      ra   r$   rf   c                       e Zd ZdZy)CUDAzMark the target as CUDA.
    Nr`   r9   r$   r   rh   rh      rd   r$   rh   c                       e Zd ZdZy)NPyUfunczMark the target as a ufunc
    Nr`   r9   r$   r   rj   rj      rd   r$   rj   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;   rC   rF   rJ   rQ   rS   rX   r_   rc   rf   rh   rj   rH   
cpu_targetr9   r$   r   <module>ry      s?   # > %7 " % 	Lo 	L "#  3f 3G$'
*:3 &S &f ' 
' 3 
v 
 %	       &
 %v6  U#
"/ J Z r$   