a
    NSic                     @   sT   d dl Z d dlZddlmZmZ g dZdddZdd	 Zd
d Zej	dd Z
dS )    N   )cudartcheck_error)ZgpustarttimestampZgpuendtimestampZ
gridsize3dZthreadblocksizeZstreamidzenableonstart 0Zconckerneltrace	key_valuec                 C   s   t  }t|dstd|d u r$tn|}|dkr:|jj}n|dkrL|jj}ntdtj	ddF}|
dd	d
 |D  |  t||j| | W d    n1 s0    Y  d S )NcudaOutputModez-HIP does not support profiler initialization!r   Zcsvz;supported CUDA profiler output modes are: key_value and csvT)delete   
c                 s   s   | ]}| d V  qdS )asciiN)encode).0f r   O/var/www/html/django/DPS/env/lib/python3.9/site-packages/torch/cuda/profiler.py	<genexpr>       zinit.<locals>.<genexpr>)r   hasattrAssertionErrorDEFAULT_FLAGSr   KeyValuePairCSVRuntimeErrortempfileNamedTemporaryFilewritejoinflushr   cudaProfilerInitializename)output_fileflagsZoutput_modertZoutput_mode_enumr   r   r   r   init   s    


r!   c                   C   s   t t   d S N)r   r   cudaProfilerStartr   r   r   r   start"   s    r$   c                   C   s   t t   d S r"   )r   r   cudaProfilerStopr   r   r   r   stop&   s    r&   c                   c   s$   zt   d V  W t  nt  0 d S r"   )r$   r&   r   r   r   r   profile*   s    r'   )Nr   )r   
contextlib r   r   r   r!   r$   r&   contextmanagerr'   r   r   r   r   <module>   s   
