+
    ړLjB                    ~   ^ RI Ht ^RIHtHt ^RIHt ^RIHt ]R 4       t]R 4       t	]! ]P                  4      t]P                  ]R 4       4       t]P                  ]]P                  ! R4      R	 4       4       4       t]P                  ]]P                  ! R
4      RPR l4       4       4       t]P                  ]RQR l4       4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]R 4       t]P                  ]]P2                  ! RRRR7      RRR l4       4       4       t]P                  ]]P2                  ! RRR7      RSR l4       4       4       t]R 4       t]R 4       t]R  4       t]R! 4       t]P                  ]]P2                  ! R"RRR7      RRR# l4       4       4       t ]P                  ]]P2                  ! R$RR7      RSR% l4       4       4       t!]R& 4       t"]R' 4       t#]P                  ]]P2                  ! R(R)R*7      RTR+ R, ll4       4       4       t$]R- 4       t%]P                  ]]P2                  ! R.4      RUR/ l4       4       4       t&]R0 4       t']P                  ]]P2                  ! R14      RQR2 l4       4       4       t(]P                  ]]PR                  ! R3R)R*7      RVR4 R5 ll4       4       4       t*]R6 4       t+]P                  ]]PR                  ! R74      RWR8 l4       4       4       t,]R9 R: l4       t-]R; R< l4       t.]R= R> l4       t/]R? R@ l4       t0]RR]Pb                  3RA RB ll4       t2]R]Pb                  3RC RD ll4       t3]RXRE RF ll4       t4]R]Pb                  3RG RH ll4       t5]RI 4       t6]P                  ]RXRJ l4       4       t7]RK 4       t8]RL RM l4       t9]RN RO l4       t:R# )Y    )annotations)jitconstexpr_function)core)mathc                D    ^ pT pV^8  d   V^,          pV^,          pK  V# r    )ilog2ns   &  D/app/.local/lib/python3.14/site-packages/triton/language/standard.py_log2r   
   s*    D	A
a%	a	K    c                @    W ^,
          ,          ^ 8H  ;'       d    V ^ 8g  #    r
   )r   s   &r   _is_power_of_twor      s    QKA((!q&(r   c                .    W^,
          ,           V,          # )z
Computes the ceiling division of :code:`x` by :code:`div`

:param x: the input number
:type x: Block
:param div: the divisor
:type div: Block
r
   )xdivs   &&r   cdivr       s     qMc!!r   sigmoidc                L    ^^\         P                  ! V ) 4      ,           ,          # r   )r   exp)r   s   &r   r   r   .   s     DHHaRL !!r   softmaxNc                    Vf   ^ pMTpV \        WVR7      ,
          p\        P                  ! V4      p\        WdVR7      p\        P                  ! WgV4      # N	keep_dims)maxr   r   sumfdiv)r   dimr    ieee_rounding_dimznumdens   &&&&    r   r   r   5   sN     { "	C9--A
((1+C
c9
-C99S}--r   c                H    \         P                  ! W P                  .VR7      # )z^
Returns a contiguous flattened view of :code:`x`.

:param x: the input tensor
:type x: Block
)can_reorder)r   reshapenumel)r   r+   s   &&r   ravelr.   C   s     <<GG9+>>r   c                    W,          V,           pWC,          pWV,          pWt,          p\         P                  ! W(,
          V4      pWV,          pWV,          ,           p	WT,          p
W3# )a  
Transforms the indices of a row-major `size_i * size_j` matrix into
the indices of a column-major matrix for each group of `size_g` rows.

For example, for :code:`size_i = size_j = 4` and :code:`size_g = 2`, it will
transform ::

    [[0 , 1 , 2 , 3 ],
     [4 , 5 , 6 , 7 ],
     [8 , 9 , 10, 11],
     [12, 13, 14, 15]]

into ::

    [[0, 2,  4 , 6 ],
     [1, 3,  5 , 7 ],
     [8, 10, 12, 14],
     [9, 11, 13, 15]]
r   minimum)r   jsize_isize_jsize_gijsize_gjgroup_idoff_inew_inew_js   &&&&&      r   	swizzle2dr<   O   s[    , 
aB oG}HE\\&.&1F	BKELE<r   c                2    \         P                  ! V ^ V4      # )a  
Returns a tensor filled with the scalar value 0 for the given :code:`shape` and :code:`dtype`.

:param shape: Shape of the new array, e.g., (8, 16) or (8, )
:type shape: tuple of ints
:param dtype: Data-type of the new array, e.g., :code:`tl.float16`
:type dtype: DType
)r   full)shapedtypes   &&r   zerosrA   w   s     99UAu%%r   c                B    \        V P                  V P                  4      # )z{
Returns a tensor of zeros with the same shape and type as a given tensor.

:param input: input tensor
:type input: Tensor
)rA   r?   r@   )inputs   &r   
zeros_likerD      s     ekk**r   c                    V'       d   W8H  ;'       d    W8  pMR pW8  ;'       g    Tp\         P                  ! W`V4      p\         P                  ! WaV4      pWx3# Fr   where)	value1index1value2index2tie_break_lefttiegtv_reti_rets	   &&&&&    r   _argmax_combinerR      sS    226?			CBJJr6*EJJr6*E<r   c                    \        WW#R 4      # TrR   rI   rJ   rK   rL   s   &&&&r   _argmax_combine_tie_break_leftrW          664@@r   c                    \        WW#R 4      # rF   rU   rV   s   &&&&r   _argmax_combine_tie_break_fastrZ          665AAr   c                .    \         P                  ! W4      # N)r   maximumabs   &&r   _elementwise_maxrb          <<r   r^   return_indicesreturn_indices_tie_break_left)return_indices_argtie_break_argc                   \         P                  ! V 4      p V'       dC   V'       d   \         P                  ! W\        VR 7      # \         P                  ! W\        VR 7      # \         P
                  ! V P                  P                  4      \         P
                  ! ^ 4      8  d   \         P
                  ! V P                  P                  4       4      '       d!   V P                  \         P                  4      p MFV P                  P                  4       '       g   Q R4       hV P                  \         P                  4      p \         P                  ! W\        VR 7      # r   z"Expecting input to be integer type)r   _promote_bfloat16_to_float32_reduce_with_indicesrW   rZ   	constexprr@   primitive_bitwidthis_floatingtofloat32is_intint32reducerb   rC   axisrd   re   r    s   &&&&&r   r!   r!      s    
 --e4E(,,U:Xdmnn,,U:Xdmnn>>%++889DNN2<NN~~ekk55788.{{))++Q-QQ+,{{5(8INNr   zmaximum indexrM   )rg   c                &    \        WR W#R7      w  rEV# T)rd   re   r    )r!   rC   ru   rM   r    _rets   &&&&  r   argmaxr{      s     5tSawHQJr   c                    V'       d   W8H  ;'       d    W8  pMR pW8  ;'       g    Tp\         P                  ! W`V4      p\         P                  ! WaV4      pWx3# rF   rG   )	rI   rJ   rK   rL   rM   rN   lt	value_ret	index_rets	   &&&&&    r   _argmin_combiner      sT    226?			CB

2v.I

2v.Ir   c                    \        WW#R 4      # rT   r   rV   s   &&&&r   _argmin_combine_tie_break_leftr      rX   r   c                    \        WW#R 4      # rF   r   rV   s   &&&&r   _argmin_combine_tie_break_fastr      r[   r   c                .    \         P                  ! W4      # r]   r0   r_   s   &&r   _elementwise_minr      rc   r   r1   c                   \         P                  ! V 4      p V'       dC   V'       d   \         P                  ! W\        VR 7      # \         P                  ! W\        VR 7      # \         P
                  ! V P                  P                  4      ^ 8  d   \         P
                  ! V P                  P                  4       4      '       d!   V P                  \         P                  4      p MFV P                  P                  4       '       g   Q R4       hV P                  \         P                  4      p \         P                  ! W\        VR 7      # ri   )r   rj   rk   r   r   rl   r@   rm   rn   ro   rp   rq   rr   rs   r   rt   s   &&&&&r   minr      s    
 --e4E(,,U:Xdmnn,,U:Xdmnn>>%++889B>~~ekk55788.{{))++Q-QQ+,{{5(8INNr   zminimum indexc                &    \        WR W#R7      w  rEV# rw   )r   rx   s   &&&&  r   argminr      s     TQ_uFAJr   c                    W,           # r]   r
   r_   s   &&r   _sum_combiner     	    5Lr   c                   Ve   V# R pV P                  4       '       d(   V P                  ^ 8  d   \        P                  pV# R pV# V P	                  4       '       d$   V P                  ^ 8  d   \        P
                  MR pV# r]   )is_int_signedint_bitwidthr   rr   is_int_unsigneduint32)in_dtyper@   	out_dtypes   && r   _pick_sum_dtyper     s     I"*"7"7""<DJJ	  CG	  
	!	!	#	##+#8#82#=DKK4	r   r"   r@   )	dtype_argc                   V ^8  d   QhRR/#    r@   core.constexprr
   )formats   "r   __annotate__r     s     G G. Gr   c                    \        V P                  V4      pVe   V P                  V4      p \        P                  ! W\
        VR7      # r   )r   r@   ro   r   rs   r   )rC   ru   r    r@   r   s   &&&& r   r"   r"     s;    
 !0U CI#;;uLIFFr   c                    W,          # r]   r
   r_   s   &&r   _xor_combiner   (  r   r   zxor sumc                    \         P                  ! V P                  P                  P	                  4       R 4       \         P
                  ! W\        VR7      # )z#xor_sum only supported for integersr   )r   static_asserttypescalarrq   rs   r   rC   ru   r    s   &&&r   xor_sumr   0  s;     	uzz((//13XY;;uLIFFr   c                    W,          # r]   r
   )r   ys   &&r   _or_combiner   ;  r   r   	reduce_orc                    \         P                  ! V P                  P                  P	                  4       R 4       \         P
                  ! W\        VR7      # )z%reduce_or only supported for integersr   )r   r   r   r   rq   rs   r   r   s   &&&r   r   r   @  s;     	uzz((//13Z[;;uK9EEr   cumsumc                   V ^8  d   QhRR/# r   r
   )r   s   "r   r   r   N  s     	E 	E 	Er   c                    \         P                  ! V 4      p \        V P                  V4      pVe   V P	                  V4      p \         P
                  ! W\        V4      # r]   )r   rj   r   r@   ro   associative_scanr   )rC   ru   reverser@   r   s   &&&& r   r   r   K  sM     --e4E /U CI#  lGDDr   c                    W,          # r]   r
   r_   s   &&r   _prod_combiner   ]  r   r   cumprodc                f    \         P                  ! V 4      p \         P                  ! W\        V4      # r]   )r   rj   r   r   )rC   ru   r   s   &&&r   r   r   b  s)    
 --e4E  mWEEr   c                    V ^8  d   QhRRRR/# )r   n_dimsr   r2   r
   )r   s   "r   r   r   o  s      ~ . r   c                    \         P                  ! ^ ^4      p\         P                  ! V^.W,
          ^,
          ,          ^.,           ^.V,          ,           4      pV# r	   )r   aranger,   )r   r2   ars   && r   
_indicatorr   n  sF    	Q	B	b1#a0A36!q@	ABIr   c                   V ^8  d   QhRR/# )r   r   r   r
   )r   s   "r   r   r   v  s      . r   c                n   \        V P                  4      p\        V P                  P                  R R7      pV P                  VR R7      pV\        WS^,
          V,
          R 4      ,          pVP                  V P                  R R7      p\        W24      p\        P                  ! W8  W,          8g  Wp4      p	V	# )Tbitwidthsignedbitcast)
r   r-   _get_int_dtyper@   rm   ro   r   r   r   rH   )
r   flipr   r   idtypeixiyr   is_rightrz   s
   &&&       r   _compare_and_swapr   u  s     #177^F QWW%?%?MF	
fd	#B	gb1*q.$/	/B
aggt$A &$H **ae11
8CJr   c                    V ^8  d   QhRRRR/# )r   stager   orderr
   )r   s   "r   r   r     s      ~ n r   c                    V^8X  d!   \        \        V P                  4      V4      pMTp\        P                  ! V4       F  p\        WV^,
          V,
          4      p K  	  V # )zR
order_type 0 == ascending
order_type 1 == descending
order_type 2 == alternating
)r   r   r-   r   static_ranger   )r   r   r   r   r   s   &&&  r   _bitonic_merge_hypercuber     sR     z%.%0u%auqy1}5 &Hr   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r
   )r   s   "r   r   r     s!      ^ N N r   c                    \         P                  ! V ^.\        V P                  4      ,          4      p\	        WAV4      p\         P                  ! W@P
                  4      p V # )r   )r   r,   r   r-   r   r?   )r   r   r   r   hs   &&&& r   _bitonic_merger     sD    QeAGGn,-A 51AQ AHr   c               $    V ^8  d   QhRRRRRR/# )r   kr   r$   
descendingr
   )r   s   "r   r   r     s"     % %N % %Sa %r   c                   Vf   \        V P                  4      ^,
          MTp\        P                  ! V\        V P                  4      ^,
          8H  R4       \	        V P                  V,          4      pVf   TM
\	        V4      p\	        V P
                  4      p\        P                  ! Y'       d   ^.V,          M^.4      p\        P                  ! ^V^,           4       F  p	\        YW8  d   ^MT4      pK  	  \        P                  ! V^,           V^,           4       F{  p	V'       d/   \        V\	        VP
                  4      ^,
          V,
          R7      M-\        V\	        VP
                  4      ^,
          V,
          R7      p\        YW8  d   ^MT4      pK}  	  \        P                  ! WP                  RR ^V,          .,           4      p V # )aA  
Sorts a tensor along a specified dimension.

:param x: The input tensor to be sorted.
:type x: Tensor
:param dim: The dimension along which to sort the tensor. If None, the tensor is sorted along the last dimension. Currently, only sorting along the last dimension is supported.
:type dim: int, optional
:param k: the number of top elements to select. If none, assume k = x.shape[dim]
:type k: int, optional
:param descending: If set to True, the tensor is sorted in descending order. If set to False, the tensor is sorted in ascending order.
:type descending: bool, optional
N+only minor dimension is currently supported)ru   )lenr?   r   r   r   r-   r,   r   r   r!   r   )
r   r   r$   r   r&   log_nlog_kr   r   r   s
   &&&&      r   	sort_implr     sY    03{3qww<!+Dts177|a//1^_!!''$-0E%&YEE!HE"177^F 	QfQC8A q%!),$Q	1zJ -
 uqy%!)49CCqww!+e35QV[\]\c\cVdghVhkpVpIr$QAIq:N 5
 	Q5z12AHr   c                    V ^8  d   QhRRRR/# r   r$   r   r   r
   )r   s   "r   r   r     s     8 8 8N 8r   c                    \        WVR 7      # ))r$   r   r   )r   r$   r   s   &&&r   sortr     s    QJ77r   c                    V ^8  d   QhRRRR/# )r   r   r   r$   r
   )r   s   "r   r   r     s     7 7~ 7N 7r   c                    \        WVRR7      # )a  
Returns the k largest elements of the input tensor along the specified dimension.

The elements are returned in sorted order (largest first).

:param x: The input tensor.
:type x: Tensor
:param k: The number of top elements to return. Must be a power of two.
:type k: int
:param dim: The dimension along which to find the top k elements.
            If None, uses the last dimension. Currently only the last dimension is supported.
:type dim: int, optional
:return: A tensor containing the k largest elements along the specified dimension.
:rtype: Tensor

Example::

    # Get top 4 elements from a 1D tensor
    x = tl.arange(0, 16)
    top4 = tl.topk(x, 4)  # Returns [15, 14, 13, 12]
T)r   r$   r   r   )r   r   r$   s   &&&r   topkr     s    . Q66r   c                    V ^8  d   QhRRRR/# r   r
   )r   s   "r   r   r     s     9 9. 9^ 9r   c                    Vf   \        V P                  4      ^,
          MTp\        P                  ! V\        V P                  4      ^,
          8H  R4       \	        V P                  R,          4      p\        WW$4      # )Nr   r   )r   r?   r   r   r   r   )r   r$   r   r&   r   s   &&&  r   bitonic_merger     s^     03{3qww<!+Dts177|a//1^_"1772;/F!Z88r   c                d    V f   \        V4      ^,
          p V ^ 8  d   V \        V4      ,          p V # r]   )r   )r$   r?   s   &&r   _get_flip_dimr     s.    
{%j1n
Qws5zJr   c                F   \         P                  ! \        V P                  4      ) V8*  ;'       d    V\        V P                  4      8  4       \	        WP                  4      p\         P                  ! \        V P                  V,          4      4       \        V P                  V,          4      p\        V P                  P                  RR7      p\         P                  ! V P                  VRR7      V P                  RV ^.V,          ,           V P                  V^,           R ,           4      p\         P                  ! V4       F  pV\        WRV,           R4      ,          pK  	  \         P                  ! WPP                  4      P                  V P                  RR7      p V # )z
Flips a tensor `x` along the dimension `dim`.

:param x: the first input tensor
:type x: Block
:param dim: the dimension to flip along
:type dim: int
Tr   r   N)r   r   r   r?   r   r   r   r   r@   rm   r,   ro   r   r   )r   r$   r&   stepsr   r   r   s   &&     r   r   r      s,    	AGG}+BBc!''l0BC(gg6D'67!!''$-0E QWW%?%?MFQTT&$T/$1#+1MPQPWPWX\_`X`XaPb1bcAu%!8T** &Q ##AGGT#:AHr   c                    \         P                  ! W4      p\        VP                  4      ^8X  d   V# \         P                  ! W"P                  RR ^VP                  R,          ,          .,           4      # )a  
Interleaves the values of two tensors along their last dimension. The two tensors must have the same shape.
Equivalent to `tl.join(a, b).reshape(a.shape[:-1] + [2 * a.shape[-1]])`

:param a: The first input tensor.
:type a: Tensor
:param b: The second input tensor.
:type b: Tensor
N)r   joinr   r?   r,   )r`   ra   cs   && r   
interleaver     sU     			!A
177|q
 ||Awws|q1772;.??@@r   c                   V ^8  d   QhRR/# r   r$   r   r
   )r   s   "r   r   r   1  s     8 8N 8r   c                    \         P                  ! V P                  V,          ^8H  4       V P                  V P                  RV V P                  V^,           R ,           4      # )r   N)r   r   r?   r,   r   r$   s   &&r   squeezer   0  sJ    qwws|q()99QWWTc]QWWS1WX%6677r   c                   V ^8  d   QhRR/# r   r
   )r   s   "r   r   r   7  s     < <n <r   c                t    V P                  V P                  R V R,           V P                  VR  ,           4      # )Nr   )r,   r?   r   s   &&r   	unsqueezer   6  s/    99QWWTc]U*QWWST]:;;r   )NFFrF   )NFTF)TF)NFN)NF)r   FN)r   Fr]   );
__future__r   runtime.jitr   r    r   r   r   r   get_int_dtyper   _tensor_member_fnr   _add_math_1arg_docstrr   r   r.   r<   rA   rD   rR   rW   rZ   rb   _add_reduction_docstrr!   r{   r   r   r   r   r   r   r   r   r"   r   r   r   r   _add_scan_docstrr   r   r   r   r   r   r   CONSTEXPR_0r   r   r   r   r   r   r   r   r   r
   r   r   <module>r     s   " 1  
   ) ) $D$6$67 	"  	" I&" '  " I&. '  . ?  ? $ $N 	& 	& + +   A A B B   I:J*IKOK  O" O;KL M       A A B B   I:J*IKOK  O" O;KL M  
     EW5G 6  G   I&G '  G   K(F )  F x73	E 4  	E   y!F "  F    $  *   %)dhdtdt % %P "&TEUEU 8 8 7 72 +/dN^N^ 9 9     . A A, 8 8
 < <r   