
    קg	                         d Z ddlmZ 	 ddlmZ n"# e$ r  G d d          Z e            ZY nw xY wg dZd Zd Z	d	e
fd
ZddZd Zed             ZdS )zNThis package adds support for NVIDIA Tools Extension (NVTX) used in profiling.    )contextmanager)_nvtxc                   0    e Zd Zed             ZeZeZeZdS )	_NVTXStubc                       t          d          )NzANVTX functions not installed. Are you sure you have a CUDA build?)RuntimeError)argskwargss     K/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/cuda/nvtx.py_failz_NVTXStub._fail   s    S      N)__name__
__module____qualname__staticmethodr   
rangePushArangePopmarkA r   r   r   r      s8        		 	 
	
 
r   r   )
range_push	range_poprange_start	range_endmarkrangec                 *    t          j        |           S )z
    Push a range onto a stack of nested range span.  Returns zero-based depth of the range that is started.

    Args:
        msg (str): ASCII message to associate with range
    )r   r   msgs    r   r   r      s     C   r   c                  (    t          j                    S )zlPop a range off of a stack of nested range spans.  Returns the  zero-based depth of the range that is ended.)r   r   r   r   r   r   r   %   s    >r   returnc                 *    t          j        |           S )a  
    Mark the start of a range with string message. It returns an unique handle
    for this range to pass to the corresponding call to rangeEnd().

    A key difference between this and range_push/range_pop is that the
    range_start/range_end version supports range across threads (start on one
    thread and end on another thread).

    Returns: A range handle (uint64_t) that can be passed to range_end().

    Args:
        msg (str): ASCII message to associate with the range.
    )r   rangeStartAr   s    r   r   r   *   s     S!!!r   Nc                 .    t          j        |            dS )z
    Mark the end of a range for a given range_id.

    Args:
        range_id (int): an unique handle for the start range.
    N)r   rangeEnd)range_ids    r   r   r   ;   s     
N8r   c                 *    t          j        |           S )z
    Describe an instantaneous event that occurred at some point.

    Args:
        msg (str): ASCII message to associate with the event.
    )r   r   r   s    r   r   r   E   s     ;sr   c              /      K   t           | j        |i |           	 dV  t                       dS # t                       w xY w)a  
    Context manager / decorator that pushes an NVTX range at the beginning
    of its scope, and pops it at the end. If extra arguments are given,
    they are passed as arguments to msg.format().

    Args:
        msg (str): message to associate with the range
    N)r   formatr   )r   r	   r
   s      r   r   r   O   sP       zsz4*6**+++	s	   2 A)r    N)__doc__
contextlibr   torch._Cr   ImportErrorr   __all__r   r   intr   r   r   r   r   r   r   <module>r/      s   U U % % % % % %   	 	 	 	 	 	 	 	 IKKEEE S
R
R! ! !  
" " " " ""          s    00