
    c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y)    )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 )GluonASTSourcec                b    t         |   ||||       t        j                  | _        d| _        y )Nttgir)super__init__r   GLUONlanguageext)selffn	signature
constexprsattrs	__class__s        \/var/www/html/engine/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                         }	 ||      }
|
j                  |      }|	j                  d|j                  |             |	j                  d|j                  |j                               |	j                  d|j                  |j                               |	j                  d|j                  |j                               |j                  dk(  }|r7|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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   s   9>**W%&&( v&((1g&=&=f&EF)?)?@Q@Q)RS(>(>w?O?O(PQ.0F0FwGXGX0YZ&&&0w2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_gluon4   s    r    )r=   r>   r?   rF   rJ   r@   rA   s   @r   rC   rC   -   s    
r    rC   N)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>.decoratorU   s4    ||/+I+	
 		
r    )r   r   r;   zJITFunction[T]rI   )	r   rK   rL   rM   rN   rO   rP   rQ   rU   s	    ``````` r   r   r   8   s&    :
 
 
~} r    rE   )r   zOptional[T]rL   Optional[Callable]rM   rV   rN   Optional[Iterable[int | str]]rO   rW   rP   Optional[bool]rQ   rX   r;   z9Union[GluonJITFunction[T], Callable[[T], JITFunction[T]]])
__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>r_      s    " . - > ? ? "CL
'Y @{1~  . #*.7;DH #.. 	.
 (. 5. %B. . . ?.r    