
    Pi              	          d dl mZ d dlmZ d dlmZ d dlmZmZ d dl	m
Z
mZmZmZmZ d dlmZ  e
d          Zdd	gZ G d
 de          Z G d dee                   Z	 dddddddddddZdS )     )annotations)	ASTSource)Language)JITFunctionconstexpr_function)TypeVarOptionalCallableIterableUnion)irTr   jitc                  (     e Zd Zdd fdZd Z xZS )GluonASTSourceNreturnNonec                    t                                          ||||           t          j        | _        d| _        d S )Nttgir)super__init__r   GLUONlanguageext)selffn	signature
constexprsattrs	__class__s        z/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/triton/experimental/gluon/_runtime.pyr   zGluonASTSource.__init__   s5    Y
E:::     c           	        ddl m} ddlm} t	          j        |          }|                                }	 ||          }
|
                    |          }|	                    d|	                    |                     |	                    d|
                    |j                             |	                    d|
                    |j                             |	                    d|
                    |j                             |j        dk    }|r5|j        .|	                    d	|
                    |j                              || j        | |||||	
          }	|	S )Nr   )make_backend)ast_to_ttirz
ttg.targetzttg.num-warpszttg.num-ctaszttg.threads-per-warpcudazttg.maxnreg)contextoptionscodegen_fns
module_mapmodule)triton.compiler.compilerr$   triton.compiler.code_generatorr%   r   buildercreate_moduleget_target_nameset_attrget_string_attrget_int32_attr	num_warpsnum_ctas	warp_sizebackend_namemaxnregr   )r   targetr(   r)   r*   r'   r$   r%   r.   r+   backendis_cudas               r!   make_irzGluonASTSource.make_ir   sm   999999>>>>>>*W%%&&(( ,v&&((11g&=&=f&E&EFFF)?)?@Q)R)RSSS(>(>w?O(P(PQQQ.0F0FwGX0Y0YZZZ&&0 	Tw2OOM7+A+A'/+R+RSSSTWdGWZe(26C C Cr"   )NN)r   r   )__name__
__module____qualname__r   r<   __classcell__r    s   @r!   r   r      sQ              
      r"   r   c                  $     e Zd Z fdZd Z xZS )GluonJITFunctionc                `    t                                                      }t          | _        |S N)r   create_binderr   r   )r   resultr    s     r!   rF   zGluonJITFunction.create_binder/   s$    &&(('r"   c                    dS )NT )r   s    r!   is_gluonzGluonJITFunction.is_gluon4   s    tr"   )r=   r>   r?   rF   rJ   r@   rA   s   @r!   rC   rC   -   sG            
      r"   rC   N)versionreprlaunch_metadatado_not_specializedo_not_specialize_on_alignmentdebugnoinliner   Optional[T]rL   Optional[Callable]rM   rN   Optional[Iterable[int | str]]rO   rP   Optional[bool]rQ   r   9Union[GluonJITFunction[T], Callable[[T], JITFunction[T]]]c               F    dfd}|  ||           S |S )a<  
    Decorator for JIT-compiling a function using the Triton compiler.

    :note: When a jit'd function is called, arguments are
        implicitly converted to pointers if they have a :code:`.data_ptr()` method
        and a `.dtype` attribute.

    :note: This function will be compiled and run on the GPU. It will only have access to:

           * python primitives,
           * builtins within the triton package,
           * arguments to this function,
           * other jit'd functions

    :param fn: the function to be jit-compiled
    :type fn: Callable
    r   r   r   JITFunction[T]c           
     T    t          |           sJ t          |           S )N)rK   rN   rO   rP   rQ   rL   rM   )callablerC   )r   rP   rN   rO   rM   rQ   rL   rK   s    r!   	decoratorzjit.<locals>.decoratorU   sD    ||/+I+	
 	
 	
 		
r"   N)r   r   r   rX   rI   )	r   rK   rL   rM   rN   rO   rP   rQ   r[   s	    ``````` r!   r   r   8   sb    :
 
 
 
 
 
 
 
 
 
 
 
 
~y}} r"   rE   )r   rR   rL   rS   rM   rS   rN   rT   rO   rT   rP   rU   rQ   rU   r   rV   )
__future__r   r,   r   triton.backends.compilerr   triton.runtime.jitr   r   typingr   r	   r
   r   r   triton._C.libtritonr   r   __all__r   rC   r   rI   r"   r!   <module>rb      sH   " " " " " " . . . . . . - - - - - - > > > > > > > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? " " " " " "GCLL
'    Y   @    {1~    . #*.7;DH #. . . . . . . .r"   