o
    h                     @  s  U d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
 er;ddlmZ eee eedf ejejf Zeedf ZdZdYddZdZddZd[ddZdd Zd\ddZi d d!d"d!d#d!d$d!d%d&d'd(d)d*d+d&d,d-d.d-d/d(d0d1d2d1d3d4d5d4d6d7d8d9d9d:d:d;d<d=d=d>d?d@dAdBdCdDZee D ]Zeee< qdEdF Zi dGdH dID dJdH dID dKdH dLD dMdH dND dOd dPZdQedR< e D ]
\Z Zee ee < qd]dVdWZ!dXS )^    )annotationsreduce)AnyCallableTYPE_CHECKINGUnionListDict   core.i   iterableIterableTypepathObjPathreturnr   c                 C  s   t dd || S )Nc                 S  s   | | S N )aidxr   r   S/home/www/facesmatcher.com/frenv_anti/lib/python3.10/site-packages/triton/_utils.py<lambda>   s    z#get_iterable_path.<locals>.<lambda>r   )r   r   r   r   r   get_iterable_path      r   tuple[int, ...]valc                 C  sB   t |dksJ t |dkr| nt| |d d }|||d < d S )Nr   r   )lenr   )r   r   r   prevr   r   r   set_iterable_path   s   "r    Union[IterableType, Any]predCallable[[ObjPath, Any], bool]list[ObjPath]c                   sF   ddl m fddi d fd	d
  d|  t S )Nr   r   c                   s   t | tt j jfS r   )
isinstancelisttuple
tuple_typexr   r   r   r      s    zfind_paths_if.<locals>.<lambda>r   r   currentr   c                   sL   |rt |D ]\}} g | |R | qd S | |r$d | < d S d S r   )	enumerate)r   r+   r   item)_implis_iterabler"   retr   r   r.      s   
zfind_paths_if.<locals>._implr   )r   r   r+   r   )languager   r&   keys)r   r"   r   )r.   r   r/   r"   r0   r   find_paths_if   s   
r3   c                 C  s   | | d @ dkS )Nr   r   r   r)   r   r   r   is_power_of_two*   r   r4   shape	List[int]c                 C  s|   d}t | D ]&\}}t|tstd| dt| dt|s(td| d||9 }q|tkr<td| dt d|S )	Nr   zShape element z1 must have type `constexpr[int]`, got `constexpr[]z must be a power of 2znumel (z') exceeds triton maximum tensor numel ())r,   r%   int	TypeErrortyper4   
ValueErrorTRITON_MAX_TENSOR_NUMEL)r5   Znumelidr   r   r   validate_block_shape.   s   

r@   boolu1Zint1Zuint1i1Z
float8e4nvZfp8e4nvZfloat8e5Zfp8e5Zfloat8e4b15Zfp8e4b15Zfloat8_e4m3fnZ
float8e4b8Zfp8e4b8Zfloat8_e4m3fnuzZfloat8_e5m2Zfloat8e5b16Zfp8e5b16Zfloat8_e5m2fnuzZhalfZfp16Zfloat16Zbfloat16bf16floatZfp32Zfp64i8Zi16Zi32Zi64u8u16u32Zu64void)Zfloat32doubleZfloat64Zint8Zint16r9   Zint32Zint64Zuint8Zuint16Zuint32Zuint64rJ   c                 C  s   t | dd }t| S )N.r   )strsplittype_canonicalisation_dict)dtypeZ	dtype_strr   r   r   canonicalize_dtypee   s   rQ   c                 C     i | ]}d | |qS )ur   .0nr   r   r   
<dictcomp>k       rW   )r             @   c                 C  rR   )r>   r   rT   r   r   r   rW   m   rX   c                 C  rR   )fpr   rT   r   r   r   rW   o   rX   )rZ   r[   r\   c                 C  s   i | ]}d | dqS )Zfp8rY   r   )rU   suffixr   r   r   rW   q   rX   )Ze4nvZe4b15Ze4b8Ze5Ze5b16rZ   )rD   rJ   zDict[str, int]BITWIDTH_DICTrP   rM   r9   c                 C  s   t |  S r   )r_   )rP   r   r   r   get_primitive_bitwidth{   s   r`   N)r   r   r   r   r   r   )r   r   r   r   r   r   )r   r!   r"   r#   r   r$   )r5   r6   )rP   rM   r   r9   )"
__future__r   	functoolsr   typingr   r   r   r   r	   r
   r1   r   r&   r'   r(   r   r9   r   r=   r   r    r3   r4   r@   rO   valuesvrQ   r_   __annotations__itemskr`   r   r   r   r   <module>   s      



	
%
	