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   H/var/www/html/scripts/venv/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   numelidr   r   r   validate_block_shape.   s   

rA   boolu1int1uint1i1
float8e4nvfp8e4nvfloat8e5fp8e5float8e4b15fp8e4b15float8_e4m3fn
float8e4b8fp8e4b8float8_e4m3fnuzfloat8_e5m2float8e5b16fp8e5b16float8_e5m2fnuzhalffp16float16bfloat16bf16floatfp32fp64i8i16i32i64u8u16u32u64void)float32doublefloat64int8int16r9   int32int64uint8uint16uint32uint64re   c                 C  s   t | dd }t| S )N.r   )strsplittype_canonicalisation_dict)dtype	dtype_strr   r   r   canonicalize_dtypee   s   rw   c                 C     i | ]}d | |qS )ur   .0nr   r   r   
<dictcomp>k       r}   )r             @   c                 C  rx   )r?   r   rz   r   r   r   r}   m   r~   c                 C  rx   )fpr   rz   r   r   r   r}   o   r~   )r   r   r   c                 C  s   i | ]}d | dqS )fp8r   r   )r{   suffixr   r   r   r}   q   r~   )e4nve4b15e4b8e5e5b16r   )rY   re   zDict[str, int]BITWIDTH_DICTru   rr   r9   c                 C  s   t |  S r   )r   )ru   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   )ru   rr   r   r9   )"
__future__r   	functoolsr   typingr   r   r   r   r	   r
   r1   r   r&   r'   r(   r   r9   r   r=   r   r    r3   r4   rA   rt   valuesvrw   r   __annotations__itemskr   r   r   r   r   <module>   s      



	
%
	