U
    ®9%e	  ã                   @  s’   d dl mZ ddlmZ ddlmZ edd„ ƒZee d¡d	d„ ƒƒZee d
¡ddd
„ƒƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZdS )é    )Úannotationsé   )Újité   )Úcorec                 C  s   | | d | S )z¬
    Computes the ceiling division of :code:`x` by :code:`div`

    :param x: the input number
    :type input: Block
    :param div: the divisor
    :param div: Block
    r   © )ÚxÚdivr   r   úW/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/triton/language/standard.pyÚcdiv   s    
r   Úsigmoidc                 C  s   ddt  |  ¡  S )Nr   )r   Úexp©r   r   r   r
   r      s    ÚsoftmaxFc                 C  s4   | t  | d¡ }t  |¡}t  |d¡}t  |||¡S )Nr   )r   Úmaxr   ÚsumZfdiv)r   Zieee_roundingÚzÚnumZdenr   r   r
   r      s    
c                 C  s   t  | | jg¡S )zn
    Returns a contiguous flattened view of :code:`x`.

    :param x: the input tensor
    :type x: Block
    )r   ÚviewZnumelr   r   r   r
   Úravel'   s    r   c                 C  sT   | | | }|| }|| }|| }t  || |¡}|||  }	|| | }
|	|
fS )a™  
    Transforms indices of a row-major size_i*size_j matrix into those
    of one where indices are row major for each group of size_j rows.
    For example, for size_i = size_j = 4 and 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)ÚiÚjZsize_iZsize_jZsize_gZijZsize_gjZgroup_idZoff_iZnew_iZnew_jr   r   r
   Ú	swizzle2d2   s    r   c                 C  s   t  | d|¡S )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   )r   Úfull)ÚshapeÚdtyper   r   r
   ÚzerosS   s    
r   c                 C  s   t | j| jƒS )N)r   r   r   )Úinputr   r   r
   Ú
zeros_like`   s    r   N)F)Ú
__future__r   Zruntime.jitr   Ú r   r   Z_add_math_1arg_docstrr   r   r   r   r   r   r   r   r   r
   Ú<module>   s$   



 
