o
    i	                     @  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   g/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/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&    



 
