o
    oh                     @   sZ   d dl mZmZ d dlmZmZ ddlmZmZ dZ	G dd dZ
dd
dZdddZd	S )   )enter_state
exit_state)enter_scope
exit_scope    )CompiledKernelLazyDict__proton_launch_metadatac                   @   sZ   e Zd Zg dZdd eD dg dg Zededdfd	d
ZededdfddZdS )
TritonHook)          @   c                 C   s   g | ]}d | qS )flops ).0widthr   r   h/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/triton/profiler/hook.py
<listcomp>
   s    zTritonHook.<listcomp>bytesr   	lazy_dictreturnNc                    s@   t t |   t   fddtjD }t d d|d d S )Nc                    s   i | ]}| v r| | qS r   r   )r   kmetadatar   r   
<dictcomp>   s    z$TritonHook.enter.<locals>.<dictcomp>nameT)	triton_opmetrics)r   COMPUTE_METADATA_SCOPE_NAMEgetr   r
   r   r   )r   
fn_metricsr   r   r   enter   s
   zTritonHook.enterc                 C   s   t dd d S )NT)r   )r   )r   r   r   r   exit   s   zTritonHook.exit)	__name__
__module____qualname__flops_widthr   staticmethodr   r"   r#   r   r   r   r   r
      s    r
   r   Nc                   C   s"   t jd u rtjt _tjt _d S d S N)r   launch_enter_hookr
   r"   r#   launch_exit_hookr   r   r   r   register_triton_hook   s   
r,   c                   C   s    t jtjkrd t _d t _d S d S r)   )r   r*   r
   r"   r+   r   r   r   r   unregister_triton_hook   s   
r-   )r   N)stater   r   scoper   r   triton.compilerr   r   r   r
   r,   r-   r   r   r   r   <module>   s    
