
    rhC              	          d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZmZmZ d dlmZ  e
d      Z G d	 d
e      Z G d dee         Z	 ddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)    )annotationsN)	ASTSource)Language)JITFunction)TypeVarOptionalCallableIterableUnion)irTc                  (     e Zd Zdd fdZd Z xZS )GluonASTSourcec                b    t         |   ||||       t        j                  | _        d| _        y )Nttgir)super__init__r   GLUONlanguageext)selffn	signature
constexprsattrs	__class__s        u/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/triton/experimental/gluon/_runtime.pyr   zGluonASTSource.__init__   s(    Y
E:     c           	        ddl m} ddlm} t	        j
                  |      }|j                         }t        j                  j                  j                  j                         }	 ||	      }
|
j                  |      }	|j                  d|j                  |	             |j                  d|j                  |j                                |j                  d|j                  |j"                               |j                  d|j                  d             |j$                  +|j                  d	|j                  |j$                                || j&                  | |||||
      }|S )Nr   )make_backend)ast_to_ttirz
ttg.targetzttg.num-warpszttg.num-ctaszttg.threads-per-warp    zttg.maxnreg)contextoptionscodegen_fns
module_mapmodule)triton.compiler.compilerr    triton.compiler.code_generatorr!   r   buildercreate_moduletritonruntimedriveractiveget_current_targetget_target_nameset_attrget_string_attrget_int32_attr	num_warpsnum_ctasmaxnregr   )r   r$   r%   r&   r#   r    r!   r*   r'   targetbackends              r   make_irzGluonASTSource.make_ir   s   9>**W%&&( &&--@@Bv&((1g&=&=f&EF)?)?@Q@Q)RS(>(>w?O?O(PQ.0F0Fr0JK??&OOM7+A+A'//+RSTWWdGWZe(26Cr   )NN)returnNone)__name__
__module____qualname__r   r:   __classcell__r   s   @r   r   r      s    
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                     y)NT )r   s    r   is_gluonzGluonJITFunction.is_gluon1   s    r   )r=   r>   r?   rF   rJ   r@   rA   s   @r   rC   rC   *   s    
r   rC   )versionreprlaunch_metadatado_not_specializedo_not_specialize_on_alignmentdebugnoinlinec               @    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
    c           
     D    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>.decoratorR   s4    ||/+I+	
 		
r   )r   r   r;   zJITFunction[T]rI   )	r   rK   rL   rM   rN   rO   rP   rQ   rU   s	    ``````` r   jitrV   5   s&    :
 
 
~} r   rE   )r   zOptional[T]rL   Optional[Callable]rM   rW   rN   Optional[Iterable[int | str]]rO   rX   rP   Optional[bool]rQ   rY   r;   z9Union[GluonJITFunction[T], Callable[[T], JITFunction[T]]])
__future__r   r,   r(   r   triton.backends.compilerr   triton.runtime.jitr   typingr   r   r	   r
   r   triton._C.libtritonr   r   r   rC   rV   rI   r   r   <module>r_      s    "  . - * ? ? "CLY <{1~  . #*.7;DH #.. 	.
 (. 5. %B. . . ?.r   